@@ -30,6 +30,7 @@ import (
3030 . "github.com/onsi/ginkgo/v2"
3131 . "github.com/onsi/gomega"
3232 "k8s.io/utils/ptr"
33+ clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3334 capi_e2e "sigs.k8s.io/cluster-api/test/e2e"
3435 "sigs.k8s.io/cluster-api/test/framework"
3536 "sigs.k8s.io/cluster-api/test/framework/clusterctl"
@@ -181,6 +182,8 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
181182
182183 if os .Getenv ("USE_LOCAL_KIND_REGISTRY" ) != "true" {
183184 Context ("API Version Upgrade" , func () {
185+ var aksKubernetesVersion string
186+
184187 BeforeEach (func () {
185188 // Unset resource group and vnet env variables, since the upgrade test creates 2 clusters,
186189 // and will result in both the clusters using the same vnet and resource group.
@@ -199,6 +202,9 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
199202 identity , err := identityClient .Get (ctx , identityRG , identityName , nil )
200203 Expect (err ).NotTo (HaveOccurred ())
201204 Expect (os .Setenv ("AZURE_CLIENT_ID_CLOUD_PROVIDER" , * identity .Properties .ClientID )).To (Succeed ())
205+
206+ aksKubernetesVersion , err = GetAKSKubernetesVersion (ctx , e2eConfig , AKSKubernetesVersion )
207+ Expect (err ).NotTo (HaveOccurred ())
202208 })
203209
204210 Context ("upgrade from an old version of v1beta1 to current, and scale workload clusters created in the old version" , func () {
@@ -250,6 +256,82 @@ var _ = Describe("Running the Cluster API E2E tests", func() {
250256 }
251257 })
252258 })
259+
260+ Context ("upgrade from an old version of v1beta1 to current, and scale AKS workload clusters created in the old version" , func () {
261+ capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
262+ return capi_e2e.ClusterctlUpgradeSpecInput {
263+ E2EConfig : e2eConfig ,
264+ ClusterctlConfigPath : clusterctlConfigPath ,
265+ WorkloadFlavor : "aks" ,
266+ WorkloadKubernetesVersion : aksKubernetesVersion ,
267+ ControlPlaneMachineCount : ptr.To [int64 ](0 ),
268+ BootstrapClusterProxy : bootstrapClusterProxy ,
269+ ArtifactFolder : artifactFolder ,
270+ SkipCleanup : skipCleanup ,
271+ PreInit : getPreInitFunc (ctx ),
272+ InitWithProvidersContract : "v1beta1" ,
273+ ControlPlaneWaiters : clusterctl.ControlPlaneWaiters {
274+ WaitForControlPlaneInitialized : EnsureControlPlaneInitialized ,
275+ },
276+ InitWithKubernetesVersion : e2eConfig .MustGetVariable (KubernetesVersionAPIUpgradeFrom ),
277+ InitWithBinary : fmt .Sprintf ("https://github.com/kubernetes-sigs/cluster-api/releases/download/%s/clusterctl-{OS}-{ARCH}" , e2eConfig .MustGetVariable (OldCAPIUpgradeVersion )),
278+ InitWithCoreProvider : "cluster-api:" + e2eConfig .MustGetVariable (OldCAPIUpgradeVersion ),
279+ InitWithInfrastructureProviders : []string {"azure:" + e2eConfig .MustGetVariable (OldProviderUpgradeVersion )},
280+ Upgrades : []capi_e2e.ClusterctlUpgradeSpecInputUpgrade {
281+ {
282+ Contract : clusterv1 .GroupVersion .Version ,
283+ PostUpgrade : func (managementClusterProxy framework.ClusterProxy , clusterNamespace , clusterName string ) {
284+ AKSMachinePoolPostUpgradeSpec (ctx , func () AKSMachinePoolPostUpgradeSpecInput {
285+ return AKSMachinePoolPostUpgradeSpecInput {
286+ MgmtCluster : managementClusterProxy ,
287+ ClusterName : clusterName ,
288+ ClusterNamespace : clusterNamespace ,
289+ }
290+ })
291+ },
292+ },
293+ },
294+ }
295+ })
296+ })
297+
298+ Context ("upgrade from the latest version of v1beta1 to current, and scale AKS workload clusters created in the old version" , func () {
299+ capi_e2e .ClusterctlUpgradeSpec (ctx , func () capi_e2e.ClusterctlUpgradeSpecInput {
300+ return capi_e2e.ClusterctlUpgradeSpecInput {
301+ E2EConfig : e2eConfig ,
302+ ClusterctlConfigPath : clusterctlConfigPath ,
303+ WorkloadFlavor : "aks" ,
304+ WorkloadKubernetesVersion : aksKubernetesVersion ,
305+ ControlPlaneMachineCount : ptr.To [int64 ](0 ),
306+ BootstrapClusterProxy : bootstrapClusterProxy ,
307+ ArtifactFolder : artifactFolder ,
308+ SkipCleanup : skipCleanup ,
309+ PreInit : getPreInitFunc (ctx ),
310+ InitWithProvidersContract : "v1beta1" ,
311+ ControlPlaneWaiters : clusterctl.ControlPlaneWaiters {
312+ WaitForControlPlaneInitialized : EnsureControlPlaneInitialized ,
313+ },
314+ InitWithKubernetesVersion : e2eConfig .MustGetVariable (KubernetesVersionAPIUpgradeFrom ),
315+ InitWithBinary : fmt .Sprintf ("https://github.com/kubernetes-sigs/cluster-api/releases/download/%s/clusterctl-{OS}-{ARCH}" , e2eConfig .MustGetVariable (LatestCAPIUpgradeVersion )),
316+ InitWithCoreProvider : "cluster-api:" + e2eConfig .MustGetVariable (LatestCAPIUpgradeVersion ),
317+ InitWithInfrastructureProviders : []string {"azure:" + e2eConfig .MustGetVariable (LatestProviderUpgradeVersion )},
318+ Upgrades : []capi_e2e.ClusterctlUpgradeSpecInputUpgrade {
319+ {
320+ Contract : clusterv1 .GroupVersion .Version ,
321+ PostUpgrade : func (managementClusterProxy framework.ClusterProxy , clusterNamespace , clusterName string ) {
322+ AKSMachinePoolPostUpgradeSpec (ctx , func () AKSMachinePoolPostUpgradeSpecInput {
323+ return AKSMachinePoolPostUpgradeSpecInput {
324+ MgmtCluster : managementClusterProxy ,
325+ ClusterName : clusterName ,
326+ ClusterNamespace : clusterNamespace ,
327+ }
328+ })
329+ },
330+ },
331+ },
332+ }
333+ })
334+ })
253335 })
254336 }
255337
0 commit comments