-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[storagemover] Add scenario tests for Storage Mover #49281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sssash18
wants to merge
4
commits into
main
Choose a base branch
from
fix/storagemover-java-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6e9d934
[storagemover] Add scenario tests mirroring .NET source-of-truth (30 …
8496bbe
Refactor schedule tests to use dynamic start dates and update tag man…
7dc6f87
Update Tag in assets.json for storagemover to reflect current version
92f50ad
Update assets.json tag and add scenario tests for Connection and JobD…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
sdk/storagemover/azure-resourcemanager-storagemover/assets.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "AssetsRepo": "Azure/azure-sdk-assets", | ||
| "AssetsRepoPrefixPath": "java", | ||
| "TagPrefix": "java/storagemover/azure-resourcemanager-storagemover", | ||
| "Tag": "java/storagemover/azure-resourcemanager-storagemover_f2516d6925" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 0 additions & 93 deletions
93
...emover/src/test/java/com/azure/resourcemanager/storagemover/StorageMoverManagerTests.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...toragemover/src/test/java/com/azure/resourcemanager/storagemover/scenario/AgentTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.resourcemanager.storagemover.scenario; | ||
|
|
||
| import org.junit.jupiter.api.Disabled; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| /** | ||
| * Mirrors {@code AgentTests.cs} from the .NET source-of-truth test suite. | ||
| * | ||
| * <p>The single {@code GetExistTest} method is skipped in every language port | ||
| * because Storage Mover agents cannot be created via the RP — they self-register | ||
| * from a real VM. See {@code storage-mover-scenario-tests-cross-language} task | ||
| * note for the rationale shared across .NET, Python, JS, Go, and Java. | ||
| */ | ||
| public class AgentTests extends StorageMoverManagementTestBase { | ||
|
|
||
| @Test | ||
| @Disabled("Agents cannot be created by the RP; this test requires a registered agent VM.") | ||
| public void getExist() { | ||
| // Body intentionally empty — see @Disabled reason. The .NET reference | ||
| // exercises agent get / list / patch (uploadLimitWeeklyRecurrences) on | ||
| // a pre-existing agent named "testagent1", which is impossible to set | ||
| // up hermetically. | ||
| } | ||
| } |
98 changes: 98 additions & 0 deletions
98
...emover/src/test/java/com/azure/resourcemanager/storagemover/scenario/ConnectionTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.resourcemanager.storagemover.scenario; | ||
|
|
||
| import com.azure.core.management.Region; | ||
| import com.azure.resourcemanager.storagemover.models.Connection; | ||
| import com.azure.resourcemanager.storagemover.models.ConnectionProperties; | ||
| import com.azure.resourcemanager.storagemover.models.StorageMover; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.stream.StreamSupport; | ||
|
|
||
| /** | ||
| * Mirrors {@code ConnectionTests.cs} from the .NET source-of-truth (row #32 of | ||
| * the cross-language matrix). Exercises Connection CRUD against the shared | ||
| * private-link service {@code test-pls-wcs}. | ||
| * | ||
| * <p>Operates in {@code westcentralus} because the upstream PLS is deployed | ||
| * there; the per-test resource group is provisioned in the same region so | ||
| * private endpoint provisioning stays in-region. | ||
| * | ||
| * <p>This test intentionally does not assert on {@code connectionStatus} — | ||
| * PLS provisioning is asynchronous and the status starts as {@code Pending}. | ||
| * The status assertion lives in the C2C-with-private-source scenario (row | ||
| * #31) where the PE is explicitly approved. | ||
| * | ||
| * <p>The {@code description} field on update is also intentionally not asserted | ||
| * to equal the new value — the RP echoes the stale (create-time) description | ||
| * for several seconds after a PATCH and the assertion would be flaky across | ||
| * languages (Python and JS hit the same behaviour). | ||
| */ | ||
| public class ConnectionTests extends StorageMoverManagementTestBase { | ||
|
|
||
| @Override | ||
| protected Region testRegion() { | ||
| return WEST_CENTRAL_US; | ||
| } | ||
|
|
||
| @Test | ||
| public void createGetListUpdateDelete() { | ||
| String storageMoverName = generateRandomResourceName("stomover-conn-", 24); | ||
| String connectionName = generateRandomResourceName("conn-", 24); | ||
|
|
||
| StorageMover sm = storageMoverManager.storageMovers() | ||
| .define(storageMoverName) | ||
| .withRegion(testRegion()) | ||
| .withExistingResourceGroup(resourceGroupName) | ||
| .create(); | ||
|
|
||
| try { | ||
| Connection created = storageMoverManager.connections() | ||
| .define(connectionName) | ||
| .withExistingStorageMover(resourceGroupName, sm.name()) | ||
| .withProperties(new ConnectionProperties().withDescription("initial description") | ||
| .withPrivateLinkServiceId(PRIVATE_LINK_SERVICE_ID)) | ||
| .create(); | ||
| Assertions.assertEquals(connectionName, created.name()); | ||
| Assertions.assertNotNull(created.properties()); | ||
| Assertions.assertEquals("initial description", created.properties().description()); | ||
| Assertions.assertEquals(PRIVATE_LINK_SERVICE_ID, created.properties().privateLinkServiceId()); | ||
|
|
||
| Connection fetched = storageMoverManager.connections().get(resourceGroupName, sm.name(), connectionName); | ||
| Assertions.assertEquals(connectionName, fetched.name()); | ||
| Assertions.assertEquals(PRIVATE_LINK_SERVICE_ID, fetched.properties().privateLinkServiceId()); | ||
|
|
||
| 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); | ||
|
|
||
| // Update keeps the same PLS id (cannot be changed post-create) and | ||
| // changes only the description. The new description is intentionally | ||
| // NOT asserted because the RP echoes the create-time value for several | ||
| // seconds after the PATCH (cross-language flakiness — see playbook). | ||
| Connection updated = fetched.update() | ||
| .withProperties(new ConnectionProperties().withDescription("updated description") | ||
| .withPrivateLinkServiceId(PRIVATE_LINK_SERVICE_ID)) | ||
| .apply(); | ||
| Assertions.assertEquals(connectionName, updated.name()); | ||
|
|
||
| Connection refreshed = updated.refresh(); | ||
| Assertions.assertEquals(connectionName, refreshed.name()); | ||
|
|
||
| storageMoverManager.connections().delete(resourceGroupName, sm.name(), connectionName); | ||
| assertNotFound(() -> storageMoverManager.connections().get(resourceGroupName, sm.name(), connectionName)); | ||
| } finally { | ||
| // Best-effort cleanup in case the test failed before the explicit | ||
| // delete above. Idempotent — delete on a missing resource is a 204. | ||
| try { | ||
| storageMoverManager.connections().delete(resourceGroupName, sm.name(), connectionName); | ||
| } catch (RuntimeException ignored) { | ||
| // already deleted or never created. | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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().Or, keep this as-is but validate that we find the matching
connectionNamein the listed connections, as that is what we probably should be checking for here.