Skip to content

Commit 4481651

Browse files
Suyash ChoudharyCopilot
andcommitted
test(storagemover): skip cross-sub sync tests on mindependency leg
Build 6327088 showed test_job_definition_job_run and test_start_c2c_job_with_private_source still failing on the mindependency leg with 'msrestazure.azure_exceptions.CloudError: InvalidAuthenticationToken'. Root cause: the floor-pinned azure-mgmt-storage (v2019_06_01) uses msrestazure transport which bypasses azure-core's RequestsTransport, and therefore the test-proxy, hitting live ARM instead of replaying the cassette. Detect the modernization line via the presence of the .aio submodule on azure-mgmt-storage/-network plus the v2022_04_01 namespace on azure-mgmt-authorization, and gate both cross-sub sync tests behind a pytest.mark.skipif that triggers when those signals are absent. The matrix-#11/#12/#13 schedule tests in the same file (which do not use cross-sub clients) are unaffected and continue to run in mindependency. The cross-sub imports themselves are now wrapped in try/except so the module collects cleanly when those packages are too old to even provide the symbols (otherwise mindependency would fail on the from-import line before the skipif could fire). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent e2b8e7b commit 4481651

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

sdk/storagemover/azure-mgmt-storagemover/tests/test_storage_mover_mgmt_job_definitions_operations_test.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,42 @@
1818

1919
import pytest
2020
from azure.core.exceptions import HttpResponseError
21-
from azure.mgmt.authorization.v2022_04_01 import AuthorizationManagementClient
22-
from azure.mgmt.network import NetworkManagementClient
23-
from azure.mgmt.storage import StorageManagementClient
2421
from azure.mgmt.storagemover import StorageMoverMgmtClient
2522

2623
from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy
2724

25+
# Detect whether the cross-sub mgmt clients are "modern enough" to flow through
26+
# azure-core's RequestsTransport (which the test-proxy intercepts). The pre-20.0
27+
# generations of azure-mgmt-storage / azure-mgmt-network / azure-mgmt-authorization
28+
# use msrestazure's transport, bypass the proxy, and hit live ARM. The presence
29+
# of the `.aio` submodule + the `v2022_04_01` authorization API version is a
30+
# reliable signal of "post-modernization".
31+
# The `mindependency` CI leg pins those packages to very old floors that lack
32+
# these — skip the two cross-sub tests cleanly in that environment.
33+
try:
34+
from azure.mgmt.authorization.v2022_04_01 import AuthorizationManagementClient
35+
from azure.mgmt.network import NetworkManagementClient
36+
from azure.mgmt.storage import StorageManagementClient
37+
import azure.mgmt.network.aio # noqa: F401 (modernization signal)
38+
import azure.mgmt.storage.aio # noqa: F401 (modernization signal)
39+
_CROSS_SUB_CLIENTS_MODERN = True
40+
except ImportError:
41+
AuthorizationManagementClient = None # type: ignore[assignment]
42+
NetworkManagementClient = None # type: ignore[assignment]
43+
StorageManagementClient = None # type: ignore[assignment]
44+
_CROSS_SUB_CLIENTS_MODERN = False
45+
46+
_SKIP_IF_CROSS_SUB_CLIENTS_OLD = pytest.mark.skipif(
47+
not _CROSS_SUB_CLIENTS_MODERN,
48+
reason=(
49+
"Cross-sub mgmt clients too old: pre-modernization versions of "
50+
"azure-mgmt-{storage,network,authorization} use msrestazure transport "
51+
"and bypass the test-proxy, hitting live ARM. Bump those packages to "
52+
"their post-azure-core releases (storage>=20, network>=19, authorization>=2) "
53+
"to enable this test."
54+
),
55+
)
56+
2857
AZURE_LOCATION = "eastus"
2958
# Matrix row #31 runs in westcentralus because the shared PLS + storage account
3059
# live there. Other tests in this file keep the default eastus location.
@@ -125,6 +154,7 @@ def _provision_parents(self, rg, sm_name, project_name, source_endpoint, target_
125154
# Connection / PrivateLinkService approval — the public bucket is reachable
126155
# via the MCC directly.
127156

157+
@_SKIP_IF_CROSS_SUB_CLIENTS_OLD
128158
@RandomNameResourceGroupPreparer(location=WCUS_LOCATION)
129159
@recorded_by_proxy
130160
def test_job_definition_job_run(self, resource_group, **kwargs):
@@ -489,6 +519,7 @@ def test_create_with_onetime_schedule(self, resource_group, **kwargs):
489519
# See the "Porter's reference" callout in the cross-language playbook
490520
# (storage-mover-scenario-tests-cross-language) for the canonical step-by-step.
491521

522+
@_SKIP_IF_CROSS_SUB_CLIENTS_OLD
492523
@RandomNameResourceGroupPreparer(location=WCUS_LOCATION)
493524
@recorded_by_proxy
494525
def test_start_c2c_job_with_private_source(self, resource_group, **kwargs):

0 commit comments

Comments
 (0)