From 153cf970492297dc272bdcc4a8c0f6be33ea0405 Mon Sep 17 00:00:00 2001 From: justinsb Date: Mon, 6 Sep 2021 14:43:35 -0400 Subject: [PATCH] tests: create-cluster integration tests should validate additional objects As we start creating them for addon support, we want to be sure that they aren't created elsewhere. --- cmd/kops/create_cluster_integration_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cmd/kops/create_cluster_integration_test.go b/cmd/kops/create_cluster_integration_test.go index 9a817f46da..74cb5a3be3 100644 --- a/cmd/kops/create_cluster_integration_test.go +++ b/cmd/kops/create_cluster_integration_test.go @@ -260,6 +260,25 @@ func runCreateClusterIntegrationTest(t *testing.T, srcDir string, version string yamlAll = append(yamlAll, actualYAML) } + // Compare additional objects + addons, err := clientset.AddonsFor(&clusters.Items[0]).List() + if err != nil { + t.Fatalf("error listing addons: %v", err) + } + + for _, addon := range addons { + u := addon.ToUnstructured() + + actualYAMLBytes, err := kopscodecs.ToVersionedYamlWithVersion(u, schema.GroupVersion{Group: "kops.k8s.io", Version: version}) + if err != nil { + t.Fatalf("unexpected error serializing Addon: %v", err) + } + + actualYAML := strings.TrimSpace(string(actualYAMLBytes)) + + yamlAll = append(yamlAll, actualYAML) + } + actualYAML := strings.Join(yamlAll, "\n\n---\n\n") golden.AssertMatchesFile(t, actualYAML, path.Join(srcDir, expectedClusterPath)) }