Skip to content

Commit

Permalink
WIP: e2e: add init versions for providers
Browse files Browse the repository at this point in the history
  • Loading branch information
lentzi90 committed Nov 25, 2022
1 parent 6c65434 commit 4cba044
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 6 deletions.
59 changes: 53 additions & 6 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -255,16 +273,45 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
input.PreInit(managementClusterProxy)
}

var (
coreProvider string
bootstrapProviders []string
controlPlaneProviders []string
infrastructureProviders []string
ipamProviders []string
runtimeExtensionProviders []string
)

getValueOrFallback := func(value []string, fallback []string) []string {
if len(value) > 0 {
return value
}
return fallback
}

coreProvider = getValueOrFallback([]string{input.InitWithCoreProvider},
input.E2EConfig.GetProviderLatestVersionsByContract(initContract, config.ClusterAPIProviderName))[0]
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")...)

Expand Down
16 changes: 16 additions & 0 deletions test/e2e/clusterctl_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,19 @@ var _ = Describe("When testing clusterctl upgrades using ClusterClass (v1.2=>cur
}
})
})

var _ = Describe("When testing clusterctl upgrades with init versions (v1.2=>current)", func() {
ClusterctlUpgradeSpec(ctx, func() ClusterctlUpgradeSpecInput {
return ClusterctlUpgradeSpecInput{
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
SkipCleanup: skipCleanup,
InitWithBinary: "https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.2.5/clusterctl-{OS}-{ARCH}",
InitWithProvidersContract: "v1beta1",
InitWithKubernetesVersion: "v1.25.0",
InitWithInfrastructureProviders: []string{"docker:v1.2.6"},
}
})
})

0 comments on commit 4cba044

Please sign in to comment.