Skip to content

{ACR} Update ACR test suite: remove unnecessary @live_only decorators and make time.sleep conditional on live mode#33135

Open
CodeJourneys wants to merge 10 commits intoAzure:devfrom
CodeJourneys:acr-module-check-health-bug-fix-mar2026
Open

{ACR} Update ACR test suite: remove unnecessary @live_only decorators and make time.sleep conditional on live mode#33135
CodeJourneys wants to merge 10 commits intoAzure:devfrom
CodeJourneys:acr-module-check-health-bug-fix-mar2026

Conversation

@CodeJourneys
Copy link
Copy Markdown
Contributor

Related command
az acr (various test scenarios)

Description
Test refactoring to the ACR command test suite:

  • Removed @live_only() decorators from test_acr_create_with_managed_registry and test_acr_connectedregistry_dedicated_endpoint_not_enabled so those tests can run in VCR playback.
  • Kept @live_only() with explanatory comments where confirmed required
  • Made all time.sleep() calls in test_acr_encryption_with_cmk conditional on self.is_live to avoid unnecessary delays during playback.
  • Fixed command ordering in test_acr_with_zone_redundancy: moved acr replication show on the home region after replications are created, so the check matches current API source.
  • Cleaned up unused imports in test_acr_agentpool_commands.py and test_acr_connectedregistry_commands.py.
  • Updated all affected test recordings.

This checklist is used to make sure that common guidelines for a pull request are followed.

@CodeJourneys CodeJourneys requested a review from NoriZC as a code owner April 4, 2026 00:08
Copilot AI review requested due to automatic review settings April 4, 2026 00:08
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 4, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 4, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@CodeJourneys CodeJourneys changed the title {ACR} Update ACR test suite: remove unnecessary @live_only decorators and make time.sleep conditional on live mode {ACR} update ACR test suite Apr 4, 2026
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 4, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@CodeJourneys CodeJourneys changed the title {ACR} update ACR test suite {ACR} Update ACR test suite: remove unnecessary @live_only decorators and make time.sleep conditional on live mode Apr 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 primarily refactors the ACR command module test suite to enable more VCR playback coverage and reduce unnecessary delays, alongside updated VCR recordings. It also includes a production-code change in acr/check_health.py affecting CMK validation logic.

Changes:

  • Removed or adjusted @live_only() usage so more ACR scenario tests can run in VCR playback.
  • Made time.sleep() calls conditional on self.is_live to avoid slowing down playback runs; fixed command ordering in a zone-redundancy test.
  • Updated multiple ACR test recordings to match the new execution paths and CLI/SDK versions.

Reviewed changes

Copilot reviewed 18 out of 42 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_task_commands.py Removes live_only usage for task tests; import list changed.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_connectedregistry_commands.py Removes live_only usage for a connected registry test; import list changed.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands.py Keeps live_only where required; gates sleeps on live runs; reorders a replication check.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_agentpool_commands.py Cleans up and simplifies imports for agentpool tests.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/recordings/*.yaml Refreshes VCR recordings to align with updated tests and CLI/SDK behavior.
src/azure-cli/azure/cli/command_modules/acr/check_health.py Removes API-version gating around CMK validation (runtime behavior change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +353 to +354
if registry and registry.encryption and registry.encryption.key_vault_properties: # pylint: disable=too-many-nested-blocks
client_id = registry.encryption.key_vault_properties.identity
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Removing the cmd.supported_api_version(... MGMT_CONTAINERREGISTRY ...) guard changes runtime behavior and can cause an AttributeError on clouds/profiles using older Container Registry API versions where the returned Registry model may not have an encryption attribute. Please either restore the API-version gate (as before) or switch these accesses to getattr(registry, 'encryption', None) / getattr(..., 'key_vault_properties', None) so az acr check-health remains compatible across profiles.

Suggested change
if registry and registry.encryption and registry.encryption.key_vault_properties: # pylint: disable=too-many-nested-blocks
client_id = registry.encryption.key_vault_properties.identity
encryption = getattr(registry, 'encryption', None) if registry else None
key_vault_properties = getattr(encryption, 'key_vault_properties', None)
if key_vault_properties: # pylint: disable=too-many-nested-blocks
client_id = key_vault_properties.identity

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed by #33117

Comment on lines +352 to +353
# CMK settings
if registry and registry.encryption and registry.encryption.key_vault_properties: # pylint: disable=too-many-nested-blocks
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

This change also makes from azure.cli.core.profiles import ResourceType (near the top of _check_registry_health) unused, since ResourceType was only referenced by the removed cmd.supported_api_version(...) call. Please remove that import (or reintroduce the version check) to avoid unused-import lint failures.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Comment on lines +352 to +369
# CMK settings
if registry and registry.encryption and registry.encryption.key_vault_properties: # pylint: disable=too-many-nested-blocks
client_id = registry.encryption.key_vault_properties.identity
valid_identity = False
if registry.identity:
valid_identity = ((client_id == 'system') and
bool(registry.identity.principal_id)) # use system identity?
if not valid_identity and registry.identity.user_assigned_identities:
for k, v in registry.identity.user_assigned_identities.items():
if v.client_id == client_id:
from azure.core.exceptions import HttpResponseError
try:
valid_identity = resolve_identity_client_id(cmd.cli_ctx, k) == client_id
except HttpResponseError:
pass
if not valid_identity:
from ._errors import CMK_MANAGED_IDENTITY_ERROR
_handle_error(CMK_MANAGED_IDENTITY_ERROR.format_error_message(registry_name), ignore_errors)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The PR title/description focus on ACR test refactoring, but this hunk changes production behavior in acr/check_health.py (CMK validation now runs unconditionally and the API-version gate is removed). Please update the PR description to explicitly call out this functional change (or move it into a separate PR) so reviewers can assess the runtime impact appropriately.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That modification should be addressed by #33117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants