Skip to content

Add PlatformValidation sync/async live and recorded SDK tests - #49303

Open
shivangirana20 wants to merge 7 commits into
mainfrom
tests/platformvalidation-recorded-cloudvalidation
Open

shivangirana20 wants to merge 7 commits into
mainfrom
tests/platformvalidation-recorded-cloudvalidation

Conversation

@shivangirana20

@shivangirana20 shivangirana20 commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Description

Adds handwritten PlatformValidation integration tests using the official
Python SDK testing guide
and management-plane testing guide.

Twenty recorded scenarios exercise all 25 SDK methods in both sync and async clients:

Operation group Methods per client
CloudValidation Create/update, GET, PATCH, DELETE, LIST by RG, LIST by subscription
Validation execution plans Create/update, GET, PATCH, DELETE, LIST
Execution plan runs Create a new run, GET, DELETE, LIST
Validation test runs GET, LIST
Test catalog, versions and categories GET and LIST for each
Operation status GET
Provider operations LIST

Existing-resource PUT is additionally exercised for CloudValidation and execution
plans. Assertions verify identity, persisted metadata/configuration, completed
workload results, ownership and post-delete 404.

The implementation follows the documented workflow:

  1. Install dev_requirements.txt and the editable SDK in a virtual environment.
  2. Use AzureMgmtRecordedTestCase, framework credentials and resource preparers.
  3. Record real sync/async requests with the test proxy decorators.
  4. Provision workload prerequisites through service-created MRGs, without manual
    MRG creation or role assignments; verify child-first cleanup.
  5. Sanitize credentials, image URLs, signed queries and unrelated list metadata;
    verify nested JSON and replay the full included suite.
  6. Publish through manage_recordings.py push, update assets.json, and verify
    playback from a separate checkout with freshly downloaded published assets.

Current validation: package-root playback using CI's collection scope reports
236 passed, 2 failed, 50 skipped. All 218 mocked regressions and 18 non-catalog
recorded scenarios pass. The 50 skips are existing generated placeholders; no
new skips or xfails were introduced. Repository Black and whitespace checks pass.

The two failures are the sync/async catalog scenarios. Catalog tests and categories
are declared @subscriptionResource, and versions inherit their parent's scope in
the official TypeSpec.
Expected IDs now use the framework's configured subscription:
/subscriptions/{subscriptionId}/providers/Microsoft.PlatformValidation/....
The deployed service and existing recordings return /providers/Microsoft.PlatformValidation/...
instead. Strict assertions expose this service/contract mismatch, matching Go and
JavaScript coverage. Focused regressions reject missing or wrong subscription IDs.

Ready for review, not merge-ready: current validation is playback, not a fresh
live run. Recordings and their published tag are unchanged; no responses were
rewritten to satisfy the assertions. After the service is corrected, rerun live
recording, publish refreshed assets, and verify playback/CI. The earlier
235-pass result used provider-global catalog expectations and does not establish
compliance with the subscription-scoped contract.

Published recordings:
20 recordings, 414 HTTP interactions. The package README documents setup,
prerequisites and the end-to-end live/record/playback/publication commands.

Includes a minimal shared test-tool SAS-regex fix: preserve JSON escape
characters while redacting signed queries. Regression cases cover all four SAS
fields across three JSON nesting levels and escaped values.

Test-only changes: no generated SDK code, public APIs, package versions, runtime
dependencies or pipelines changed. A product changelog entry is not applicable.

All SDK Contribution checklist:

  • The pull request does not introduce breaking changes.
  • CHANGELOG is updated for new features, bug fixes or other significant changes. Not applicable: test-only changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each with an informative message; previously merged commits are not included.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f75acd6-b422-40b6-9131-9d233e89dfc4
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
9 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@shivangirana20 shivangirana20 changed the title (AI Generated) Test hardening: test_cloud_validation_lifecycle in TestCloudValidations Test hardening: test_cloud_validation_lifecycle in TestCloudValidations Oct 1, 2026
Shivangi Rana and others added 4 commits October 1, 2026 21:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f75acd6-b422-40b6-9131-9d233e89dfc4
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 6f75acd6-b422-40b6-9131-9d233e89dfc4
Add sync/async catalog, execution, update and result scenarios with service-managed prerequisites and ownership-checked cleanup. Publish sanitized recordings and document the official Python SDK test workflow.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2a042b96-9dc7-4414-9d1e-5bb57db74da4
Fix only the shared test-tool SAS expression and add regression coverage for escaped values at multiple JSON nesting depths. Verified clean-source live recording exposed the dependency.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2a042b96-9dc7-4414-9d1e-5bb57db74da4
@shivangirana20 shivangirana20 changed the title Test hardening: test_cloud_validation_lifecycle in TestCloudValidations Add PlatformValidation sync/async live and recorded SDK tests Oct 27, 2026
@shivangirana20
shivangirana20 marked this pull request as ready for review October 27, 2026 06:15
Copilot AI balanced review requested due to automatic review settings October 27, 2026 06:16

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.

🟡 Changes recommended

Credential exposure through debug logging, unresolved-submission cleanup risks and isolated live-test authentication failures remain unresolved.

3 open issues
What changed in this PR

Adds handwritten live and recorded tests for the PlatformValidation management SDK, covering synchronous and asynchronous clients without changing generated SDK code or public APIs.

Changes:

  • Adds lifecycle, update, catalog, operation-listing and execution-result scenarios.
  • Adds prerequisite provisioning, ownership-aware cleanup, sanitization and mocked regression tests.
  • Documents recording workflows, references published assets and updates shared SAS sanitization to preserve JSON escapes.
File Description
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_update_helpers.py Tests update payloads and safe response observations.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_operations.py Tests provider-operation listings for both clients.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_managed_group_cleanup.py Tests managed-group disappearance checks.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_updates.py Adds synchronous execution-plan update scenarios.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_updates_async.py Adds asynchronous execution-plan update scenarios.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_results.py Validates existing execution results with both clients.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_prerequisite_cleanup.py Tests prerequisite ownership and cleanup safeguards.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_lifecycle.py Adds synchronous plan and workload lifecycles.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_lifecycle_async.py Adds asynchronous plan and workload lifecycles.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_execution_helpers.py Tests configuration, cleanup, timeouts and sanitization.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_cloud_validations.py Adds synchronous CloudValidation lifecycle tests.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_cloud_validations_async.py Adds asynchronous CloudValidation lifecycle tests.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_catalog.py Tests public catalog discovery and identities.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​test_catalog_helpers.py Tests provider-global catalog identity assertions.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​README.md Documents setup, coverage, cleanup and recording workflows.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​conftest.py Configures recording sanitizers and playback fixtures.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​_update_testcase.py Provides update payload and observation helpers.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​_execution_testcase.py Provides shared execution assertions, polling and cleanup.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​_execution_prerequisites.py Provisions and cleans up workload prerequisites.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​_cloud_validation_testcase.py Provides CloudValidation assertions and cleanup helpers.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​dev_requirements.txt Adds the resource-management SDK test dependency.
sdk/​platformvalidation/​azure-mgmt-platformvalidation/​assets.json References published test recordings.
eng/​tools/​azure-sdk-tools/​devtools_testutils/​proxy_startup.py Preserves JSON escapes during shared SAS redaction.

Review effort: Balanced

Comment on lines +213 to +214
assert not list(client.execution_plan_runs.list_by_execution_plan(*args))
complete(client.validation_execution_plans.begin_delete(*args))
Comment on lines +248 to +249
class ExecutionTestCase(CloudValidationTestCase):
def assert_parent(self, parent, group, name, ownership):
Comment on lines +28 to +29
@recorded_by_proxy
def test_list_management_operations(self) -> None:
Move sanitizer configuration into a regular test helper so regression tests do not import an ambiguous conftest module when generated and handwritten tests are collected together. Preserve fixture scope, dependencies, sanitizer rules, and assertions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7a785b66-f182-4517-86a0-2775420a38dd
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:45
@shivangirana20

Copy link
Copy Markdown
Member Author

Fixed the CI test-collection import collision in commit 2952409. Sanitizer configuration now lives in a regular test helper; neither regression test imports conftest.py. Fixture scope/dependencies, sanitizer rules, assertions, recordings, generated SDK code, and CI configuration are unchanged.

Validation used the same package-root collection and ignore flags as CI, covering generated and handwritten tests together. Before: 97 failed, 138 passed, 50 skipped. After: 235 passed, 50 skipped. The 50 skips are the existing generated placeholders; no new skips were added. Black and git diff --check pass. The push triggers fresh CI; these local results do not claim remote CI is green.

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.

🔵 Needs a closer look

Execution clients can leak signed VHD credentials through debug logs, while standalone live operation tests omit the documented authentication variables and may fail or use an unintended identity.

3 open issues

Review effort: Balanced

Derive catalog IDs from the configured subscription and reject missing or wrong scope in focused regressions. Document the two strict catalog playback failures against current service responses; retain published recordings unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 7a785b66-f182-4517-86a0-2775420a38dd
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:55

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.

🔵 Needs a closer look

Execution clients enable HTTP tracing that can expose signed image URI credentials in debug logs before sanitization.

3 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Build catalog test ID from the configured subscription

sdk/​platformvalidation/​azure-mgmt-platformvalidation/​tests/​_execution_testcase.py:288

This assertion still requires a provider-global catalog ID. The official ValidationTestRunProperties.testId contract identifies the catalog resource's ARM ID, and ValidationTest is subscription-scoped, as the new catalog tests correctly enforce. A service correction that satisfies those tests would therefore fail the lifecycle and read-only result scenarios here. Build this expected ID from the configured subscription as well.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor
[Pilot] PR Pipeline Failure Analysis

What failed

Azure Pipelines build 7017108 failed on all 6 platform legs (macos311, ubuntu2404_311, ubuntu2404_311_coverage, Ubuntu2404_313, Ubuntu2404_314, windows2022_312; both whl and sdist installs), each with the identical failure:

  • sdk.platformvalidation.azure-mgmt-platformvalidation.tests.test_catalog.TestCatalog.test_public_catalog
  • sdk.platformvalidation.azure-mgmt-platformvalidation.tests.test_catalog.TestCatalog.test_public_catalog_async

A separate GitHub Actions job, Test Azure SDK Tools, also failed with test_rust_support_is_disabled_by_default_and_forwarded raising KeyError: '${{ if parameters.InstallMsRustToolchain }}'. This test file (eng/tools/azure-sdk-tools/tests/test_native_build_pipeline.py) is not touched by this PR's diff, so this failure is unrelated pre-existing/flaky repo-tooling test noise, not caused by this change.

Relevant pipeline output

Catalog ID assertion failure (identical on every platform)
tests/test_catalog.py:78: in test_public_catalog
    self.assert_entry(test, test_id, name)

entry = {'id': '/providers/Microsoft.PlatformValidation/validationTests/compute-vmimagevalidation-vm-boot-test', 'name': 'compute-vmimagevalidation-vm-boot-test', ...}
resource_id = '/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.PlatformValidation/validationTests/compute-vmimagevalidation-vm-boot-test'

def assert_entry(self, entry, resource_id, name):
    assert entry.name == name
    actual_id = entry.id
>   assert (
        actual_id and actual_id.lower() == resource_id.lower()
    ), "Catalog ID differs from the canonical subscription-scoped identity."
E   AssertionError: Catalog ID differs from the canonical subscription-scoped identity.
E     - /subscriptions/00000000-0000-0000-0000-000000000000/providers/microsoft.platformvalidation/validationtests/compute-vmimagevalidation-vm-boot-test
E     ? ---------------------------------------------------
E     + /providers/microsoft.platformvalidation/validationtests/compute-vmimagevalidation-vm-boot-test
tests/test_catalog.py:48: AssertionError

Identical trace for test_public_catalog_async, same recorded response (tests/recordings/test_catalog.*), confirming one root cause reproduced across all platforms/install modes.

Diagnosis

This is a recorded-response / contract mismatch, not a logic bug in the test or production code. The PR author's own description confirms this: the test asserts a subscription-scoped catalog resource id (/subscriptions/{subscriptionId}/providers/Microsoft.PlatformValidation/...), matching the official TypeSpec's @subscriptionResource declaration for the catalog/category/version hierarchy. However, the committed recording (and the currently deployed PlatformValidation service) still returns a provider-global id (/providers/Microsoft.PlatformValidation/...), without the subscription segment.

No amount of client-side code change can make the committed recording return a different id value — the assertion is deliberately strict and correctly flags a genuine service/recording contract gap. The author explicitly marked the PR "Ready for review, not merge-ready" pending either:

  1. A service-side fix so the catalog API returns subscription-scoped IDs, followed by re-recording, or
  2. A decision to relax the assertion if provider-global IDs are the intended (TypeSpec-divergent) contract.

Recommended next steps

  • Do not patch the test assertion to silently accept the provider-global ID; that would mask a real API-contract divergence from the published TypeSpec.
  • Confirm with the PlatformValidation service team whether the catalog/version id should be subscription-scoped (per TypeSpec) or provider-global (current deployed behavior and current recording).
  • Once resolved, re-record test_public_catalog/test_public_catalog_async live and republish the recording per the package README's live/record/playback/publish workflow, then rerun CI.
  • The unrelated test_rust_support_is_disabled_by_default_and_forwarded failure in Test Azure SDK Tools is not caused by this PR's diff; re-run that job or investigate separately if it persists.
  • See https://aka.ms/ci-fix

Copilot detected the failing pipeline and generated the analysis above. To have it attempt a
fix automatically, reply with @copilot please fix the failing pipeline on this PR.

Generated by Pipeline Analysis Next Steps · copilot · sonnet50 · 49.6 AIC · ⌖ 0.568 AIC · ⊞ 8.9K · ◷

This branch has not been deployed

No deployments
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.

2 participants