|
37 | 37 | CONST_KUBE_DASHBOARD_ADDON_NAME, |
38 | 38 | CONST_LOAD_BALANCER_BACKEND_POOL_TYPE_NODE_IP, |
39 | 39 | CONST_LOAD_BALANCER_SKU_STANDARD, |
| 40 | + CONST_LOAD_BALANCER_SKU_BASIC, |
40 | 41 | CONST_MONITORING_ADDON_NAME, |
41 | 42 | CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID, |
42 | 43 | CONST_MONITORING_USING_AAD_MSI_AUTH, |
|
47 | 48 | CONST_ROTATION_POLL_INTERVAL, |
48 | 49 | CONST_SECRET_ROTATION_ENABLED, |
49 | 50 | CONST_VIRTUAL_MACHINE_SCALE_SETS, |
| 51 | + CONST_AVAILABILITY_SET, |
| 52 | + CONST_VIRTUAL_MACHINES, |
50 | 53 | CONST_VIRTUAL_NODE_ADDON_NAME, |
51 | 54 | CONST_VIRTUAL_NODE_SUBNET_NAME, |
52 | 55 | CONST_WORKLOAD_RUNTIME_OCI_CONTAINER, |
|
85 | 88 | MutuallyExclusiveArgumentError, |
86 | 89 | RequiredArgumentMissingError, |
87 | 90 | UnknownError, |
| 91 | + CLIError, |
88 | 92 | ) |
89 | 93 | from azure.cli.command_modules.acs._consts import ( |
90 | 94 | CONST_OUTBOUND_TYPE_LOAD_BALANCER, |
@@ -9078,6 +9082,113 @@ def test_update_acns_in_network_profile(self): |
9078 | 9082 | ), |
9079 | 9083 | ) |
9080 | 9084 | self.assertEqual(dec_mc_1, ground_truth_mc_1) |
| 9085 | + |
| 9086 | + def test_update_vmas_to_vms(self): |
| 9087 | + # Should not update mc if unset |
| 9088 | + dec_0 = AKSPreviewManagedClusterUpdateDecorator( |
| 9089 | + self.cmd, |
| 9090 | + self.client, |
| 9091 | + {}, |
| 9092 | + CUSTOM_MGMT_AKS_PREVIEW, |
| 9093 | + ) |
| 9094 | + mc_0 = self.models.ManagedCluster( |
| 9095 | + location="test_location", |
| 9096 | + ) |
| 9097 | + dec_0.context.attach_mc(mc_0) |
| 9098 | + dec_mc_0 = dec_0.update_vmas_to_vms(mc_0) |
| 9099 | + ground_truth_mc_0 = self.models.ManagedCluster( |
| 9100 | + location="test_location", |
| 9101 | + ) |
| 9102 | + self.assertEqual(dec_mc_0, ground_truth_mc_0) |
| 9103 | + |
| 9104 | + # Should raise error if trying to migrate non-vmas cluster to vms |
| 9105 | + dec_1 = AKSPreviewManagedClusterUpdateDecorator( |
| 9106 | + self.cmd, |
| 9107 | + self.client, |
| 9108 | + { |
| 9109 | + "migrate_vmas_to_vms": True, |
| 9110 | + "yes": True, |
| 9111 | + }, |
| 9112 | + CUSTOM_MGMT_AKS_PREVIEW, |
| 9113 | + ) |
| 9114 | + mc_1 = self.models.ManagedCluster( |
| 9115 | + location="test_location", |
| 9116 | + ) |
| 9117 | + ap_1 = self.models.ManagedClusterAgentPoolProfile( |
| 9118 | + name="test_np_name", |
| 9119 | + type=CONST_VIRTUAL_MACHINE_SCALE_SETS, |
| 9120 | + ) |
| 9121 | + mc_1.agent_pool_profiles = [ap_1] |
| 9122 | + dec_1.context.attach_mc(mc_1) |
| 9123 | + with self.assertRaises(CLIError): |
| 9124 | + dec_1.update_vmas_to_vms(mc_1) |
| 9125 | + |
| 9126 | + # Should raise error if cluster has more than 1 AP |
| 9127 | + dec_2 = AKSPreviewManagedClusterUpdateDecorator( |
| 9128 | + self.cmd, |
| 9129 | + self.client, |
| 9130 | + { |
| 9131 | + "migrate_vmas_to_vms": True, |
| 9132 | + "yes": True, |
| 9133 | + }, |
| 9134 | + CUSTOM_MGMT_AKS_PREVIEW, |
| 9135 | + ) |
| 9136 | + mc_2 = self.models.ManagedCluster( |
| 9137 | + location="test_location", |
| 9138 | + ) |
| 9139 | + ap_2_1 = self.models.ManagedClusterAgentPoolProfile( |
| 9140 | + name="test_np_name_1", |
| 9141 | + type=CONST_AVAILABILITY_SET, |
| 9142 | + ) |
| 9143 | + ap_2_2 = self.models.ManagedClusterAgentPoolProfile( |
| 9144 | + name="test_np_name_2", |
| 9145 | + type=CONST_AVAILABILITY_SET, |
| 9146 | + ) |
| 9147 | + mc_2.agent_pool_profiles = [ap_2_1, ap_2_2] |
| 9148 | + dec_2.context.attach_mc(mc_2) |
| 9149 | + with self.assertRaises(CLIError): |
| 9150 | + dec_2.update_vmas_to_vms(mc_2) |
| 9151 | + |
| 9152 | + # Should migrate vmas-blb to vms-slb |
| 9153 | + dec_3 = AKSPreviewManagedClusterUpdateDecorator( |
| 9154 | + self.cmd, |
| 9155 | + self.client, |
| 9156 | + { |
| 9157 | + "migrate_vmas_to_vms": True, |
| 9158 | + "yes": True, |
| 9159 | + }, |
| 9160 | + CUSTOM_MGMT_AKS_PREVIEW, |
| 9161 | + ) |
| 9162 | + mc_3 = self.models.ManagedCluster( |
| 9163 | + location="test_location", |
| 9164 | + ) |
| 9165 | + ap_3 = self.models.ManagedClusterAgentPoolProfile( |
| 9166 | + name="test_np_name", |
| 9167 | + type=CONST_AVAILABILITY_SET, |
| 9168 | + ) |
| 9169 | + network_profile_3 = self.models.ContainerServiceNetworkProfile( |
| 9170 | + load_balancer_sku=CONST_LOAD_BALANCER_SKU_BASIC, |
| 9171 | + ) |
| 9172 | + mc_3.agent_pool_profiles = [ap_3] |
| 9173 | + mc_3.network_profile = network_profile_3 |
| 9174 | + dec_3.context.attach_mc(mc_3) |
| 9175 | + dec_mc_3 = dec_3.update_vmas_to_vms(mc_3) |
| 9176 | + |
| 9177 | + ground_truth_mc_3 = self.models.ManagedCluster( |
| 9178 | + location="test_location", |
| 9179 | + ) |
| 9180 | + ground_truth_ap_3 = self.models.ManagedClusterAgentPoolProfile( |
| 9181 | + name="test_np_name", |
| 9182 | + type=CONST_VIRTUAL_MACHINES, |
| 9183 | + ) |
| 9184 | + ground_truth_network_profile_3 = self.models.ContainerServiceNetworkProfile( |
| 9185 | + load_balancer_sku=CONST_LOAD_BALANCER_SKU_STANDARD, |
| 9186 | + ) |
| 9187 | + ground_truth_mc_3.agent_pool_profiles = [ground_truth_ap_3] |
| 9188 | + ground_truth_mc_3.network_profile = ground_truth_network_profile_3 |
| 9189 | + self.assertEqual(dec_mc_3, ground_truth_mc_3) |
| 9190 | + |
| 9191 | + |
9081 | 9192 |
|
9082 | 9193 | def test_enable_retina_network_flow_logs(self): |
9083 | 9194 | # Case 1: enable_acns, enable monitoring addons_profile, enable retina_network_flow_logs |
|
0 commit comments