Skip to content

Commit

Permalink
mgmt, re-recrod DeploymentStacksTests after core-test update (#40441)
Browse files Browse the repository at this point in the history
* re-recrod DeploymentStacksTests after core-test update

* sanitize subscription id in id

* add assertResourceIdEquals for comparing resource ID
  • Loading branch information
weidongxu-microsoft authored Jun 4, 2024
1 parent ca60bc3 commit d784dab
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ public void canCRUDApp() {
Assertions.assertNotNull(app.url());
Assertions.assertTrue(app.isHttpsOnly());
Assertions.assertTrue(app.isPublic());
Assertions.assertTrue(app.hasConfigurationServiceBinding());
Assertions.assertTrue(app.hasServiceRegistryBinding());
Assertions.assertTrue(springService.getDefaultConfigurationService().getAppBindings().stream().anyMatch(SpringApp::hasConfigurationServiceBinding));
Assertions.assertTrue(springService.getDefaultServiceRegistry().getAppBindings().stream().anyMatch(SpringApp::hasServiceRegistryBinding));
if (!isPlaybackMode()) {
// skip in playback, as "hasConfigurationServiceBinding" involve resource ID check
Assertions.assertTrue(app.hasConfigurationServiceBinding());
Assertions.assertTrue(app.hasServiceRegistryBinding());
Assertions.assertTrue(springService.getDefaultConfigurationService().getAppBindings().stream().anyMatch(SpringApp::hasConfigurationServiceBinding));
Assertions.assertTrue(springService.getDefaultServiceRegistry().getAppBindings().stream().anyMatch(SpringApp::hasServiceRegistryBinding));
}

app.update()
.withoutHttpsOnly()
Expand All @@ -133,9 +136,11 @@ public void canCRUDApp() {

Assertions.assertFalse(app.isHttpsOnly());
Assertions.assertFalse(app.isPublic());
Assertions.assertFalse(app.hasConfigurationServiceBinding());
Assertions.assertFalse(app.hasServiceRegistryBinding());
Assertions.assertFalse(springService.getDefaultConfigurationService().getAppBindings().stream().anyMatch(SpringApp::hasConfigurationServiceBinding));
Assertions.assertFalse(springService.getDefaultServiceRegistry().getAppBindings().stream().anyMatch(SpringApp::hasServiceRegistryBinding));
if (!isPlaybackMode()) {
Assertions.assertFalse(app.hasConfigurationServiceBinding());
Assertions.assertFalse(app.hasServiceRegistryBinding());
Assertions.assertFalse(springService.getDefaultConfigurationService().getAppBindings().stream().anyMatch(SpringApp::hasConfigurationServiceBinding));
Assertions.assertFalse(springService.getDefaultServiceRegistry().getAppBindings().stream().anyMatch(SpringApp::hasServiceRegistryBinding));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public void canCreateAndUpdateFunctionAppOnACA() {

FunctionApp functionApp = appServiceManager.functionApps().getByResourceGroup(rgName1, webappName1);

Assertions.assertEquals(managedEnvironmentId, functionApp.managedEnvironmentId());
assertResourceIdEquals(managedEnvironmentId, functionApp.managedEnvironmentId());
Assertions.assertEquals(10, functionApp.maxReplicas());
Assertions.assertEquals(3, functionApp.minReplicas());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public void canOperateOnManagedDiskFromDisk() {
Assertions.assertNull(disk.osType());
Assertions.assertNotNull(disk.source());
Assertions.assertEquals(disk.source().type(), CreationSourceType.COPIED_FROM_DISK);
Assertions.assertTrue(disk.source().sourceId().equalsIgnoreCase(emptyDisk.id()));
assertResourceIdEquals(disk.source().sourceId(), emptyDisk.id());

computeManager.disks().deleteById(emptyDisk.id());
computeManager.disks().deleteById(disk.id());
Expand Down Expand Up @@ -224,7 +224,7 @@ public void canOperateOnManagedDiskFromSnapshot() {
Assertions.assertNull(snapshot.osType());
Assertions.assertNotNull(snapshot.source());
Assertions.assertEquals(snapshot.source().type(), CreationSourceType.COPIED_FROM_DISK);
Assertions.assertTrue(snapshot.source().sourceId().equalsIgnoreCase(emptyDisk.id()));
assertResourceIdEquals(snapshot.source().sourceId(), emptyDisk.id());

Disk fromSnapshotDisk =
computeManager
Expand All @@ -245,7 +245,7 @@ public void canOperateOnManagedDiskFromSnapshot() {
Assertions.assertNull(fromSnapshotDisk.osType());
Assertions.assertNotNull(fromSnapshotDisk.source());
Assertions.assertEquals(fromSnapshotDisk.source().type(), CreationSourceType.COPIED_FROM_SNAPSHOT);
Assertions.assertTrue(fromSnapshotDisk.source().sourceId().equalsIgnoreCase(snapshot.id()));
assertResourceIdEquals(snapshot.source().sourceId(), emptyDisk.id());
}

// test-proxy playback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

--add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
</javaModulesSurefireArgLine>
<revapi.skip>true</revapi.skip>
</properties>

<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ public void canManageGeoDisasterRecoveryPairing() throws Throwable {
Assertions.assertTrue(pairing.name().equalsIgnoreCase(geodrName));
Assertions.assertTrue(pairing.primaryNamespaceResourceGroupName().equalsIgnoreCase(rgName));
Assertions.assertTrue(pairing.primaryNamespaceName().equalsIgnoreCase(primaryNamespace.name()));
Assertions.assertTrue(pairing.secondaryNamespaceId().equalsIgnoreCase(secondaryNamespace.id()));
assertResourceIdEquals(pairing.secondaryNamespaceId(), secondaryNamespace.id());

PagedIterable<DisasterRecoveryPairingAuthorizationRule> rules = pairing.listAuthorizationRules();
Assertions.assertTrue(TestUtilities.getSize(rules) > 0);
Expand All @@ -572,7 +572,7 @@ public void canManageGeoDisasterRecoveryPairing() throws Throwable {
found = true;
Assertions.assertTrue(pairing1.primaryNamespaceResourceGroupName().equalsIgnoreCase(rgName));
Assertions.assertTrue(pairing1.primaryNamespaceName().equalsIgnoreCase(primaryNamespace.name()));
Assertions.assertTrue(pairing1.secondaryNamespaceId().equalsIgnoreCase(secondaryNamespace.id()));
assertResourceIdEquals(pairing.secondaryNamespaceId(), secondaryNamespace.id());
}
}
Assertions.assertTrue(found);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void canCRUDAutoscale() throws Exception {

Assertions.assertNotNull(setting);
Assertions.assertEquals("somesettingZ", setting.name());
Assertions.assertEquals(servicePlan.id(), setting.targetResourceId());
assertResourceIdEquals(servicePlan.id(), setting.targetResourceId());
Assertions.assertTrue(setting.adminEmailNotificationEnabled());
Assertions.assertTrue(setting.coAdminEmailNotificationEnabled());
Assertions.assertFalse(setting.autoscaleEnabled());
Expand Down Expand Up @@ -162,7 +162,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
ScaleRule rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofMinutes(10), rule.duration());
Assertions.assertEquals(Duration.ofMinutes(1), rule.frequency());
Expand Down Expand Up @@ -195,7 +195,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofMinutes(10), rule.duration());
Assertions.assertEquals(Duration.ofMinutes(1), rule.frequency());
Expand All @@ -212,7 +212,7 @@ public void canCRUDAutoscale() throws Exception {
AutoscaleSetting settingFromGet = monitorManager.autoscaleSettings().getById(setting.id());
Assertions.assertNotNull(settingFromGet);
Assertions.assertEquals("somesettingZ", settingFromGet.name());
Assertions.assertEquals(servicePlan.id(), settingFromGet.targetResourceId());
assertResourceIdEquals(servicePlan.id(), settingFromGet.targetResourceId());
Assertions.assertTrue(settingFromGet.adminEmailNotificationEnabled());
Assertions.assertTrue(settingFromGet.coAdminEmailNotificationEnabled());
Assertions.assertFalse(settingFromGet.autoscaleEnabled());
Expand Down Expand Up @@ -264,7 +264,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofMinutes(10), rule.duration());
Assertions.assertEquals(Duration.ofMinutes(1), rule.frequency());
Expand Down Expand Up @@ -297,7 +297,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofMinutes(10), rule.duration());
Assertions.assertEquals(Duration.ofMinutes(1), rule.frequency());
Expand Down Expand Up @@ -350,7 +350,7 @@ public void canCRUDAutoscale() throws Exception {

Assertions.assertNotNull(setting);
Assertions.assertEquals("somesettingZ", setting.name());
Assertions.assertEquals(servicePlan.id(), setting.targetResourceId());
assertResourceIdEquals(servicePlan.id(), setting.targetResourceId());
Assertions.assertTrue(setting.adminEmailNotificationEnabled());
Assertions.assertFalse(setting.coAdminEmailNotificationEnabled());
Assertions.assertTrue(setting.autoscaleEnabled());
Expand Down Expand Up @@ -413,7 +413,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofHours(10), rule.duration());
Assertions.assertEquals(Duration.ofHours(1), rule.frequency());
Expand Down Expand Up @@ -443,7 +443,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofMinutes(15), rule.duration());
Assertions.assertEquals(Duration.ofMinutes(1), rule.frequency());
Expand All @@ -461,7 +461,7 @@ public void canCRUDAutoscale() throws Exception {

Assertions.assertNotNull(settingFromGet);
Assertions.assertEquals("somesettingZ", settingFromGet.name());
Assertions.assertEquals(servicePlan.id(), settingFromGet.targetResourceId());
assertResourceIdEquals(servicePlan.id(), settingFromGet.targetResourceId());
Assertions.assertTrue(settingFromGet.adminEmailNotificationEnabled());
Assertions.assertFalse(settingFromGet.coAdminEmailNotificationEnabled());
Assertions.assertTrue(settingFromGet.autoscaleEnabled());
Expand Down Expand Up @@ -524,7 +524,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofHours(10), rule.duration());
Assertions.assertEquals(Duration.ofHours(1), rule.frequency());
Expand Down Expand Up @@ -554,7 +554,7 @@ public void canCRUDAutoscale() throws Exception {
Assertions.assertNotNull(tempProfile.rules());
Assertions.assertEquals(1, tempProfile.rules().size());
rule = tempProfile.rules().get(0);
Assertions.assertEquals(servicePlan.id(), rule.metricSource());
assertResourceIdEquals(servicePlan.id(), rule.metricSource());
Assertions.assertEquals("CPUPercentage", rule.metricName());
Assertions.assertEquals(Duration.ofMinutes(15), rule.duration());
Assertions.assertEquals(Duration.ofMinutes(1), rule.frequency());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public void canCRUDDiagnosticSettings() {
.withLogsAndMetrics(categories, Duration.ofMinutes(5), 7)
.create();

Assertions.assertTrue(vm.id().equalsIgnoreCase(setting.resourceId()));
Assertions.assertTrue(sa.id().equalsIgnoreCase(setting.storageAccountId()));
Assertions.assertTrue(evenHubNsRule.id().equalsIgnoreCase(setting.eventHubAuthorizationRuleId()));
assertResourceIdEquals(vm.id(), setting.resourceId());
assertResourceIdEquals(sa.id(), setting.storageAccountId());
assertResourceIdEquals(evenHubNsRule.id(), setting.eventHubAuthorizationRuleId());
Assertions.assertNull(setting.eventHubName());
Assertions.assertNull(setting.workspaceId());
Assertions.assertTrue(setting.logs().isEmpty());
Expand All @@ -112,8 +112,8 @@ public void canCRUDDiagnosticSettings() {
.withoutLogs()
.apply();

Assertions.assertTrue(vm.id().equalsIgnoreCase(setting.resourceId()));
Assertions.assertTrue(evenHubNsRule.id().equalsIgnoreCase(setting.eventHubAuthorizationRuleId()));
assertResourceIdEquals(vm.id(), setting.resourceId());
assertResourceIdEquals(evenHubNsRule.id(), setting.eventHubAuthorizationRuleId());
Assertions.assertNull(setting.storageAccountId());
Assertions.assertNull(setting.eventHubName());
Assertions.assertNull(setting.workspaceId());
Expand Down Expand Up @@ -162,7 +162,7 @@ public void canCRUDDiagnosticSettingsForSubscription() {
if (!isPlaybackMode()) {
Assertions.assertTrue(resourceId.equalsIgnoreCase(setting.resourceId()));
}
Assertions.assertTrue(sa.id().equalsIgnoreCase(setting.storageAccountId()));
assertResourceIdEquals(sa.id(), setting.storageAccountId());

Assertions.assertFalse(setting.logs().isEmpty());
Assertions.assertTrue(setting.metrics().isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/resourcemanager/azure-resourcemanager-resources",
"Tag": "java/resourcemanager/azure-resourcemanager-resources_1f62f881a3"
"Tag": "java/resourcemanager/azure-resourcemanager-resources_d2b26f3d6e"
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public void testDeploymentStacks() {
.withDenySettings(new DenySettings()
.withMode(DenySettingsMode.NONE)));

// Assertions.assertEquals(dpName, deploymentStack.name());
Assertions.assertEquals(dpName, deploymentStack.name());
Assertions.assertEquals(DeploymentStacksDeleteDetachEnum.DELETE, deploymentStack.actionOnUnmanage().resources());

deploymentStack = resourceClient.deploymentStackClient().getDeploymentStacks()
.getByResourceGroup(rgName, dpName);
// Assertions.assertEquals(dpName, deploymentStack.name());
Assertions.assertEquals(dpName, deploymentStack.name());
Assertions.assertEquals(DeploymentStacksDeleteDetachEnum.DELETE, deploymentStack.actionOnUnmanage().resources());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.azure.resourcemanager.resources;

import com.azure.resourcemanager.resources.implementation.TypeSerializationTests;
import com.azure.resourcemanager.resources.models.GenericResource;
import com.azure.resourcemanager.resources.models.ResourceGroup;
import com.azure.resourcemanager.resources.models.TagResource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -17,7 +17,9 @@ public class TagsTests extends ResourceManagementTest {
@Test
public void canUpdateTag() throws Exception {
// assume there is a resource
GenericResource resource = resourceClient.genericResources().list().iterator().next();
ResourceGroup resource = resourceClient.resourceGroups().list().stream()
.filter(resourceGroup -> "Succeeded".equalsIgnoreCase(resourceGroup.provisioningState()))
.findFirst().get();

Map<String, String> originalTags = resource.tags();
if (originalTags == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public void canCRUDSqlFailoverGroup() throws Exception {
.withNewDatabaseId(db.id())
.apply();
Assertions.assertEquals(1, failoverGroup.databases().size());
Assertions.assertEquals(db.id(), failoverGroup.databases().get(0));
assertResourceIdEquals(db.id(), failoverGroup.databases().get(0));
Assertions.assertEquals(0, failoverGroup.readWriteEndpointDataLossGracePeriodMinutes());
Assertions.assertEquals(ReadWriteEndpointFailoverPolicy.MANUAL, failoverGroup.readWriteEndpointPolicy());
Assertions.assertEquals(ReadOnlyEndpointFailoverPolicy.DISABLED, failoverGroup.readOnlyEndpointPolicy());
Expand Down
Loading

0 comments on commit d784dab

Please sign in to comment.