Skip to content

[AKS] Fix aks-preview tests with latest CLI - #10179

Merged
Julie Zhu (yanzhudd) merged 2 commits into
Azure:mainfrom
FumingZhang:fix/aks-preview-autoscaler-tests
Aug 4, 2026
Merged

[AKS] Fix aks-preview tests with latest CLI#10179
Julie Zhu (yanzhudd) merged 2 commits into
Azure:mainfrom
FumingZhang:fix/aks-preview-autoscaler-tests

Conversation

@FumingZhang

@FumingZhang FumingZhang commented Aug 4, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes
️✔️ None

Summary

  • Avoid applying VirtualMachines autoscaler profile conversions twice when the base Azure CLI update flow already handles them.
  • Preserve compatibility with older CLI versions that do not yet provide the base VMS autoscaler flow.
  • Refresh the outbound public IP recording for Network API version 2025-07-01.
  • Document the fix under the pending aks-preview release notes.

Related command

az aks nodepool update --enable-cluster-autoscaler

az aks nodepool update --disable-cluster-autoscaler

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install azdev required)
  • My extension version conforms to the Extension version schema

For new extensions:

  • Not applicable; aks-preview is an existing extension.

Validation

  • azdev test azext_aks_preview: 1157 passed, 117 skipped, 6 subtests passed
  • azdev style aks-preview: pylint and flake8 passed
  • python scripts/ci/test_index.py -q: 9 tests passed, 2 skipped

About Extension Publish

This is a non-release change. HISTORY.rst is updated under Pending, and the extension version remains 21.0.0b13.

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.
Copilot AI lite review requested due to automatic review settings August 4, 2026 03:26
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi FumingZhang,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_vms in update_agentpool_profile_preview when the base Azure CLI update flow already provides that functionality (to avoid double conversion).
  • Update/adjust unit test expectations around update_auto_scaler_properties_vms and refresh a test recording to use Network API version 2025-07-01.
  • Document the behavior change in aks-preview pending 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.
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@yanzhudd
Julie Zhu (yanzhudd) merged commit ff85fab into Azure:main Aug 4, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants