Skip to content

Commit 9718df2

Browse files
Merge pull request #2 from caln-microsoft/backup
Backup
2 parents 72858ce + 50cd60d commit 9718df2

File tree

7 files changed

+190
-8
lines changed

7 files changed

+190
-8
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
<Reference Include="Hyak.Common">
4848
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
4949
</Reference>
50+
<Reference Include="Microsoft.Azure.Management.Sql">
51+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.29.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
52+
</Reference>
5053
<Reference Include="Microsoft.Azure.Common">
5154
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
5255
</Reference>
@@ -64,9 +67,6 @@
6467
<SpecificVersion>False</SpecificVersion>
6568
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
6669
</Reference>
67-
<Reference Include="Microsoft.Azure.Management.Sql">
68-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.28.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
69-
</Reference>
7070
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7171
<SpecificVersion>False</SpecificVersion>
7272
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
@@ -150,11 +150,15 @@
150150
<DependentUpon>Resources.resx</DependentUpon>
151151
</Compile>
152152
<Compile Include="ScenarioTests\DatabaseActivationTests.cs" />
153+
<Compile Include="ScenarioTests\DatabaseBackupTests.cs" />
153154
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
154155
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
155156
<None Include="ScenarioTests\DatabaseActivationTests.ps1">
156157
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
157158
</None>
159+
<None Include="ScenarioTests\DatabaseBackupTests.ps1">
160+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
161+
</None>
158162
<None Include="ScenarioTests\RecommendedElasticPoolTests.ps1">
159163
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
160164
</None>
@@ -175,6 +179,7 @@
175179
<Compile Include="UnitTests\AzureSqlDatabaseServerFirewallRuleAttributeTests.cs" />
176180
<Compile Include="UnitTests\AzureSqlDatabaseServerAttributeTests.cs" />
177181
<Compile Include="UnitTests\AzureSqlServerUpgradeAttributeTests.cs" />
182+
<Compile Include="UnitTests\AzureSqlDatabaseBackupAttributeTests.cs" />
178183
<Compile Include="Utilities\UnitTestHelper.cs" />
179184
</ItemGroup>
180185
<ItemGroup>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
16+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
17+
using Xunit;
18+
19+
namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
20+
{
21+
public class DatabaseBackupTests : SqlTestsBase
22+
{
23+
[Fact]
24+
[Trait(Category.Sql, Category.CheckIn)]
25+
public void TestDatabasePauseResume()
26+
{
27+
RunPowerShellTest("Test-ListDatabaseRestorePoints");
28+
}
29+
30+
[Fact]
31+
[Trait(Category.Sql, Category.CheckIn)]
32+
public void TestDatabasePauseResumePiped()
33+
{
34+
RunPowerShellTest("Test-ListDatabaseRestorePointsPiped");
35+
}
36+
}
37+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Test getting restore points from databases.
18+
#>
19+
function Test-ListDatabaseRestorePoints
20+
{
21+
# Setup
22+
$location = "Japan East"
23+
$serverVersion = "12.0";
24+
$rg = Create-ResourceGroupForTest
25+
26+
try
27+
{
28+
$server = Create-ServerForTest $rg $serverVersion $location
29+
30+
# Create data warehouse database with all parameters.
31+
$databaseName = Get-DatabaseName
32+
$dwdb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
33+
-Edition DataWarehouse -RequestedServiceObjectiveName DW100
34+
35+
$databaseName = Get-DatabaseName
36+
$standarddb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
37+
-Edition Standard -RequestedServiceObjectiveName S0
38+
39+
# Get restore points from data warehouse database. There should be none.
40+
$restorePoints = Get-AzureSqlDatabaseRestorePoints -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName
41+
Assert-True $restorePoints.IsEmpty
42+
43+
# Get restore points from standard database.There should be 1.
44+
$restorePoints = Resume-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $standarddb.DatabaseName
45+
$restorePoint = $restorePoints[0]
46+
Assert-AreEqual $restorePoint.RestorePointType Continuous
47+
Assert-Null $restorePoint.RestorePointCreationDate
48+
Assert-NotNull $restorePoint.EarliestRestoreDate
49+
Assert-AreEqual $restorePoint.SizeBytes 0
50+
}
51+
finally
52+
{
53+
Remove-ResourceGroupForTest $rg
54+
}
55+
}
56+
57+
<#
58+
.SYNOPSIS
59+
Test getting restore points from databases via piped cmdlets.
60+
#>
61+
function Test-ListDatabaseRestorePointsPiped
62+
{
63+
# Setup
64+
$location = "Japan East"
65+
$serverVersion = "12.0";
66+
$rg = Create-ResourceGroupForTest
67+
68+
try
69+
{
70+
$server = Create-ServerForTest $rg $serverVersion $location
71+
72+
# Create data warehouse database with all parameters.
73+
$databaseName = Get-DatabaseName
74+
$dwdb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
75+
-Edition DataWarehouse -RequestedServiceObjectiveName DW100
76+
77+
$databaseName = Get-DatabaseName
78+
$standarddb = New-AzureSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
79+
-Edition Standard -RequestedServiceObjectiveName S0
80+
81+
# Get restore points from data warehouse database.
82+
Assert-True $restorePoints.IsEmpty
83+
84+
# Get restore points from standard database.
85+
$restorePoints = $standarddb | Resume-AzureSqlDatabase
86+
$restorePoint = $restorePoints[0]
87+
Assert-AreEqual $restorePoint.RestorePointType Continuous
88+
Assert-Null $restorePoint.RestorePointCreationDate
89+
Assert-NotNull $restorePoint.EarliestRestoreDate
90+
Assert-AreEqual $restorePoint.SizeBytes 0
91+
}
92+
finally
93+
{
94+
Remove-ResourceGroupForTest $rg
95+
}
96+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Management.Automation;
17+
18+
using Microsoft.Azure.Commands.Sql.Backup.Cmdlet;
19+
using Microsoft.Azure.Commands.Sql.Test.Utilities;
20+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
21+
using Xunit;
22+
23+
namespace Microsoft.Azure.Commands.Sql.Test.UnitTests
24+
{
25+
public class AzureSqlDatabaseBackupAttributeTests
26+
{
27+
[Fact]
28+
[Trait(Category.Sql, Category.CheckIn)]
29+
public void GetAzureSqlDatabaseRestorePointsAttributes()
30+
{
31+
Type type = typeof(GetAzureSqlDatabaseRestorePoints);
32+
UnitTestHelper.CheckCmdletModifiesData(type, supportsShouldProcess: false);
33+
UnitTestHelper.CheckConfirmImpact(type, ConfirmImpact.None);
34+
35+
UnitTestHelper.CheckCmdletParameterAttributes(type, "ServerName", isMandatory: true, valueFromPipelineByName: true);
36+
UnitTestHelper.CheckCmdletParameterAttributes(type, "DatabaseName", isMandatory: true, valueFromPipelineByName: true);
37+
}
38+
}
39+
}

src/ResourceManager/Sql/Commands.Sql.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<package id="Microsoft.Azure.Common.Authentication" version="1.0.26-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
8+
<package id="Microsoft.Azure.Management.Sql" version="0.29.0-prerelease" targetFramework="net45" />
89
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
910
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
10-
<package id="Microsoft.Azure.Management.Sql" version="0.28.0-prerelease" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />
1313
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />

src/ResourceManager/Sql/Commands.Sql/Commands.Sql.csproj

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@
5151
<Prefer32Bit>false</Prefer32Bit>
5252
</PropertyGroup>
5353
<ItemGroup>
54+
<Compile Include="Database Backup\Cmdlet\AzureSqlDatabaseRestorePointCmdletBase.cs" />
55+
<Compile Include="Database Backup\Cmdlet\GetAzureSqlDatabaseRestorePoints.cs" />
56+
<Compile Include="Database Backup\Model\AzureSqlDatabaseRestorePointModel.cs" />
57+
<Compile Include="Database Backup\Services\AzureSqlDatabaseBackupAdapter.cs" />
58+
<Compile Include="Database Backup\Services\AzureSqlDatabaseBackupCommunicator.cs" />
5459
<Compile Include="Database Activation\Cmdlet\AzureSqlDatabaseActivationCmdletBase.cs" />
5560
<Compile Include="Database Activation\Cmdlet\ResumeAzureSqlDatabase.cs" />
5661
<Compile Include="Database Activation\Cmdlet\SuspendAzureSqlDatabase.cs" />
@@ -192,6 +197,9 @@
192197
<SpecificVersion>False</SpecificVersion>
193198
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
194199
</Reference>
200+
<Reference Include="Microsoft.Azure.Management.Sql">
201+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.29.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
202+
</Reference>
195203
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
196204
<SpecificVersion>False</SpecificVersion>
197205
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
@@ -204,9 +212,6 @@
204212
<SpecificVersion>False</SpecificVersion>
205213
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
206214
</Reference>
207-
<Reference Include="Microsoft.Azure.Management.Sql">
208-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.28.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
209-
</Reference>
210215
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
211216
<SpecificVersion>False</SpecificVersion>
212217
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>

src/ResourceManager/Sql/Commands.Sql/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<package id="Microsoft.Azure.Common.Authentication" version="1.0.26-preview" targetFramework="net45" />
66
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
8-
<package id="Microsoft.Azure.Management.Sql" version="0.28.0-prerelease" targetFramework="net45" />
8+
<package id="Microsoft.Azure.Management.Sql" version="0.29.0-prerelease" targetFramework="net45" />
99
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
1010
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1111
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />

0 commit comments

Comments
 (0)