-
Notifications
You must be signed in to change notification settings - Fork 4k
Geo-Restore Instance database cmdlet #8493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8dd38f1
ba055a1
71e1653
bec0514
07bc402
faa9032
f147648
18406f3
7ac5840
2da0b9e
58a1726
e2e1e83
73f1a17
08218b3
2e98fab
a1068ad
c64b91c
4268bfc
5b35b43
b360b15
689b1de
cc4afac
ed685c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,5 +63,19 @@ public void TestRestoreManagedDatabase() | |
{ | ||
RunPowerShellTest("Test-RestoreManagedDatabase"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestGetManagedDatabaseGeoBackup() | ||
{ | ||
RunPowerShellTest("Test-GetManagedDatabaseGeoBackup"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestGeoRestoreManagedDatabase() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same comment. |
||
{ | ||
RunPowerShellTest("Test-GeoRestoreManagedDatabase"); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,4 +240,92 @@ function Test-RestoreManagedDatabase | |
{ | ||
Remove-ResourceGroupForTest $rg | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Tests Getting a managed database geo-redundant backups | ||
#> | ||
function Test-GetManagedDatabaseGeoBackup | ||
{ | ||
# Setup | ||
$rgName = "restore-rg" | ||
$managedInstanceName = "testbrinstance" | ||
$managedDatabaseName = "sourcedb" | ||
|
||
# Test Get using all parameters | ||
$gdb1 = Get-AzSqlInstanceDatabaseGeoBackup -ResourceGroupName $rgName -InstanceName $managedInstanceName -Name $managedDatabaseName | ||
Assert-NotNull $gdb1 | ||
Assert-AreEqual $managedDatabaseName $gdb1.Name | ||
|
||
# Test Get using ResourceGroupName and InstanceName | ||
$all = Get-AzSqlInstanceDatabaseGeoBackup -ResourceGroupName $rgName -InstanceName $managedInstanceName | ||
|
||
Assert-NotNull $all | ||
if($all.Count -le 1) | ||
{ | ||
throw "Should get more than 1 backup geo-redundant backups" | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Tests geo-restoring a managed database | ||
#> | ||
function Test-GeoRestoreManagedDatabase | ||
{ | ||
# Setup | ||
$rgName = "restore-rg" | ||
$managedInstanceName = "testbrinstance" | ||
$managedDatabaseName = "sourcedb" | ||
|
||
$targetRgName = "restore-rg" | ||
$targetInstanceName = "testbrinstance" | ||
try | ||
{ | ||
$sourceDbGeoBackup = Get-AzSqlInstanceDatabaseGeoBackup -ResourceGroupName $rgName -InstanceName $managedInstanceName -Name $managedDatabaseName | ||
|
||
Assert-NotNull $sourceDbGeoBackup | ||
|
||
$targetManagedDatabaseName1 = Get-ManagedDatabaseName | ||
$targetManagedDatabaseName2 = Get-ManagedDatabaseName | ||
$targetManagedDatabaseName3 = Get-ManagedDatabaseName | ||
$targetManagedDatabaseName4 = Get-ManagedDatabaseName | ||
|
||
# geo-restore managed database using resourceID | ||
$restoredDb1 = Restore-AzSqlInstanceDatabase -FromGeoBackup -ResourceId $sourceDbGeoBackup.RecoverableDatabaseId -TargetInstanceDatabaseName $targetManagedDatabaseName1 -TargetInstanceName $targetInstanceName -TargetResourceGroupName $targetRgName | ||
Assert-NotNull $restoredDb1 | ||
Assert-AreEqual $restoredDb1.Name $targetManagedDatabaseName1 | ||
Assert-AreEqual $restoredDb1.ResourceGroupName $targetRgName | ||
Assert-AreEqual $restoredDb1.ManagedInstanceName $targetInstanceName | ||
|
||
# geo-restore managed database using name, instance and resource group name | ||
$restoredDb2 = Restore-AzSqlInstanceDatabase -FromGeoBackup -ResourceGroupName $rgName -InstanceName $managedInstanceName -Name $managedDatabaseName -TargetInstanceDatabaseName $targetManagedDatabaseName2 -TargetInstanceName $targetInstanceName -TargetResourceGroupName $targetRgName | ||
Assert-NotNull $restoredDb2 | ||
Assert-AreEqual $restoredDb2.Name $targetManagedDatabaseName2 | ||
Assert-AreEqual $restoredDb2.ResourceGroupName $targetRgName | ||
Assert-AreEqual $restoredDb2.ManagedInstanceName $targetInstanceName | ||
|
||
# geo-restore managed database using GeoBackupObject | ||
$restoredDb3 = Restore-AzSqlInstanceDatabase -FromGeoBackup -GeoBackupObject $sourceDbGeoBackup -TargetInstanceDatabaseName $targetManagedDatabaseName3 -TargetInstanceName $targetInstanceName -TargetResourceGroupName $targetRgName | ||
Assert-NotNull $restoredDb3 | ||
Assert-AreEqual $restoredDb3.Name $targetManagedDatabaseName3 | ||
Assert-AreEqual $restoredDb3.ResourceGroupName $targetRgName | ||
Assert-AreEqual $restoredDb3.ManagedInstanceName $targetInstanceName | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add piping scenario test
Added |
||
# geo-restore managed database using piping | ||
$restoredDb4 = $sourceDbGeoBackup | Restore-AzSqlInstanceDatabase -FromGeoBackup -TargetInstanceDatabaseName $targetManagedDatabaseName4 -TargetInstanceName $targetInstanceName -TargetResourceGroupName $targetRgName | ||
Assert-NotNull $restoredDb4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you point me to where piping gets actually tested? |
||
Assert-AreEqual $restoredDb4.Name $targetManagedDatabaseName4 | ||
Assert-AreEqual $restoredDb4.ResourceGroupName $targetRgName | ||
Assert-AreEqual $restoredDb4.ManagedInstanceName $targetInstanceName | ||
|
||
} | ||
finally | ||
{ | ||
$restoredDb1 | Remove-AzSqlInstanceDatabase -Force | ||
$restoredDb2 | Remove-AzSqlInstanceDatabase -Force | ||
$restoredDb3 | Remove-AzSqlInstanceDatabase -Force | ||
$restoredDb4 | Remove-AzSqlInstanceDatabase -Force | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the skip reason only makes sense for LiveOnly category tests. Once recorded - the test time should't take long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case other person will do record test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the test recorded - it should't take long to playback - so you don't need to skip it. If a test skipped it's in fact disabled.