From 9ff8c4c440cf0a6a7de3df666db176f28de66e2e Mon Sep 17 00:00:00 2001 From: "Hong Li(MSFT)" Date: Mon, 12 Jun 2023 16:25:09 +0800 Subject: [PATCH 1/6] mgmt, recoveryservicesbackup, add live tests --- .../pom.xml | 12 + .../RecoveryServicesBackupManagerTests.java | 295 ++++++++++++++++++ .../test-resources.bicep | 27 ++ sdk/recoveryservicesbackup/tests.mgmt.yml | 16 + 4 files changed, 350 insertions(+) create mode 100644 sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java create mode 100644 sdk/recoveryservicesbackup/test-resources.bicep create mode 100644 sdk/recoveryservicesbackup/tests.mgmt.yml diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml index 4c5cef958e7ca..6f5df75c26652 100644 --- a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml @@ -57,6 +57,18 @@ azure-core-management 1.11.2 + + com.azure.resourcemanager + azure-resourcemanager-recoveryservices + 1.1.0 + test + + + com.azure.resourcemanager + azure-resourcemanager-resources + 2.27.0 + test + com.azure azure-core-test diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java new file mode 100644 index 0000000000000..99e819224c88b --- /dev/null +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.resourcemanager.recoveryservicesbackup; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.Region; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.TestBase; +import com.azure.core.test.annotation.DoNotRecord; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.resourcemanager.recoveryservices.RecoveryServicesManager; +import com.azure.resourcemanager.recoveryservices.models.CrossSubscriptionRestoreSettings; +import com.azure.resourcemanager.recoveryservices.models.CrossSubscriptionRestoreState; +import com.azure.resourcemanager.recoveryservices.models.PublicNetworkAccess; +import com.azure.resourcemanager.recoveryservices.models.RestoreSettings; +import com.azure.resourcemanager.recoveryservices.models.Sku; +import com.azure.resourcemanager.recoveryservices.models.SkuName; +import com.azure.resourcemanager.recoveryservices.models.Vault; +import com.azure.resourcemanager.recoveryservices.models.VaultProperties; +import com.azure.resourcemanager.recoveryservicesbackup.models.AzureVmWorkloadProtectionPolicy; +import com.azure.resourcemanager.recoveryservicesbackup.models.DayOfWeek; +import com.azure.resourcemanager.recoveryservicesbackup.models.LogSchedulePolicy; +import com.azure.resourcemanager.recoveryservicesbackup.models.LongTermRetentionPolicy; +import com.azure.resourcemanager.recoveryservicesbackup.models.MonthOfYear; +import com.azure.resourcemanager.recoveryservicesbackup.models.MonthlyRetentionSchedule; +import com.azure.resourcemanager.recoveryservicesbackup.models.PolicyType; +import com.azure.resourcemanager.recoveryservicesbackup.models.ProtectionPolicyResource; +import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDuration; +import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionDurationType; +import com.azure.resourcemanager.recoveryservicesbackup.models.RetentionScheduleFormat; +import com.azure.resourcemanager.recoveryservicesbackup.models.ScheduleRunType; +import com.azure.resourcemanager.recoveryservicesbackup.models.Settings; +import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleRetentionPolicy; +import com.azure.resourcemanager.recoveryservicesbackup.models.SimpleSchedulePolicy; +import com.azure.resourcemanager.recoveryservicesbackup.models.SubProtectionPolicy; +import com.azure.resourcemanager.recoveryservicesbackup.models.WeekOfMonth; +import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionFormat; +import com.azure.resourcemanager.recoveryservicesbackup.models.WeeklyRetentionSchedule; +import com.azure.resourcemanager.recoveryservicesbackup.models.WorkloadType; +import com.azure.resourcemanager.recoveryservicesbackup.models.YearlyRetentionSchedule; +import com.azure.resourcemanager.resources.ResourceManager; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class RecoveryServicesBackupManagerTests extends TestBase { + private static final Random RANDOM = new Random(); + private static final Region REGION = Region.US_WEST2; + private String resourceGroupName = "rg" + randomPadding(); + private RecoveryServicesBackupManager recoveryServicesBackupManager; + private RecoveryServicesManager recoveryServicesManager; + private ResourceManager resourceManager; + private boolean testEnv; + + @Override + public void beforeTest() { + final TokenCredential credential = new DefaultAzureCredentialBuilder().build(); + final AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); + + recoveryServicesManager = RecoveryServicesManager + .configure() + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + + recoveryServicesBackupManager = RecoveryServicesBackupManager + .configure() + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile); + + resourceManager = ResourceManager + .configure() + .withLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)) + .authenticate(credential, profile) + .withDefaultSubscription(); + + // use AZURE_RESOURCE_GROUP_NAME if run in LIVE CI + String testResourceGroup = Configuration.getGlobalConfiguration().get("AZURE_RESOURCE_GROUP_NAME"); + testEnv = !CoreUtils.isNullOrEmpty(testResourceGroup); + if (testEnv) { + resourceGroupName = testResourceGroup; + } else { + resourceManager.resourceGroups() + .define(resourceGroupName) + .withRegion(REGION) + .create(); + } + } + + @Override + protected void afterTest() { + if (!testEnv) { + resourceManager.resourceGroups().beginDeleteByName(resourceGroupName); + } + } + + @Test + @DoNotRecord(skipInPlayback = true) + public void testCreateProtectionPolicy() { + Vault vault = null; + ProtectionPolicyResource protectionPolicyResource = null; + String randomPadding = randomPadding(); + try { + String vaultName = "vault" + randomPadding; + String policyName = "policy" + randomPadding; + + // @embedmeStart + List lstSubProtectionPolicy = new ArrayList<>(); + lstSubProtectionPolicy.add(new SubProtectionPolicy() + .withPolicyType(PolicyType.FULL) + .withSchedulePolicy( + new SimpleSchedulePolicy() + .withScheduleRunFrequency(ScheduleRunType.WEEKLY) + .withScheduleRunDays( + new ArrayList() { + { + add(DayOfWeek.SUNDAY); + add(DayOfWeek.TUESDAY); + } + }) + .withScheduleRunTimes( + new ArrayList() { + { + add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); + } + })) + .withRetentionPolicy( + new LongTermRetentionPolicy() + .withWeeklySchedule( + new WeeklyRetentionSchedule() + .withDaysOfTheWeek( + new ArrayList() { + { + add(DayOfWeek.SUNDAY); + add(DayOfWeek.TUESDAY); + } + }) + .withRetentionTimes( + new ArrayList() { + { + add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); + } + }) + .withRetentionDuration( + new RetentionDuration() + .withCount(2) + .withDurationType(RetentionDurationType.WEEKS))) + .withMonthlySchedule( + new MonthlyRetentionSchedule() + .withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY) + .withRetentionScheduleWeekly( + new WeeklyRetentionFormat() + .withDaysOfTheWeek( + new ArrayList() { + { + add(DayOfWeek.SUNDAY); + } + }) + .withWeeksOfTheMonth( + new ArrayList() { + { + add(WeekOfMonth.SECOND); + } + })) + .withRetentionTimes( + new ArrayList() { + { + add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); + } + }) + .withRetentionDuration( + new RetentionDuration() + .withCount(1) + .withDurationType(RetentionDurationType.MONTHS))) + .withYearlySchedule( + new YearlyRetentionSchedule() + .withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY) + .withMonthsOfYear( + new ArrayList() { + { + add(MonthOfYear.JANUARY); + add(MonthOfYear.JUNE); + add(MonthOfYear.DECEMBER); + } + }) + .withRetentionScheduleWeekly( + new WeeklyRetentionFormat() + .withDaysOfTheWeek( + new ArrayList() { + { + add(DayOfWeek.SUNDAY); + } + }) + .withWeeksOfTheMonth( + new ArrayList() { + { + add(WeekOfMonth.LAST); + } + })) + .withRetentionTimes( + new ArrayList() { + { + add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); + } + }) + .withRetentionDuration( + new RetentionDuration() + .withCount(1) + .withDurationType(RetentionDurationType.YEARS))))); + + lstSubProtectionPolicy.add(new SubProtectionPolicy() + .withPolicyType(PolicyType.DIFFERENTIAL) + .withSchedulePolicy( + new SimpleSchedulePolicy() + .withScheduleRunFrequency(ScheduleRunType.WEEKLY) + .withScheduleRunDays( + new ArrayList() { + { + add(DayOfWeek.FRIDAY); + } + }) + .withScheduleRunTimes( + new ArrayList() { + { + add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); + } + })) + .withRetentionPolicy( + new SimpleRetentionPolicy() + .withRetentionDuration( + new RetentionDuration() + .withCount(8) + .withDurationType(RetentionDurationType.DAYS)))); + + lstSubProtectionPolicy.add(new SubProtectionPolicy() + .withPolicyType(PolicyType.LOG) + .withSchedulePolicy(new LogSchedulePolicy().withScheduleFrequencyInMins(60)) + .withRetentionPolicy( + new SimpleRetentionPolicy() + .withRetentionDuration( + new RetentionDuration() + .withCount(7) + .withDurationType(RetentionDurationType.DAYS)))); + + vault = recoveryServicesManager.vaults() + .define(vaultName) + .withRegion(REGION) + .withExistingResourceGroup(resourceGroupName) + .withSku(new Sku().withName(SkuName.RS0).withTier("Standard")) + .withProperties(new VaultProperties() + .withPublicNetworkAccess(PublicNetworkAccess.ENABLED) + .withRestoreSettings(new RestoreSettings() + .withCrossSubscriptionRestoreSettings( + new CrossSubscriptionRestoreSettings() + .withCrossSubscriptionRestoreState(CrossSubscriptionRestoreState.ENABLED)))) + .create(); + + protectionPolicyResource = recoveryServicesBackupManager.protectionPolicies() + .define(policyName) + .withRegion(REGION) + .withExistingVault(vaultName, resourceGroupName) + .withProperties( + new AzureVmWorkloadProtectionPolicy() + .withWorkLoadType(WorkloadType.SQLDATA_BASE) + .withSettings(new Settings().withTimeZone("Pacific Standard Time").withIssqlcompression(false)) + .withSubProtectionPolicy(lstSubProtectionPolicy) + ) + .create(); + // @embedmeEnd + protectionPolicyResource.refresh(); + Assertions.assertEquals(protectionPolicyResource.name(), policyName); + Assertions.assertEquals(protectionPolicyResource.name(), recoveryServicesBackupManager.protectionPolicies().getById(protectionPolicyResource.id()).name()); + } finally { + if (protectionPolicyResource != null) { + recoveryServicesBackupManager.protectionPolicies().deleteById(protectionPolicyResource.id()); + } + if (vault != null) { + recoveryServicesManager.vaults().deleteById(vault.id()); + } + } + } + + private static String randomPadding() { + return String.format("%05d", Math.abs(RANDOM.nextInt() % 100000)); + } +} diff --git a/sdk/recoveryservicesbackup/test-resources.bicep b/sdk/recoveryservicesbackup/test-resources.bicep new file mode 100644 index 0000000000000..2250946806c02 --- /dev/null +++ b/sdk/recoveryservicesbackup/test-resources.bicep @@ -0,0 +1,27 @@ +@description('The tenant id to which the application and resources belong.') +param tenantId string = '72f988bf-86f1-41af-91ab-2d7cd011db47' + +@description('The client id of the service principal used to run tests.') +param testApplicationId string + +@description('This is the object id of the service principal used to run tests.') +param testApplicationOid string + +@description('The application client secret used to run tests.') +param testApplicationSecret string + +var contributorRoleId = '/subscriptions/${subscription().subscriptionId}/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c' + +resource contributorRoleId_name 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + name: guid('contributorRoleId${resourceGroup().name}') + properties: { + roleDefinitionId: contributorRoleId + principalId: testApplicationOid + } +} + +output AZURE_TENANT_ID string = tenantId +output AZURE_CLIENT_ID string = testApplicationId +output AZURE_CLIENT_SECRET string = testApplicationSecret +output AZURE_SUBSCRIPTION_ID string = subscription().subscriptionId +output AZURE_RESOURCE_GROUP_NAME string = resourceGroup().name diff --git a/sdk/recoveryservicesbackup/tests.mgmt.yml b/sdk/recoveryservicesbackup/tests.mgmt.yml new file mode 100644 index 0000000000000..e868aeab61977 --- /dev/null +++ b/sdk/recoveryservicesbackup/tests.mgmt.yml @@ -0,0 +1,16 @@ +trigger: none + +pr: none + +stages: + - template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml + parameters: + ServiceDirectory: recoveryservicesbackup + Artifacts: + - name: azure-resourcemanager-recoveryservicesbackup + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerrecoveryservicesbackup + Clouds: 'Public' + # Only run tests on Windows to save cost. + MatrixFilters: + - pool=.*(win).* From ccbc02b353d1de48d7a6f935bf18da33e4eb757a Mon Sep 17 00:00:00 2001 From: "Hong Li(MSFT)" Date: Tue, 13 Jun 2023 09:51:39 +0800 Subject: [PATCH 2/6] mgmt, recoveryservicesbackup, add live tests --- .../RecoveryServicesBackupManagerTests.java | 203 ++++++------------ 1 file changed, 66 insertions(+), 137 deletions(-) diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java index 99e819224c88b..07e91f1be3fe3 100644 --- a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java @@ -49,7 +49,7 @@ import org.junit.jupiter.api.Test; import java.time.OffsetDateTime; -import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Random; @@ -114,142 +114,71 @@ public void testCreateProtectionPolicy() { String policyName = "policy" + randomPadding; // @embedmeStart - List lstSubProtectionPolicy = new ArrayList<>(); - lstSubProtectionPolicy.add(new SubProtectionPolicy() - .withPolicyType(PolicyType.FULL) - .withSchedulePolicy( - new SimpleSchedulePolicy() - .withScheduleRunFrequency(ScheduleRunType.WEEKLY) - .withScheduleRunDays( - new ArrayList() { - { - add(DayOfWeek.SUNDAY); - add(DayOfWeek.TUESDAY); - } - }) - .withScheduleRunTimes( - new ArrayList() { - { - add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); - } - })) - .withRetentionPolicy( - new LongTermRetentionPolicy() - .withWeeklySchedule( - new WeeklyRetentionSchedule() - .withDaysOfTheWeek( - new ArrayList() { - { - add(DayOfWeek.SUNDAY); - add(DayOfWeek.TUESDAY); - } - }) - .withRetentionTimes( - new ArrayList() { - { - add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); - } - }) - .withRetentionDuration( - new RetentionDuration() - .withCount(2) - .withDurationType(RetentionDurationType.WEEKS))) - .withMonthlySchedule( - new MonthlyRetentionSchedule() - .withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY) - .withRetentionScheduleWeekly( - new WeeklyRetentionFormat() - .withDaysOfTheWeek( - new ArrayList() { - { - add(DayOfWeek.SUNDAY); - } - }) - .withWeeksOfTheMonth( - new ArrayList() { - { - add(WeekOfMonth.SECOND); - } - })) - .withRetentionTimes( - new ArrayList() { - { - add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); - } - }) - .withRetentionDuration( - new RetentionDuration() - .withCount(1) - .withDurationType(RetentionDurationType.MONTHS))) - .withYearlySchedule( - new YearlyRetentionSchedule() - .withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY) - .withMonthsOfYear( - new ArrayList() { - { - add(MonthOfYear.JANUARY); - add(MonthOfYear.JUNE); - add(MonthOfYear.DECEMBER); - } - }) - .withRetentionScheduleWeekly( - new WeeklyRetentionFormat() - .withDaysOfTheWeek( - new ArrayList() { - { - add(DayOfWeek.SUNDAY); - } - }) - .withWeeksOfTheMonth( - new ArrayList() { - { - add(WeekOfMonth.LAST); - } - })) - .withRetentionTimes( - new ArrayList() { - { - add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); - } - }) - .withRetentionDuration( - new RetentionDuration() - .withCount(1) - .withDurationType(RetentionDurationType.YEARS))))); - - lstSubProtectionPolicy.add(new SubProtectionPolicy() - .withPolicyType(PolicyType.DIFFERENTIAL) - .withSchedulePolicy( - new SimpleSchedulePolicy() - .withScheduleRunFrequency(ScheduleRunType.WEEKLY) - .withScheduleRunDays( - new ArrayList() { - { - add(DayOfWeek.FRIDAY); - } - }) - .withScheduleRunTimes( - new ArrayList() { - { - add(OffsetDateTime.parse("2018-01-24T10:00:00Z")); - } - })) - .withRetentionPolicy( - new SimpleRetentionPolicy() - .withRetentionDuration( - new RetentionDuration() - .withCount(8) - .withDurationType(RetentionDurationType.DAYS)))); - - lstSubProtectionPolicy.add(new SubProtectionPolicy() - .withPolicyType(PolicyType.LOG) - .withSchedulePolicy(new LogSchedulePolicy().withScheduleFrequencyInMins(60)) - .withRetentionPolicy( - new SimpleRetentionPolicy() - .withRetentionDuration( - new RetentionDuration() - .withCount(7) - .withDurationType(RetentionDurationType.DAYS)))); + List lstSubProtectionPolicy = Arrays.asList( + new SubProtectionPolicy() + .withPolicyType(PolicyType.FULL) + .withSchedulePolicy( + new SimpleSchedulePolicy() + .withScheduleRunFrequency(ScheduleRunType.WEEKLY) + .withScheduleRunDays(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY)) + .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))) + .withRetentionPolicy( + new LongTermRetentionPolicy() + .withWeeklySchedule( + new WeeklyRetentionSchedule() + .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY)) + .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))) + .withRetentionDuration( + new RetentionDuration() + .withCount(2) + .withDurationType(RetentionDurationType.WEEKS))) + .withMonthlySchedule( + new MonthlyRetentionSchedule() + .withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY) + .withRetentionScheduleWeekly( + new WeeklyRetentionFormat() + .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY)) + .withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.SECOND))) + .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))) + .withRetentionDuration( + new RetentionDuration() + .withCount(1) + .withDurationType(RetentionDurationType.MONTHS))) + .withYearlySchedule( + new YearlyRetentionSchedule() + .withRetentionScheduleFormatType(RetentionScheduleFormat.WEEKLY) + .withMonthsOfYear(Arrays.asList(MonthOfYear.JANUARY, MonthOfYear.JUNE, MonthOfYear.DECEMBER)) + .withRetentionScheduleWeekly( + new WeeklyRetentionFormat() + .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY)) + .withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.LAST))) + .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))) + .withRetentionDuration( + new RetentionDuration() + .withCount(1) + .withDurationType(RetentionDurationType.YEARS)))), + new SubProtectionPolicy() + .withPolicyType(PolicyType.DIFFERENTIAL) + .withSchedulePolicy( + new SimpleSchedulePolicy() + .withScheduleRunFrequency(ScheduleRunType.WEEKLY) + .withScheduleRunDays(Arrays.asList(DayOfWeek.FRIDAY)) + .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))) + .withRetentionPolicy( + new SimpleRetentionPolicy() + .withRetentionDuration( + new RetentionDuration() + .withCount(8) + .withDurationType(RetentionDurationType.DAYS))), + new SubProtectionPolicy() + .withPolicyType(PolicyType.LOG) + .withSchedulePolicy(new LogSchedulePolicy().withScheduleFrequencyInMins(60)) + .withRetentionPolicy( + new SimpleRetentionPolicy() + .withRetentionDuration( + new RetentionDuration() + .withCount(7) + .withDurationType(RetentionDurationType.DAYS)))); vault = recoveryServicesManager.vaults() .define(vaultName) From 05ac6359bafc846f436c76066f5cb66f9f88d3c0 Mon Sep 17 00:00:00 2001 From: "Hong Li(MSFT)" Date: Tue, 13 Jun 2023 10:50:30 +0800 Subject: [PATCH 3/6] mgmt, recoveryservicesbackup, add live tests --- .../RecoveryServicesBackupManagerTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java index 07e91f1be3fe3..fe9380d15d74f 100644 --- a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java @@ -121,13 +121,13 @@ public void testCreateProtectionPolicy() { new SimpleSchedulePolicy() .withScheduleRunFrequency(ScheduleRunType.WEEKLY) .withScheduleRunDays(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY)) - .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))) + .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z")))) .withRetentionPolicy( new LongTermRetentionPolicy() .withWeeklySchedule( new WeeklyRetentionSchedule() .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY)) - .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))) + .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z"))) .withRetentionDuration( new RetentionDuration() .withCount(2) @@ -139,7 +139,7 @@ public void testCreateProtectionPolicy() { new WeeklyRetentionFormat() .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY)) .withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.SECOND))) - .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))) + .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z"))) .withRetentionDuration( new RetentionDuration() .withCount(1) @@ -152,7 +152,7 @@ public void testCreateProtectionPolicy() { new WeeklyRetentionFormat() .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY)) .withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.LAST))) - .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z"))) + .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z"))) .withRetentionDuration( new RetentionDuration() .withCount(1) @@ -163,7 +163,7 @@ public void testCreateProtectionPolicy() { new SimpleSchedulePolicy() .withScheduleRunFrequency(ScheduleRunType.WEEKLY) .withScheduleRunDays(Arrays.asList(DayOfWeek.FRIDAY)) - .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2018-01-24T10:00:00Z")))) + .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z")))) .withRetentionPolicy( new SimpleRetentionPolicy() .withRetentionDuration( From 521c1ec810bcda3fe37f4bacbb55b267dac7b698 Mon Sep 17 00:00:00 2001 From: "Hong Li(MSFT)" Date: Tue, 27 Jun 2023 17:58:33 +0800 Subject: [PATCH 4/6] mgmt, recoveryservicesbackup, add live tests --- .../azure-resourcemanager-recoveryservicesbackup/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml index 6f5df75c26652..f1cf1c757ebe5 100644 --- a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/pom.xml @@ -66,7 +66,7 @@ com.azure.resourcemanager azure-resourcemanager-resources - 2.27.0 + 2.28.0 test From 28229e541d6222afb721f1301884aaf59b721af7 Mon Sep 17 00:00:00 2001 From: "Hong Li(MSFT)" Date: Wed, 28 Jun 2023 11:01:36 +0800 Subject: [PATCH 5/6] mgmt, recoveryservicesbackup, add live tests --- .../RecoveryServicesBackupManagerTests.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java index fe9380d15d74f..2adace568de33 100644 --- a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java @@ -48,7 +48,9 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.time.Clock; import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.List; import java.util.Random; @@ -112,6 +114,10 @@ public void testCreateProtectionPolicy() { try { String vaultName = "vault" + randomPadding; String policyName = "policy" + randomPadding; + OffsetDateTime scheduleDateTime = OffsetDateTime.parse( + OffsetDateTime.now(Clock.systemUTC()) + .withNano(0).withMinute(0).withSecond(0) + .plusDays(1).format(DateTimeFormatter.ISO_INSTANT)); // @embedmeStart List lstSubProtectionPolicy = Arrays.asList( @@ -121,13 +127,13 @@ public void testCreateProtectionPolicy() { new SimpleSchedulePolicy() .withScheduleRunFrequency(ScheduleRunType.WEEKLY) .withScheduleRunDays(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY)) - .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z")))) + .withScheduleRunTimes(Arrays.asList(scheduleDateTime))) .withRetentionPolicy( new LongTermRetentionPolicy() .withWeeklySchedule( new WeeklyRetentionSchedule() .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY, DayOfWeek.TUESDAY)) - .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z"))) + .withRetentionTimes(Arrays.asList(scheduleDateTime)) .withRetentionDuration( new RetentionDuration() .withCount(2) @@ -139,7 +145,7 @@ public void testCreateProtectionPolicy() { new WeeklyRetentionFormat() .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY)) .withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.SECOND))) - .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z"))) + .withRetentionTimes(Arrays.asList(scheduleDateTime)) .withRetentionDuration( new RetentionDuration() .withCount(1) @@ -152,7 +158,7 @@ public void testCreateProtectionPolicy() { new WeeklyRetentionFormat() .withDaysOfTheWeek(Arrays.asList(DayOfWeek.SUNDAY)) .withWeeksOfTheMonth(Arrays.asList(WeekOfMonth.LAST))) - .withRetentionTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z"))) + .withRetentionTimes(Arrays.asList(scheduleDateTime)) .withRetentionDuration( new RetentionDuration() .withCount(1) @@ -163,7 +169,7 @@ public void testCreateProtectionPolicy() { new SimpleSchedulePolicy() .withScheduleRunFrequency(ScheduleRunType.WEEKLY) .withScheduleRunDays(Arrays.asList(DayOfWeek.FRIDAY)) - .withScheduleRunTimes(Arrays.asList(OffsetDateTime.parse("2023-06-13T10:00:00Z")))) + .withScheduleRunTimes(Arrays.asList(scheduleDateTime))) .withRetentionPolicy( new SimpleRetentionPolicy() .withRetentionDuration( From 59479013badfdea619dd382be8a550e02c6296c2 Mon Sep 17 00:00:00 2001 From: "Hong Li(MSFT)" Date: Wed, 28 Jun 2023 11:08:09 +0800 Subject: [PATCH 6/6] mgmt, recoveryservicesbackup, add live tests --- .../RecoveryServicesBackupManagerTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java index 2adace568de33..77238777039ab 100644 --- a/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java +++ b/sdk/recoveryservicesbackup/azure-resourcemanager-recoveryservicesbackup/src/test/java/com/azure/resourcemanager/recoveryservicesbackup/RecoveryServicesBackupManagerTests.java @@ -114,12 +114,13 @@ public void testCreateProtectionPolicy() { try { String vaultName = "vault" + randomPadding; String policyName = "policy" + randomPadding; + + // @embedmeStart OffsetDateTime scheduleDateTime = OffsetDateTime.parse( OffsetDateTime.now(Clock.systemUTC()) .withNano(0).withMinute(0).withSecond(0) .plusDays(1).format(DateTimeFormatter.ISO_INSTANT)); - // @embedmeStart List lstSubProtectionPolicy = Arrays.asList( new SubProtectionPolicy() .withPolicyType(PolicyType.FULL)