@@ -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
@@ -230,32 +231,83 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
230231 })
231232
232233 if os .Getenv ("LOCAL_ONLY" ) != "true" {
233- Context ("upgrade from v1alpha3 to v1beta1, and scale workload clusters created in v1alpha3" , func () {
234- BeforeEach (func () {
235- // Unset resource group and vnet env variables, since we capi test creates 2 clusters,
236- // and will result in both the clusters using the same vnet and resource group.
237- Expect (os .Unsetenv (AzureResourceGroup )).To (Succeed ())
238- Expect (os .Unsetenv (AzureVNetName )).To (Succeed ())
239-
240- // Set base64 encoded values for v1alpha3 cluster.
241- Expect (os .Setenv ("AZURE_CLIENT_ID_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv (AzureClientId ))))).To (Succeed ())
242- Expect (os .Setenv ("AZURE_CLIENT_SECRET_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv (AzureClientSecret ))))).To (Succeed ())
243- Expect (os .Setenv ("AZURE_SUBSCRIPTION_ID_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv ("AZURE_SUBSCRIPTION_ID" ))))).To (Succeed ())
244- Expect (os .Setenv ("AZURE_TENANT_ID_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv ("AZURE_TENANT_ID" ))))).To (Succeed ())
245-
246- // Unset windows specific variables
247- Expect (os .Unsetenv ("WINDOWS_WORKER_MACHINE_COUNT" )).To (Succeed ())
248- Expect (os .Unsetenv ("K8S_FEATURE_GATES" )).To (Succeed ())
234+ Context ("API Version Upgrade" , func () {
235+ Context ("upgrade from v1alpha3 to v1beta1, and scale workload clusters created in v1alpha3 " , func () {
236+ BeforeEach (func () {
237+ // Unset resource group and vnet env variables, since we capi test creates 2 clusters,
238+ // and will result in both the clusters using the same vnet and resource group.
239+ Expect (os .Unsetenv (AzureResourceGroup )).To (Succeed ())
240+ Expect (os .Unsetenv (AzureVNetName )).To (Succeed ())
241+
242+ // Set base64 encoded values for v1alpha3 cluster.
243+ Expect (os .Setenv ("AZURE_CLIENT_ID_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv (AzureClientId ))))).To (Succeed ())
244+ Expect (os .Setenv ("AZURE_CLIENT_SECRET_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv (AzureClientSecret ))))).To (Succeed ())
245+ Expect (os .Setenv ("AZURE_SUBSCRIPTION_ID_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv ("AZURE_SUBSCRIPTION_ID" ))))).To (Succeed ())
246+ Expect (os .Setenv ("AZURE_TENANT_ID_B64" , base64 .StdEncoding .EncodeToString ([]byte (os .Getenv ("AZURE_TENANT_ID" ))))).To (Succeed ())
247+
248+ // Unset windows specific variables
249+ Expect (os .Unsetenv ("WINDOWS_WORKER_MACHINE_COUNT" )).To (Succeed ())
250+ Expect (os .Unsetenv ("K8S_FEATURE_GATES" )).To (Succeed ())
251+ })
252+ capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
253+ return capi_e2e.ClusterctlUpgradeSpecInput {
254+ E2EConfig : e2eConfig ,
255+ ClusterctlConfigPath : clusterctlConfigPath ,
256+ BootstrapClusterProxy : bootstrapClusterProxy ,
257+ ArtifactFolder : artifactFolder ,
258+ SkipCleanup : skipCleanup ,
259+ }
260+ })
249261 })
250- capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
251- return capi_e2e.ClusterctlUpgradeSpecInput {
252- E2EConfig : e2eConfig ,
253- ClusterctlConfigPath : clusterctlConfigPath ,
254- BootstrapClusterProxy : bootstrapClusterProxy ,
255- ArtifactFolder : artifactFolder ,
256- SkipCleanup : skipCleanup ,
257- }
262+
263+ Context ("upgrade from v1alpha4 to v1beta1, and scale workload clusters created in v1alpha4" , func () {
264+ BeforeEach (func () {
265+ // Unset resource group and vnet env variables, since we capi test creates 2 clusters,
266+ // and will result in both the clusters using the same vnet and resource group.
267+ Expect (os .Unsetenv (AzureResourceGroup )).To (Succeed ())
268+ Expect (os .Unsetenv (AzureVNetName )).To (Succeed ())
269+
270+ // Unset windows specific variables
271+ Expect (os .Unsetenv ("WINDOWS_WORKER_MACHINE_COUNT" )).To (Succeed ())
272+ Expect (os .Unsetenv ("K8S_FEATURE_GATES" )).To (Succeed ())
273+ })
274+ capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
275+ return capi_e2e.ClusterctlUpgradeSpecInput {
276+ E2EConfig : e2eConfig ,
277+ ClusterctlConfigPath : clusterctlConfigPath ,
278+ BootstrapClusterProxy : bootstrapClusterProxy ,
279+ ArtifactFolder : artifactFolder ,
280+ SkipCleanup : skipCleanup ,
281+ InitWithProvidersContract : "v1alpha4" ,
282+ InitWithBinary : "https://github.com/kubernetes-sigs/cluster-api/releases/download/v0.4.4/clusterctl-{OS}-{ARCH}" ,
283+ PreInit : getPreInitFunc (ctx ),
284+ }
285+ })
258286 })
259287 })
260288 }
261289})
290+
291+ func getPreInitFunc (ctx context.Context ) func (proxy framework.ClusterProxy ) {
292+ return func (clusterProxy framework.ClusterProxy ) {
293+ spClientSecret := os .Getenv (AzureClientSecret )
294+ secret := & corev1.Secret {
295+ ObjectMeta : metav1.ObjectMeta {
296+ Name : IdentitySecretName ,
297+ Namespace : "default" ,
298+ Labels : map [string ]string {
299+ clusterctl .ClusterctlMoveHierarchyLabelName : "true" ,
300+ },
301+ },
302+ Type : corev1 .SecretTypeOpaque ,
303+ Data : map [string ][]byte {"clientSecret" : []byte (spClientSecret )},
304+ }
305+ err := clusterProxy .GetClient ().Create (ctx , secret )
306+ Expect (err ).ToNot (HaveOccurred ())
307+
308+ identityName := e2eConfig .GetVariable (ClusterIdentityName )
309+ Expect (os .Setenv (ClusterIdentityName , identityName )).NotTo (HaveOccurred ())
310+ Expect (os .Setenv (ClusterIdentitySecretName , IdentitySecretName )).NotTo (HaveOccurred ())
311+ Expect (os .Setenv (ClusterIdentitySecretNamespace , "default" )).NotTo (HaveOccurred ())
312+ }
313+ }
0 commit comments