Skip to content

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

Merged
merged 23 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8dd38f1
Geo-Restore Instance Database cmdlet
lixiachena Feb 6, 2019
ba055a1
change help files
lixiachena Feb 6, 2019
71e1653
Update ManagedDatabaseCrudScenarioTests.cs
lixiachena Feb 6, 2019
bec0514
Merge branch 'master' into master
lixiachena Feb 8, 2019
07bc402
Update AzureSqlRecoverableManagedDatabaseCmdletBase.cs
lixiachena Feb 11, 2019
faa9032
Update md file and test fiels
lixiachena Feb 12, 2019
f147648
Added Example
lixiachena Feb 12, 2019
18406f3
Update Get-AzSqlInstanceDatabaseGeoBackup.md
lixiachena Feb 12, 2019
7ac5840
Update Get-AzSqlInstanceDatabaseGeoBackup.md
lixiachena Feb 12, 2019
2da0b9e
Regenerate restore-azsqlinstancedatabase.md
lixiachena Feb 14, 2019
58a1726
update md file
lixiachena Feb 14, 2019
e2e1e83
Update BreakingChangeIssues.csv
lixiachena Feb 15, 2019
73f1a17
Update Restore-AzSqlInstanceDatabase.md
lixiachena Feb 15, 2019
08218b3
Update ManagedDatabaseCrudScenarioTests.ps1
lixiachena Feb 15, 2019
2e98fab
Merge remote-tracking branch 'upstream/master'
lixiachena Feb 15, 2019
a1068ad
Merge branch 'master' into master
lixiachena Feb 19, 2019
c64b91c
Address comments
lixiachena Feb 19, 2019
4268bfc
Merge branch 'master' of https://github.com/lixiachena/azure-powershell
lixiachena Feb 19, 2019
5b35b43
Merge branch 'master' into master
lixiachena Feb 19, 2019
b360b15
address on comments
lixiachena Feb 20, 2019
689b1de
Fix helpmessage and change test server/db name
lixiachena Feb 20, 2019
cc4afac
Update ManagedDatabaseCrudScenarioTests.ps1
lixiachena Feb 20, 2019
ed685c1
Fix pb mode test errors
lixiachena Feb 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Sql/Sql.Test/ScenarioTests/ManagedDatabaseCrudScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,19 @@ public void TestRestoreManagedDatabase()
{
RunPowerShellTest("Test-RestoreManagedDatabase");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

public void TestGetManagedDatabaseGeoBackup()
{
RunPowerShellTest("Test-GetManagedDatabaseGeoBackup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGeoRestoreManagedDatabase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment

Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Up @@ -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

Copy link
Contributor

@vladimir-shcherbakov vladimir-shcherbakov Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add piping scenario test

$restoredDb4 = $sourceDbGeoBackup | Restore-AzSqlInstanceDatabase ...

Added

# geo-restore managed database using piping
$restoredDb4 = $sourceDbGeoBackup | Restore-AzSqlInstanceDatabase -FromGeoBackup -TargetInstanceDatabaseName $targetManagedDatabaseName4 -TargetInstanceName $targetInstanceName -TargetResourceGroupName $targetRgName
Assert-NotNull $restoredDb4
Copy link
Contributor

Choose a reason for hiding this comment

The 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
}
}
Loading