@@ -30,6 +30,7 @@ import (
3030 e2e_namespace "sigs.k8s.io/cluster-api-provider-azure/test/e2e/kubernetes/namespace"
3131 clusterctl "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
3232 capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
33+ "sigs.k8s.io/cluster-api/test/framework"
3334 "sigs.k8s.io/cluster-api/util"
3435)
3536
@@ -257,5 +258,54 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
257258 }
258259 })
259260 })
261+
262+ Context ("upgrade from v1alpha4 to v1beta1, and scale workload clusters created in v1alpha4" , func () {
263+ BeforeEach (func () {
264+ // Unset resource group and vnet env variables, since we capi test creates 2 clusters,
265+ // and will result in both the clusters using the same vnet and resource group.
266+ Expect (os .Unsetenv (AzureResourceGroup )).To (Succeed ())
267+ Expect (os .Unsetenv (AzureVNetName )).To (Succeed ())
268+
269+ // Unset windows specific variables
270+ Expect (os .Unsetenv ("WINDOWS_WORKER_MACHINE_COUNT" )).To (Succeed ())
271+ Expect (os .Unsetenv ("K8S_FEATURE_GATES" )).To (Succeed ())
272+ })
273+ capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
274+ return capi_e2e.ClusterctlUpgradeSpecInput {
275+ E2EConfig : e2eConfig ,
276+ ClusterctlConfigPath : clusterctlConfigPath ,
277+ BootstrapClusterProxy : bootstrapClusterProxy ,
278+ ArtifactFolder : artifactFolder ,
279+ SkipCleanup : skipCleanup ,
280+ InitWithProvidersContract : "v1alpha4" ,
281+ InitWithBinary : "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/clusterctl-{OS}-{ARCH}" ,
282+ PreInit : getPreInitFunc (ctx ),
283+ }
284+ })
285+ })
260286 }
261287})
288+
289+ func getPreInitFunc (ctx context.Context ) func (proxy framework.ClusterProxy ) {
290+ return func (clusterProxy framework.ClusterProxy ) {
291+ spClientSecret := os .Getenv (AzureClientSecret )
292+ secret := & corev1.Secret {
293+ ObjectMeta : metav1.ObjectMeta {
294+ Name : IdentitySecretName ,
295+ Namespace : "default" ,
296+ Labels : map [string ]string {
297+ clusterctl .ClusterctlMoveHierarchyLabelName : "true" ,
298+ },
299+ },
300+ Type : corev1 .SecretTypeOpaque ,
301+ Data : map [string ][]byte {"clientSecret" : []byte (spClientSecret )},
302+ }
303+ err := clusterProxy .GetClient ().Create (ctx , secret )
304+ Expect (err ).ToNot (HaveOccurred ())
305+
306+ identityName := e2eConfig .GetVariable (ClusterIdentityName )
307+ Expect (os .Setenv (ClusterIdentityName , identityName )).NotTo (HaveOccurred ())
308+ Expect (os .Setenv (ClusterIdentitySecretName , IdentitySecretName )).NotTo (HaveOccurred ())
309+ Expect (os .Setenv (ClusterIdentitySecretNamespace , "default" )).NotTo (HaveOccurred ())
310+ }
311+ }
0 commit comments