From fa6bd6454f7fb75a56164645e00310f5d1542f6e Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Tue, 2 Jul 2024 08:36:11 +0200 Subject: [PATCH] Several fixes to support clusterctl upgrade tests on supervisor * Use infrastructure-components-supervisor.yaml for supervisor tests of old versions * vsphere.yaml: add variables for serviceaccount configmap, necessary to install old versions * add net-operator for supervisor tests on separate kind cluster * disable capv image preload because we are using kind * fix templates used in old supervisor e2e tests --- test/e2e/clusterctl_upgrade_test.go | 8 ++------ test/e2e/config/vsphere.yaml | 3 +++ .../clusterclass/clusterclass-quick-start-supervisor.yaml | 2 +- .../v1.9/clusterclass/kustomization.yaml | 3 +++ .../v1.9/clusterclass/patch-controlplaneendpoint.yaml | 5 +++++ test/e2e/e2e_setup_test.go | 4 ++-- test/framework/framework.go | 8 ++++++++ 7 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/patch-controlplaneendpoint.yaml diff --git a/test/e2e/clusterctl_upgrade_test.go b/test/e2e/clusterctl_upgrade_test.go index c862530b02..6f13780576 100644 --- a/test/e2e/clusterctl_upgrade_test.go +++ b/test/e2e/clusterctl_upgrade_test.go @@ -24,8 +24,6 @@ import ( . "github.com/onsi/gomega" capi_e2e "sigs.k8s.io/cluster-api/test/e2e" "sigs.k8s.io/cluster-api/test/framework/clusterctl" - - vsphereframework "sigs.k8s.io/cluster-api-provider-vsphere/test/framework" ) var ( @@ -55,7 +53,6 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10 SkipCleanup: skipCleanup, MgmtFlavor: testSpecificSettingsGetter().FlavorForMode("topology"), PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc, - PreUpgrade: vsphereframework.LoadImagesFunc(ctx), InitWithBinary: fmt.Sprintf(clusterctlDownloadURL, capiStableRelease), InitWithCoreProvider: fmt.Sprintf(providerCAPIPrefix, capiStableRelease), InitWithBootstrapProviders: []string{fmt.Sprintf(providerKubeadmPrefix, capiStableRelease)}, @@ -69,7 +66,7 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.10 InitWithKubernetesVersion: "v1.30.0", WorkloadKubernetesVersion: "v1.30.0", WorkloadFlavor: testSpecificSettingsGetter().FlavorForMode("workload"), - UseKindForManagementCluster: false, + UseKindForManagementCluster: true, } }) }, WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP")) @@ -93,7 +90,6 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.9= SkipCleanup: skipCleanup, MgmtFlavor: testSpecificSettingsGetter().FlavorForMode("topology"), PostNamespaceCreated: testSpecificSettingsGetter().PostNamespaceCreatedFunc, - PreUpgrade: vsphereframework.LoadImagesFunc(ctx), InitWithBinary: fmt.Sprintf(clusterctlDownloadURL, capiStableRelease), InitWithCoreProvider: fmt.Sprintf(providerCAPIPrefix, capiStableRelease), InitWithBootstrapProviders: []string{fmt.Sprintf(providerKubeadmPrefix, capiStableRelease)}, @@ -107,7 +103,7 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (CAPV 1.9= InitWithKubernetesVersion: "v1.29.0", WorkloadKubernetesVersion: "v1.29.0", WorkloadFlavor: testSpecificSettingsGetter().FlavorForMode("workload"), - UseKindForManagementCluster: false, + UseKindForManagementCluster: true, } }) }, WithIP("WORKLOAD_CONTROL_PLANE_ENDPOINT_IP")) diff --git a/test/e2e/config/vsphere.yaml b/test/e2e/config/vsphere.yaml index 7a2604c5d8..8d086924e6 100644 --- a/test/e2e/config/vsphere.yaml +++ b/test/e2e/config/vsphere.yaml @@ -275,6 +275,9 @@ variables: EXP_NODE_ANTI_AFFINITY: "true" CAPI_DIAGNOSTICS_ADDRESS: ":8080" CAPI_INSECURE_DIAGNOSTICS: "true" + # Required to be set to install capv-supervisor <= v1.10, but getting created. + SERVICE_ACCOUNTS_CM_NAMESPACE: "capv-system" + SERVICE_ACCOUNTS_CM_NAME: "service-accounts-cm" intervals: default/wait-controllers: ["5m", "10s"] diff --git a/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/clusterclass-quick-start-supervisor.yaml b/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/clusterclass-quick-start-supervisor.yaml index 10561ef024..f58e3d6dea 100644 --- a/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/clusterclass-quick-start-supervisor.yaml +++ b/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/clusterclass-quick-start-supervisor.yaml @@ -94,7 +94,7 @@ spec: name: enableSSHIntoNodes - definitions: - jsonPatches: - - op: add + - op: replace path: /spec/template/spec/controlPlaneEndpoint valueFrom: template: | diff --git a/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/kustomization.yaml b/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/kustomization.yaml index bab4a05d78..83e3657c81 100644 --- a/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/kustomization.yaml +++ b/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/kustomization.yaml @@ -12,3 +12,6 @@ patches: - target: kind: ClusterClass path: ./patch-namingstrategy.yaml + - target: + kind: VSphereClusterTemplate + path: ./patch-controlplaneendpoint.yaml diff --git a/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/patch-controlplaneendpoint.yaml b/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/patch-controlplaneendpoint.yaml new file mode 100644 index 0000000000..470c5a85e4 --- /dev/null +++ b/test/e2e/data/infrastructure-vsphere-supervisor/v1.9/clusterclass/patch-controlplaneendpoint.yaml @@ -0,0 +1,5 @@ +- op: add + path: /spec/template/spec/controlPlaneEndpoint + value: + host: "" + port: 0 diff --git a/test/e2e/e2e_setup_test.go b/test/e2e/e2e_setup_test.go index 4e048eab0c..1a1ec25483 100644 --- a/test/e2e/e2e_setup_test.go +++ b/test/e2e/e2e_setup_test.go @@ -186,11 +186,11 @@ func Setup(specName string, f func(testSpecificSettings func() testSettings), op }) if testMode == SupervisorTestMode { - runtimeExtensionProviders = append(runtimeExtensionProviders, "vm-operator") + runtimeExtensionProviders = append(runtimeExtensionProviders, "vm-operator", "net-operator") } if testTarget == VCSimTestTarget { - runtimeExtensionProviders = append(runtimeExtensionProviders, "net-operator") + runtimeExtensionProviders = append(runtimeExtensionProviders, "vcsim") } }) defer AfterEach(func() { diff --git a/test/framework/framework.go b/test/framework/framework.go index 5eb482e708..8e8b9eb327 100644 --- a/test/framework/framework.go +++ b/test/framework/framework.go @@ -142,7 +142,15 @@ func LoadE2EConfig(ctx context.Context, configPath string, configOverridesPath, Byf("Overriding source folder for vsphere provider to /config/supervisor in the e2e config") for i := range config.Providers { if config.Providers[i].Name == "vsphere" { + // Replace relativ path for latest version. config.Providers[i].Versions[0].Value = strings.ReplaceAll(config.Providers[i].Versions[0].Value, "/config/default", "/config/supervisor") + // Replace target file in github. + for j, version := range config.Providers[i].Versions { + if strings.HasSuffix(version.Value, "infrastructure-components.yaml") { + version.Value = fmt.Sprintf("%s-supervisor.yaml", strings.TrimSuffix(version.Value, ".yaml")) + config.Providers[i].Versions[j] = version + } + } break } }