[storagemover] Add scenario tests for Storage Mover#49281
Conversation
…methods) Ports the cross-language Storage Mover scenario test suite from azure-sdk-for-net (Azure.ResourceManager.StorageMover/tests/Scenario, 9 files, 30 methods) to the Java SDK. Layout is 1:1 with the .NET source; assertions are adapted to the Java fluent API. Files: - StorageMoverManagementTestBase abstract base, extends ResourceManagerTestProxyTestBase. Provides MultiCloudConnector / AWS S3 well-known IDs from the .NET base, FAKE_STORAGE_ACCOUNT_ID, FIXED_SCHEDULE_START (2030-01-01T00:00:00Z so playback is deterministic and the date serialises with a Z suffix to avoid the RP +00:00 bug documented in the cross-language playbook), generateRandomResourceName, and an assertNotFound helper for the Java-no-Exists-API gap. - AgentTests 1 method, @disabled (agent VM required) - StorageMoverCollectionTests 1 method - StorageMoverResourceTests 5 methods, 1 @disabled - ProjectCollectionTests 1 method - ProjectResourceTests 1 method - JobDefinitionJobRunTests 1 method (startJob/stopJob assertThrows ManagementException) - JobDefinitionScheduleTests 3 methods (Weekly / Daily + preservePermissions / Onetime) - JobRunTests 1 method (combined empty list + 404 get) - EndpointTests 16 methods (omnibus + MultiCloudConnector + S3WithHmac activated + 7 valid endpointKind + 5 invalid endpointKind + NfsFileShare). SMB-update identity:None workaround applied per the cross-language playbook. assets.json added with empty Tag; will be populated on first test-proxy push. The pre-existing trivial smoke test StorageMoverManagerTests.java is removed; the README example is hard-coded (not embed-extracted) so this does not affect docs. Compile-checked under Java 21 + Java 8 baseline. All 120 generated mock tests still pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…agement assertions
…efinition with private source
There was a problem hiding this comment.
Pull request overview
Adds the Java port of the cross-language Storage Mover scenario test matrix to azure-resourcemanager-storagemover, including the new private-link Connection CRUD scenario (row #32) and the end-to-end private-source C2C scenario (row #31), with assets pinned for playback.
Changes:
- Replaces the prior ad-hoc live-only manager test with a scenario-based suite under
src/test/java/.../scenario/. - Introduces a shared scenario-test base that handles test-proxy sanitizers, shared pipeline setup, and cross-sub managers used by the new E2E scenarios.
- Adds test-scope dependencies needed for private endpoint approval, RBAC assignment, and blob container provisioning, plus an
assets.jsontag pin.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/StorageMoverManagerTests.java | Removes the old live-only test in favor of scenario coverage. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/StorageMoverManagementTestBase.java | Adds shared scenario base (pipeline, sanitizers, helpers, cross-sub managers). |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/StorageMoverResourceTests.java | Adds StorageMover resource CRUD/tagging scenarios (incl. disabled agent scenario placeholder). |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/StorageMoverCollectionTests.java | Adds StorageMover collection create/update/get/list/existence scenarios. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/ProjectCollectionTests.java | Adds Project collection create/get/list scenario. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/ProjectResourceTests.java | Adds Project resource get/update/delete scenario. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/JobDefinitionJobRunTests.java | Adds JobDefinition CRUD and expected failure for start/stop without agent. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/JobDefinitionScheduleTests.java | Adds schedule scenarios with dynamic dates + sanitizer strategy for portable playback. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/JobRunTests.java | Adds JobRun list/get negative assertions for agentless environment. |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/EndpointTests.java | Adds endpoint CRUD and endpoint-kind validation scenarios (incl. S3WithHmac activated). |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/ConnectionTests.java | Adds Connection CRUD against shared private-link service (row #32). |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/JobDefinitionPrivateSourceTests.java | Adds full private-source C2C E2E scenario with PE approval, RBAC, startJob polling, cleanup (row #31). |
| sdk/storagemover/azure-resourcemanager-storagemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/AgentTests.java | Adds disabled agent scenario placeholder to match cross-language matrix. |
| sdk/storagemover/azure-resourcemanager-storagemover/pom.xml | Adds test-scope mgmt dependencies for network/authorization/storage used by new scenarios. |
| sdk/storagemover/azure-resourcemanager-storagemover/assets.json | Pins the azure-sdk-assets tag for deterministic playback. |
| interceptorManager.addSanitizers(Arrays.asList( | ||
| new TestProxySanitizer("$..startDate", null, REDACTED_SCHEDULE_DATE, TestProxySanitizerType.BODY_KEY), | ||
| new TestProxySanitizer("$..endDate", null, REDACTED_SCHEDULE_DATE, TestProxySanitizerType.BODY_KEY), | ||
| new TestProxySanitizer("$..principalId", null, "00000000-0000-0000-0000-000000000000", | ||
| TestProxySanitizerType.BODY_KEY), | ||
| new TestProxySanitizer("$..tenantId", null, "00000000-0000-0000-0000-000000000000", | ||
| TestProxySanitizerType.BODY_KEY))); |
| private static final String REDACTED_SCHEDULE_DATE = "2030-01-01T00:00:00Z"; | ||
|
|
||
| /** | ||
| * Returns a {@code startDate} suitable for schedule tests. | ||
| * | ||
| * <p>The Storage Mover RP rejects any {@code endDate} more than one year | ||
| * past wall-clock {@code now()}, so a hard-coded far-future date does not | ||
| * work. The body-key sanitizer registered in {@link #beforeTest} rewrites | ||
| * the value to {@link #REDACTED_SCHEDULE_DATE} in both the stored recording | ||
| * and the live request during playback, keeping the recordings portable. | ||
| * | ||
| * @return a UTC {@link OffsetDateTime} one day in the future, truncated to | ||
| * the day so the JSON payload is stable. | ||
| */ | ||
| protected static OffsetDateTime scheduleStartDate() { | ||
| return OffsetDateTime.now(ZoneOffset.UTC).plusDays(1).truncatedTo(ChronoUnit.DAYS); | ||
| } |
There was a problem hiding this comment.
If you want datetimes that are durable in record and playback and don't want to hard code a mock value there is TestResourceName.now() which returns an OffsetDateTime that either gets recorded as a replayable value (TestMode == RECORD) or plays back a recorded value (TestMode == PLAYBACK).
Prefer that instead of hardcoding something that may cause issues in the future.
| * @param expectedStatus expected HTTP status (typically 404). | ||
| * @param action the operation that should throw. | ||
| */ | ||
| protected static void assertHttpStatus(int expectedStatus, Runnable action) { |
There was a problem hiding this comment.
May want to rename this to be more descriptive, assertManageExceptionAndHttpStatus
| long count = StreamSupport | ||
| .stream(storageMoverManager.connections().list(resourceGroupName, sm.name()).spliterator(), false) | ||
| .count(); | ||
| Assertions.assertTrue(count >= 1, "expected at least one connection but found " + count); |
There was a problem hiding this comment.
Given we're only looking to see if we have at least one connection, instead of enumerating through all possible pages to get a count we could just check if there is .hasNext().
| long count = StreamSupport | |
| .stream(storageMoverManager.connections().list(resourceGroupName, sm.name()).spliterator(), false) | |
| .count(); | |
| Assertions.assertTrue(count >= 1, "expected at least one connection but found " + count); | |
| boolean hasNext = storageMoverManager.connections().list(resourceGroupName, sm.name()).iterator().hasNext(); | |
| Assertions.assertTrue(hasNext, "expected at least one connection but found " + count); |
Or, keep this as-is but validate that we find the matching connectionName in the listed connections, as that is what we probably should be checking for here.
Summary
Adding Scenario tests for suite in Java
(
sdk/storagemover/azure-resourcemanager-storagemover). Mirrors the.NET source-of-truth 1:1 across all 32 rows of the language-agnostic
matrix shared with .NET, Python, JS, Go, and the CLI extension.
Net layout: 10 files under
src/test/java/com/azure/resourcemanager/storagemover/scenario/—StorageMoverManagementTestBase+ 9*Tests.javaclasses.