@@ -10467,5 +10467,116 @@ def test_update_http_proxy_config(self):
1046710467 )
1046810468 self .assertEqual (dec_mc_1 , ground_truth_mc_1 )
1046910469
10470+ def test_setup_supportPlan (self ):
10471+ # default value in `aks_create`
10472+ ltsDecorator = AKSManagedClusterCreateDecorator (
10473+ self .cmd ,
10474+ self .client ,
10475+ {
10476+ "k8s_support_plan" : "AKSLongTermSupport"
10477+ },
10478+ ResourceType .MGMT_CONTAINERSERVICE ,
10479+ )
10480+
10481+ premiumSKU = self .models .ManagedClusterSKU (
10482+ name = "Base" ,
10483+ tier = "Premium" )
10484+ premiumCluster = self .models .ManagedCluster (
10485+ location = "test_location" ,
10486+ support_plan = None ,
10487+ sku = premiumSKU ,
10488+ )
10489+ ltsDecorator .context .attach_mc (premiumCluster )
10490+
10491+ # fail on passing the wrong mc object
10492+ with self .assertRaises (CLIInternalError ):
10493+ ltsDecorator .set_up_k8s_support_plan (None )
10494+
10495+ ltsClusterCalculated = ltsDecorator .set_up_k8s_support_plan (premiumCluster )
10496+ expectedLTSCluster = self .models .ManagedCluster (
10497+ location = "test_location" ,
10498+ support_plan = "AKSLongTermSupport" ,
10499+ sku = premiumSKU ,
10500+ )
10501+ self .assertEqual (ltsClusterCalculated , expectedLTSCluster )
10502+
10503+ nonLTSDecorator = AKSManagedClusterCreateDecorator (
10504+ self .cmd ,
10505+ self .client ,
10506+ {
10507+ "k8s_support_plan" : "KubernetesOfficial"
10508+ },
10509+ ResourceType .MGMT_CONTAINERSERVICE ,
10510+ )
10511+ nonLTSDecorator .context .attach_mc (premiumCluster )
10512+ nonLTSClusterCalculated = nonLTSDecorator .set_up_k8s_support_plan (premiumCluster )
10513+ expectedNonLTSCluster = self .models .ManagedCluster (
10514+ location = "test_location" ,
10515+ support_plan = "KubernetesOfficial" ,
10516+ sku = premiumSKU ,
10517+ )
10518+ self .assertEqual (nonLTSClusterCalculated , expectedNonLTSCluster )
10519+
10520+ def test_update_supportPlan (self ):
10521+ # default value in `aks_create`
10522+ noopDecorator = AKSManagedClusterUpdateDecorator (
10523+ self .cmd ,
10524+ self .client ,
10525+ {},
10526+ ResourceType .MGMT_CONTAINERSERVICE ,
10527+ )
10528+
10529+ premiumSKU = self .models .ManagedClusterSKU (
10530+ name = "Base" ,
10531+ tier = "Premium" )
10532+ ltsCluster = self .models .ManagedCluster (
10533+ location = "test_location" ,
10534+ sku = premiumSKU ,
10535+ support_plan = "AKSLongTermSupport" ,
10536+ )
10537+ noopDecorator .context .attach_mc (ltsCluster )
10538+
10539+ # fail on passing the wrong mc object
10540+ with self .assertRaises (CLIInternalError ):
10541+ noopDecorator .update_k8s_support_plan (None )
10542+
10543+ ltsClusterCalculated = noopDecorator .update_k8s_support_plan (ltsCluster )
10544+ self .assertEqual (ltsClusterCalculated , ltsCluster )
10545+
10546+ disableLTSDecorator = AKSManagedClusterUpdateDecorator (
10547+ self .cmd ,
10548+ self .client ,
10549+ {
10550+ "k8s_support_plan" : "KubernetesOfficial"
10551+ },
10552+ ResourceType .MGMT_CONTAINERSERVICE ,
10553+ )
10554+ disableLTSDecorator .context .attach_mc (ltsCluster )
10555+ nonLTSClusterCalculated = disableLTSDecorator .update_k8s_support_plan (ltsCluster )
10556+ expectedNonLTSCluster = self .models .ManagedCluster (
10557+ location = "test_location" ,
10558+ support_plan = "KubernetesOfficial" ,
10559+ sku = premiumSKU ,
10560+ )
10561+ self .assertEqual (nonLTSClusterCalculated , expectedNonLTSCluster )
10562+
10563+ normalCluster = self .models .ManagedCluster (
10564+ location = "test_location" ,
10565+ sku = self .models .ManagedClusterSKU (
10566+ name = "Base" ,
10567+ tier = "Standard" ),
10568+ support_plan = "KubernetesOfficial" ,
10569+ )
10570+ noopDecorator3 = AKSManagedClusterUpdateDecorator (
10571+ self .cmd ,
10572+ self .client ,
10573+ {},
10574+ ResourceType .MGMT_CONTAINERSERVICE ,
10575+ )
10576+ noopDecorator3 .context .attach_mc (normalCluster )
10577+ normalClusterCalculated = noopDecorator3 .update_k8s_support_plan (normalCluster )
10578+ self .assertEqual (normalClusterCalculated , normalCluster )
10579+
10580+
1047010581if __name__ == "__main__" :
1047110582 unittest .main ()
0 commit comments