Skip to content

Commit

Permalink
Added test case and final fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiaga committed Jun 26, 2023
1 parent 503197c commit d76f5bc
Show file tree
Hide file tree
Showing 10 changed files with 2,386 additions and 16 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,13 @@ Please contact Microsoft for further assistance.</value>
<data name="UnsupportedCZRForCRRVaultToPrimaryRegion" xml:space="preserve">
<value>For triggering cross zonal restore for CRR enabled (RA-GRS) vaults, please ensure that the restore is triggered for secondary region. Please remove TargetZone parameter or try a valid scenario.</value>
</data>
<data name="CantRemoveAndRetainRPsSimultaneously" xml:space="preserve">
<data name="CantRemoveAndRetainRPsSimultaneously" xml:space="preserve">
<value>RemoveRecoveryPoints and RetainRecoveryPointsAsPerPolicy parameters can't be used simultaneously.</value>
</data>

</root>
<data name="VaultLocationRequired" xml:space="preserve">
<value>VaultLocation can't be empty for fetching jobs from secondary region.</value>
</data>
<data name="VaultLocationRequiredForCRR" xml:space="preserve">
<value>VaultLocation can't be empty for cross region restore.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,18 @@ public void TestAzureVmWorkloadCrossSubscriptionRestore()
"Test-AzureVmWorkloadCrossSubscriptionRestore"
);
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(TestConstants.Workload, TestConstants.AzureVmWorkload)]
public void TestAzureVmWorkloadCrossRegionRestore()
{

TestRunner.RunTestScript(
$"Import-Module {_AzureWorkloadcommonModule.AsAbsoluteLocation()}",
$"Import-Module {_AzureWorkloadtestModule.AsAbsoluteLocation()}",
"Test-AzureVmWorkloadCrossRegionRestore"
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,50 @@ $resourceIdForFileDB = $resourceId
$policyName = "HourlyLogBackup"
$instanceName = "sqlinstance;mssqlserver"

function Test-AzureVmWorkloadCrossRegionRestore
{
$resourceGroupName = "hiagarg"
$vaultId = "/subscriptions/38304e13-357e-405e-9e9a-220351dcce8c/resourceGroups/hiagarg/providers/Microsoft.RecoveryServices/vaults/hiagaVault"
$sourceDBName = "model"
$location = "centraluseuap"
$recoveryPointId = "164200650492022" # $rp[1].RecoveryPointId

$targetResourceGroup = "clitest-rg-donotuse"
$targetVault = "clitest-vault-secondary-donotuse"
$targetDBName = "model_restored_6_26_2023_1751"
$overwrite = "Yes"

try
{
$secvault = Get-AzRecoveryServicesVault -ResourceGroupName $targetResourceGroup -Name $targetVault
$item = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureWorkload -WorkloadType MSSQL -VaultId $vaultId -UseSecondaryRegion | Where-Object { $_.Name -match "model" }
$rp = Get-AzRecoveryServicesBackupRecoveryPoint -Item $item[0] -VaultId $vaultId -UseSecondaryRegion -RecoveryPointId $recoveryPointId

$seccontainer = Get-AzRecoveryServicesBackupContainer -ContainerType AzureVMAppContainer -VaultId $secvault.ID
$secitem = Get-AzRecoveryServicesBackupItem -Container $seccontainer -VaultId $secvault.ID -WorkloadType MSSQL

$targetInstance = Get-AzRecoveryServicesBackupProtectableItem -WorkloadType MSSQL -ItemType SQLInstance -VaultId $secvault.ID

$workloadConfig = Get-AzRecoveryServicesBackupWorkloadRecoveryConfig -RecoveryPoint $rp[0] -TargetItem $targetInstance -AlternateWorkloadRestore -VaultId $vaultId -TargetContainer $seccontainer[0] -UseSecondaryRegion

$workloadConfig.RestoredDBName = $targetDBName
$workloadConfig.OverwriteWLIfpresent = $overwrite

$crrJob = Restore-AzRecoveryServicesBackupItem -WLRecoveryConfig $workloadConfig -VaultId $vaultID -RestoreToSecondaryRegion -VaultLocation $location

while($crrJob.Status -eq "InProgress"){
Start-TestSleep -Seconds 12
$crrJob = Get-AzRecoveryServicesBackupJob -VaultId $vaultId -UseSecondaryRegion -JobId $crrJob.JobId -VaultLocation $location
}

Assert-True {$crrJob.Status -eq "Completed"}
}
finally
{
# no cleanup
}
}

function Test-AzureVmWorkloadCrossSubscriptionRestore
{
$resourceGroupName = "sqlcontainer-pstest-rg"
Expand Down Expand Up @@ -678,4 +722,4 @@ function Test-AzureVmWorkloadRestoreAsFiles

Assert-True { $restorejob3.Status -eq "Completed" }

}
}
Loading

0 comments on commit d76f5bc

Please sign in to comment.