Skip to content

Commit

Permalink
Merge pull request #2 from caln-microsoft/backup
Browse files Browse the repository at this point in the history
Backup
  • Loading branch information
caln-microsoft committed Jun 19, 2015
2 parents 72858ce + 50cd60d commit 9718df2
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<Reference Include="Hyak.Common">
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.29.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
</Reference>
Expand All @@ -64,9 +67,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.18.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.28.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down Expand Up @@ -150,11 +150,15 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScenarioTests\DatabaseActivationTests.cs" />
<Compile Include="ScenarioTests\DatabaseBackupTests.cs" />
<Compile Include="ScenarioTests\DatabaseCrudTests.cs" />
<Compile Include="ScenarioTests\DataMaskingTests.cs" />
<None Include="ScenarioTests\DatabaseActivationTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DatabaseBackupTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\RecommendedElasticPoolTests.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -175,6 +179,7 @@
<Compile Include="UnitTests\AzureSqlDatabaseServerFirewallRuleAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlDatabaseServerAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlServerUpgradeAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlDatabaseBackupAttributeTests.cs" />
<Compile Include="Utilities\UnitTestHelper.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
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");
}
}
}
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
}
}
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);
}
}
}
2 changes: 1 addition & 1 deletion src/ResourceManager/Sql/Commands.Sql.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<package id="Microsoft.Azure.Common.Authentication" version="1.0.26-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Sql" version="0.29.0-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="0.18.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Sql" version="0.28.0-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5571.32271-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.0.5571.32271-prerelease" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
Expand Down
11 changes: 8 additions & 3 deletions src/ResourceManager/Sql/Commands.Sql/Commands.Sql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="Database Backup\Cmdlet\AzureSqlDatabaseRestorePointCmdletBase.cs" />
<Compile Include="Database Backup\Cmdlet\GetAzureSqlDatabaseRestorePoints.cs" />
<Compile Include="Database Backup\Model\AzureSqlDatabaseRestorePointModel.cs" />
<Compile Include="Database Backup\Services\AzureSqlDatabaseBackupAdapter.cs" />
<Compile Include="Database Backup\Services\AzureSqlDatabaseBackupCommunicator.cs" />
<Compile Include="Database Activation\Cmdlet\AzureSqlDatabaseActivationCmdletBase.cs" />
<Compile Include="Database Activation\Cmdlet\ResumeAzureSqlDatabase.cs" />
<Compile Include="Database Activation\Cmdlet\SuspendAzureSqlDatabase.cs" />
Expand Down Expand Up @@ -192,6 +197,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Hyak.Common.1.0.2\lib\net45\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.29.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
Expand All @@ -204,9 +212,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.28.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion src/ResourceManager/Sql/Commands.Sql/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Microsoft.Azure.Common.Authentication" version="1.0.26-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Sql" version="0.28.0-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Sql" version="0.29.0-prerelease" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
Expand Down

0 comments on commit 9718df2

Please sign in to comment.