Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
18 changes: 18 additions & 0 deletions sdk/storagemover/azure-resourcemanager-storagemover/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@
<version>2.54.1</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-resources;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-network</artifactId>
<version>2.58.2</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-network;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-authorization</artifactId>
<version>2.53.9</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-authorization;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-storage</artifactId>
<version>2.56.0</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-storage;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-test</artifactId>
Expand Down

This file was deleted.

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.
}
}
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);
Comment on lines +68 to +71
Copy link
Copy Markdown
Member

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().

Suggested change
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.


// 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.
}
}
}
}
Loading