From 24614254d0cd6cb76e212011d72dd90d93e2dc83 Mon Sep 17 00:00:00 2001 From: Lennart Jern Date: Fri, 25 Nov 2022 14:42:44 +0200 Subject: [PATCH] e2e: add init versions for providers --- test/e2e/clusterctl_upgrade.go | 62 ++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index 483884539b8a..7940dff34a4b 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -71,6 +71,24 @@ type ClusterctlUpgradeSpecInput struct { // InitWithKubernetesVersion can be used to override the INIT_WITH_KUBERNETES_VERSION e2e config variable with a specific // Kubernetes version to use to create the secondary management cluster, e.g. `v1.25.0` InitWithKubernetesVersion string + // InitWithCoreProvider can be used to override the INIT_WITH_CORE_PROVIDER e2e config variable with a specific core provider + // version to use when initializing the secondary management cluster, e.g. `cluster-api:v1.3.0` + InitWithCoreProvider string + // InitWithBootstrapProviders can be used to override the INIT_WITH_BOOTSTRAP_PROVIDERS e2e config variable with specific + // bootstrap providers and versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0` + InitWithBootstrapProviders []string + // InitWithControlPlaneProviders can be used to override the INIT_WITH_CONTROL_PLANE_PROVIDERS e2e config variable with specific + // control plane providers and versions to use when initializing the secondary management cluster, e.g. `kubeadm:v1.3.0` + InitWithControlPlaneProviders []string + // InitWithInfrastructureProviders can be used to override the INIT_WITH_INFRASTRUCTURE_PROVIDERS e2e config variable with specific + // infrastructure providers and versions to add to the secondary management cluster, e.g. `aws:v2.0.0` + InitWithInfrastructureProviders []string + // InitWithIPAMProviders can be used to override the INIT_WITH_IPAM_PROVIDERS e2e config variable with specific + // IPAM providers and versions to add to the secondary management cluster, e.g. `infoblox:v0.0.1` + InitWithIPAMProviders []string + // InitWithRuntimeExtensionProviders can be used to override the INIT_WITH_RUNTIME_EXTENSION_PROVIDERS e2e config variable with specific + // runtime extension providers and versions to add to the secondary management cluster, e.g. `test:v0.0.1` + InitWithRuntimeExtensionProviders []string // UpgradeClusterctlVariables can be used to set additional variables for clusterctl upgrade. UpgradeClusterctlVariables map[string]string SkipCleanup bool @@ -255,16 +273,48 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg input.PreInit(managementClusterProxy) } + var ( + coreProvider string + bootstrapProviders []string + controlPlaneProviders []string + infrastructureProviders []string + ipamProviders []string + runtimeExtensionProviders []string + ) + + coreProvider = input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName)[0] + if input.InitWithCoreProvider != "" { + coreProvider = input.InitWithCoreProvider + } + + getValueOrFallback := func(value []string, fallback []string) []string { + if len(value) > 0 { + return value + } + return fallback + } + + bootstrapProviders = getValueOrFallback(input.InitWithBootstrapProviders, + input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmBootstrapProviderName)) + controlPlaneProviders = getValueOrFallback(input.InitWithControlPlaneProviders, + input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmControlPlaneProviderName)) + infrastructureProviders = getValueOrFallback(input.InitWithInfrastructureProviders, + input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.InfrastructureProviders()...)) + ipamProviders = getValueOrFallback(input.IPAMProviders, + input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.IPAMProviders()...)) + runtimeExtensionProviders = getValueOrFallback(input.RuntimeExtensionProviders, + input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.RuntimeExtensionProviders()...)) + clusterctl.InitManagementClusterAndWatchControllerLogs(ctx, clusterctl.InitManagementClusterAndWatchControllerLogsInput{ ClusterctlBinaryPath: clusterctlBinaryPath, // use older version of clusterctl to init the management cluster ClusterProxy: managementClusterProxy, ClusterctlConfigPath: clusterctlConfigPath, - CoreProvider: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName)[0], - BootstrapProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmBootstrapProviderName), - ControlPlaneProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.KubeadmControlPlaneProviderName), - InfrastructureProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.InfrastructureProviders()...), - IPAMProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.IPAMProviders()...), - RuntimeExtensionProviders: input.E2EConfig.GetProviderLatestVersionsByContract(initContract, input.E2EConfig.RuntimeExtensionProviders()...), + CoreProvider: coreProvider, + BootstrapProviders: bootstrapProviders, + ControlPlaneProviders: controlPlaneProviders, + InfrastructureProviders: infrastructureProviders, + IPAMProviders: ipamProviders, + RuntimeExtensionProviders: runtimeExtensionProviders, LogFolder: filepath.Join(input.ArtifactFolder, "clusters", cluster.Name), }, input.E2EConfig.GetIntervals(specName, "wait-controllers")...)