[AKS] Fix aks-preview tests with latest CLI - #10179
Conversation
Avoid applying VirtualMachines autoscaler conversions twice when the base CLI already handles them, while retaining compatibility with older CLI versions. Refresh the outbound IP recording for the current Network API version.
|
Hi FumingZhang, |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR updates the aks-preview extension to stay compatible with newer Azure CLI behavior around VirtualMachines (VMS) autoscaler/profile updates, and refreshes a recorded network interaction to align with a newer Network API version.
Changes:
- Skip calling
update_auto_scaler_properties_vmsinupdate_agentpool_profile_previewwhen the base Azure CLI update flow already provides that functionality (to avoid double conversion). - Update/adjust unit test expectations around
update_auto_scaler_properties_vmsand refresh a test recording to use Network API version2025-07-01. - Document the behavior change in
aks-previewpending release notes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/aks-preview/azext_aks_preview/agentpool_decorator.py | Adds a compatibility gate to avoid applying VMS autoscaler conversions twice on newer CLI versions. |
| src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py | Updates unit tests to reflect the new call behavior for update_auto_scaler_properties_vms. |
| src/aks-preview/azext_aks_preview/tests/latest/recordings/test_aks_create_and_update_outbound_ips.yaml | Refreshes recordings to use Network api-version=2025-07-01 for Public IP operations. |
| src/aks-preview/HISTORY.rst | Notes the fix under the pending release notes. |
Suppressed comments (4)
src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py:406
- This assertion assumes update_auto_scaler_properties_vms is never invoked, but update_agentpool_profile_preview intentionally calls it on older CLI versions (when the base decorator doesn’t provide that flow). To keep the test stable across CLI versions and to cover the compatibility branch, assert conditionally based on the base class capability.
decorator.update_vm_size.assert_called_once_with(agentpool)
decorator.update_localdns_profile.assert_called_once_with(agentpool)
decorator.update_auto_scaler_properties_vms.assert_not_called()
decorator.update_upgrade_strategy.assert_called_once_with(agentpool)
src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py:488
- The expected call order and the final assert currently assume update_auto_scaler_properties_vms is never called. That makes this test brittle across Azure CLI versions and prevents validating the older-CLI compatibility branch where the method should appear between update_localdns_profile and update_upgrade_strategy.
self.assertEqual(call_order, expected_order)
decorator.update_auto_scaler_properties_vms.assert_not_called()
src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py:608
- The mock setup for mixed modes currently excludes update_auto_scaler_properties_vms from the update_methods list and then always asserts it was not called. This prevents validating the intended backward-compat behavior where System-mode should call update_auto_scaler_properties_vms when the base Azure CLI decorator lacks that method. Set up update_methods and mocks conditionally so the test is stable across CLI versions.
update_methods = [
'update_network_profile', 'update_artifact_streaming', 'update_managed_gpu',
'update_secure_boot', 'update_vtpm', 'update_os_sku', 'update_fips_image',
'update_ssh_access', 'update_vm_size', 'update_localdns_profile',
'update_upgrade_strategy', 'update_blue_green_upgrade_settings', 'update_gpu_profile',
'update_gpu_mig_strategy', 'update_crg', 'update_prepared_image_specification'
]
for method_name in update_methods:
setattr(decorator, method_name, Mock(return_value=agentpool))
decorator.update_auto_scaler_properties_vms = Mock(return_value=agentpool)
src/aks-preview/azext_aks_preview/tests/latest/test_update_agentpool_profile_preview.py:621
- The unconditional assert_not_called here will fail on older CLI versions where System mode should call update_auto_scaler_properties_vms (because the base decorator lacks that flow). Use the should_call_vms flag from the setup to assert the correct behavior for both CLI variants and for ManagedSystem mode.
decorator.update_auto_scaler_properties_vms.assert_not_called()
Condition VMS autoscaler call and ordering assertions on whether the installed base Azure CLI decorator already handles the update.
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
🤖 PR Validation — ️✔️ All clear
Summary
2025-07-01.aks-previewrelease notes.Related command
az aks nodepool update --enable-cluster-autoscaleraz aks nodepool update --disable-cluster-autoscalerGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
aks-previewis an existing extension.Validation
azdev test azext_aks_preview: 1157 passed, 117 skipped, 6 subtests passedazdev style aks-preview: pylint and flake8 passedpython scripts/ci/test_index.py -q: 9 tests passed, 2 skippedAbout Extension Publish
This is a non-release change.
HISTORY.rstis updated underPending, and the extension version remains21.0.0b13.