Skip to content

Commit 40e3fe8

Browse files
committed
Added CZR test case
added CRR DES support re-recorded failed test
1 parent 50c2db9 commit 40e3fe8

File tree

8 files changed

+3271
-5
lines changed

8 files changed

+3271
-5
lines changed

src/RecoveryServices/RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ Please contact Microsoft for further assistance.</value>
755755
<value>ResourceGuardMapping not found</value>
756756
</data>
757757
<data name="DisableWithRetainBackupNotCrititcal" xml:space="preserve">
758-
<value>Invalid parameter Token: Stop protection with retain backup data is not MUA protected</value>
758+
<value>Invalid parameter Token. Stop protection with retain backup data is not MUA protected</value>
759759
</data>
760760
<data name="CRRNotSupportedWIthCSR" xml:space="preserve">
761761
<value>Cross region restore is not supported along with cross subscription restore, please try passing either RestoreToSecondaryRegion or TargetSubscriptionId parameter but not both</value>

src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ public void TestAzureMonitorAlerts()
256256
$"Import-Module {_IaasVmtestModule.AsAbsoluteLocation()}",
257257
"Test-AzureMonitorAlerts"
258258
);
259-
}
259+
}
260+
261+
[Fact]
262+
[Trait(Category.AcceptanceType, Category.CheckIn)]
263+
[Trait(TestConstants.Workload, TestConstants.AzureVM)]
264+
public void TestAzureCrossZonalRestore()
265+
{
266+
TestRunner.RunTestScript(
267+
$"Import-Module {_IaasVmcommonModule.AsAbsoluteLocation()}",
268+
$"Import-Module {_IaasVmtestModule.AsAbsoluteLocation()}",
269+
"Test-AzureCrossZonalRestore"
270+
);
271+
}
260272
}
261273
}

src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
function Test-AzureCrossZonalRestore
16+
{
17+
$location = "eastus"
18+
$resourceGroupName = "hiagarg"
19+
$vaultName = "hiaga-zrs-vault"
20+
$vmName = "VM;iaasvmcontainerv2;hiagarg;hiagaNZP"
21+
$saName = "hiagaeussa"
22+
$targetVMName = "czr-pstest-vm"
23+
$targetVNetName = "hiagaNZPVNet"
24+
$targetVNetRG = "hiagarg"
25+
$targetSubnetName = "custom"
26+
27+
try
28+
{
29+
# Setup
30+
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $resourceGroupName -Name $vaultName
31+
$item = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM `
32+
-VaultId $vault.ID -Name $vmName
33+
34+
$rp = Get-AzRecoveryServicesBackupRecoveryPoint -Item $item[0] `
35+
-StartDate (Get-Date).AddDays(-30).ToUniversalTime() -EndDate (Get-Date).AddDays(0).ToUniversalTime() `
36+
-VaultId $vault.ID -Tier VaultStandard
37+
38+
$restoreJobCZR = Restore-AzRecoveryServicesBackupItem -VaultId $vault.ID -VaultLocation $vault.Location `
39+
-RecoveryPoint $rp[0] -StorageAccountName $saName -StorageAccountResourceGroupName $vault.ResourceGroupName -TargetResourceGroupName $vault.ResourceGroupName -TargetVMName $targetVMName -TargetVNetName $targetVNetName -TargetVNetResourceGroup $targetVNetRG -TargetSubnetName $targetSubnetName -TargetZoneNumber 2 | Wait-AzRecoveryServicesBackupJob -VaultId $vault.ID
40+
41+
Assert-True { $restoreJobCZR.Status -eq "Completed" }
42+
}
43+
finally
44+
{
45+
Delete-VM $resourceGroupName $targetVMName
46+
}
47+
}
48+
1549
function Test-AzureMonitorAlerts
1650
{
1751
$location = "centraluseuap"

src/RecoveryServices/RecoveryServices.Backup.Test/SessionRecords/Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests/TestAzureCrossZonalRestore.json

Lines changed: 3219 additions & 0 deletions
Large diffs are not rendered by default.

src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Jobs/WaitAzureRmRecoveryServicesBackupJob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public override void ExecuteCmdlet()
142142
// sleep for 30 seconds before checking again
143143
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
144144

145-
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0)
145+
if (String.Compare(testMode, "Record", StringComparison.OrdinalIgnoreCase) == 0 || TestMockSupport.RunningMocked)
146146
{
147147
Thread.Sleep(30000);
148148
}

src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Restore/RestoreAzureRMRecoveryServicesBackupItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public override void ExecuteCmdlet()
416416

417417
ServiceClientModel.BackupResourceEncryptionConfigExtendedResource vaultEncryptionSettings = ServiceClientAdapter.GetVaultEncryptionConfig(resourceGroupName, vaultName);
418418

419-
if ((vaultEncryptionSettings.Properties.EncryptionAtRestType == "CustomerManaged") && rp.IsManagedVirtualMachine && !(rp.EncryptionEnabled) && !(RestoreToSecondaryRegion.IsPresent))
419+
if ((vaultEncryptionSettings.Properties.EncryptionAtRestType == "CustomerManaged") && rp.IsManagedVirtualMachine && !(rp.EncryptionEnabled))
420420
{
421421
providerParameters.Add(RestoreVMBackupItemParams.DiskEncryptionSetId, DiskEncryptionSetId);
422422
}

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added support for passing DiskEncryptionSetId for Cross region restore
2122
* Fixed the pagination bug in `Get-AzRecoveryServicesAsrProtectableItem` for the V2ARCM scenario.
2223
* Fixed `IncludeDiskId` property for `New-ASRReplicationProtectedItem` cmdlet of H2A
2324

src/RecoveryServices/RecoveryServices/help/Restore-AzRecoveryServicesBackupItem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ $restoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -Rehydr
303303

304304
Here we filter the recovery points present in the VaultArchive tier and trigger a restore with rehydration priority and rehydration duration.
305305

306-
### Example 10: CZR restore example
306+
### Example 10: Cross zonal restore for non-ZonePinned VM in a ZRS vault
307307

308308
```powershell
309309
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"

0 commit comments

Comments
 (0)