forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from caln-microsoft/backup
Backup
- Loading branch information
Showing
7 changed files
with
190 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Commands.ScenarioTest.SqlTests; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Xunit; | ||
|
||
namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests | ||
{ | ||
public class DatabaseBackupTests : SqlTestsBase | ||
{ | ||
[Fact] | ||
[Trait(Category.Sql, Category.CheckIn)] | ||
public void TestDatabasePauseResume() | ||
{ | ||
RunPowerShellTest("Test-ListDatabaseRestorePoints"); | ||
} | ||
|
||
[Fact] | ||
[Trait(Category.Sql, Category.CheckIn)] | ||
public void TestDatabasePauseResumePiped() | ||
{ | ||
RunPowerShellTest("Test-ListDatabaseRestorePointsPiped"); | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# Copyright Microsoft Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
<# | ||
.SYNOPSIS | ||
Test getting restore points from databases. | ||
#> | ||
function Test-ListDatabaseRestorePoints | ||
{ | ||
# Setup | ||
$location = "Japan East" | ||
$serverVersion = "12.0"; | ||
$rg = Create-ResourceGroupForTest | ||
|
||
try | ||
{ | ||
$server = Create-ServerForTest $rg $serverVersion $location | ||
|
||
# Create data warehouse database with all parameters. | ||
$databaseName = Get-DatabaseName | ||
$dwdb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName ` | ||
-Edition DataWarehouse -RequestedServiceObjectiveName DW100 | ||
|
||
$databaseName = Get-DatabaseName | ||
$standarddb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName ` | ||
-Edition Standard -RequestedServiceObjectiveName S0 | ||
|
||
# Get restore points from data warehouse database. There should be none. | ||
$restorePoints = Get-AzureSqlDatabaseRestorePoints -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName | ||
Assert-True $restorePoints.IsEmpty | ||
|
||
# Get restore points from standard database.There should be 1. | ||
$restorePoints = Resume-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $standarddb.DatabaseName | ||
$restorePoint = $restorePoints[0] | ||
Assert-AreEqual $restorePoint.RestorePointType Continuous | ||
Assert-Null $restorePoint.RestorePointCreationDate | ||
Assert-NotNull $restorePoint.EarliestRestoreDate | ||
Assert-AreEqual $restorePoint.SizeBytes 0 | ||
} | ||
finally | ||
{ | ||
Remove-ResourceGroupForTest $rg | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Test getting restore points from databases via piped cmdlets. | ||
#> | ||
function Test-ListDatabaseRestorePointsPiped | ||
{ | ||
# Setup | ||
$location = "Japan East" | ||
$serverVersion = "12.0"; | ||
$rg = Create-ResourceGroupForTest | ||
|
||
try | ||
{ | ||
$server = Create-ServerForTest $rg $serverVersion $location | ||
|
||
# Create data warehouse database with all parameters. | ||
$databaseName = Get-DatabaseName | ||
$dwdb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName ` | ||
-Edition DataWarehouse -RequestedServiceObjectiveName DW100 | ||
|
||
$databaseName = Get-DatabaseName | ||
$standarddb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName ` | ||
-Edition Standard -RequestedServiceObjectiveName S0 | ||
|
||
# Get restore points from data warehouse database. | ||
Assert-True $restorePoints.IsEmpty | ||
|
||
# Get restore points from standard database. | ||
$restorePoints = $standarddb | Resume-AzureSqlDatabase | ||
$restorePoint = $restorePoints[0] | ||
Assert-AreEqual $restorePoint.RestorePointType Continuous | ||
Assert-Null $restorePoint.RestorePointCreationDate | ||
Assert-NotNull $restorePoint.EarliestRestoreDate | ||
Assert-AreEqual $restorePoint.SizeBytes 0 | ||
} | ||
finally | ||
{ | ||
Remove-ResourceGroupForTest $rg | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/ResourceManager/Sql/Commands.Sql.Test/UnitTests/AzureSqlDatabaseBackupAttributeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Management.Automation; | ||
|
||
using Microsoft.Azure.Commands.Sql.Backup.Cmdlet; | ||
using Microsoft.Azure.Commands.Sql.Test.Utilities; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Xunit; | ||
|
||
namespace Microsoft.Azure.Commands.Sql.Test.UnitTests | ||
{ | ||
public class AzureSqlDatabaseBackupAttributeTests | ||
{ | ||
[Fact] | ||
[Trait(Category.Sql, Category.CheckIn)] | ||
public void GetAzureSqlDatabaseRestorePointsAttributes() | ||
{ | ||
Type type = typeof(GetAzureSqlDatabaseRestorePoints); | ||
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false); | ||
UnitTestHelper.CheckConfirmImpact(type, ConfirmImpact.None); | ||
|
||
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true); | ||
UnitTestHelper.CheckCmdletParameterAttributes(type, "DatabaseName", isMandatory: true, valueFromPipelineByName: true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters