Skip to content

Adding SQL AutoDR support #1862

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 4 commits into from
Feb 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.43.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.0.44.0-prerelease\lib\net40\Microsoft.Azure.Management.Sql.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
Expand Down Expand Up @@ -239,6 +239,7 @@
<Compile Include="ScenarioTests\ElasticPoolCrudTests.cs" />
<Compile Include="ScenarioTests\AuditingTests.cs" />
<Compile Include="ScenarioTests\ServerCrudTests.cs" />
<Compile Include="ScenarioTests\ServerDisasterRecoveryConfigurationTests.cs" />
<Compile Include="ScenarioTests\ServerUpgradeTests.cs" />
<Compile Include="ScenarioTests\SqlEvnSetupHelper.cs" />
<Compile Include="ScenarioTests\SqlTestsBase.cs" />
Expand All @@ -253,6 +254,7 @@
<Compile Include="UnitTests\AzureSqlDatabaseIndexRecommendationAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlCapabilityAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlServerUpgradeAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlServerDisasterRecoveryConfigurationTests.cs" />
<Compile Include="UnitTests\AzureSqlServiceTierAdvisorAttributeTests.cs" />
<Compile Include="UnitTests\AzureSqlDatabaseBackupAttributeTests.cs" />
<Compile Include="Utilities\UnitTestHelper.cs" />
Expand Down Expand Up @@ -301,6 +303,12 @@
<None Include="ScenarioTests\ServerCrudTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ServerDisasterRecoveryConfigurationTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\ServerDisasterRecoveryConfigurationTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\DataMaskingTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -514,6 +522,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerCrudTests\TestServerUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerDisasterRecoveryConfigurationTests\TestServerDisasterRecoveryConfiguration.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ServerUpgradeTests\TestServerUpgradeWithUpgradeHint.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ----------------------------------------------------------------------------------
//
// 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 ServerDisasterRecoveryConfigurationTests : SqlTestsBase
{
[Fact]
[Trait(Category.AcceptanceType, Category.Sql)]
public void TestServerDisasterRecoveryConfiguration()
{
RunPowerShellTest("Test-ServerDisasterRecoveryConfiguration");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ----------------------------------------------------------------------------------
#
# 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
Tests CRUD on disaster recovery configuration
#>
function Test-ServerDisasterRecoveryConfiguration
{
Test-ServerDisasterRecoveryConfigurationInternal
}

<#
.SYNOPSIS
Tests creating 2 servers, a disaster recovery configuration, failing over, then deleting
#>
function Test-ServerDisasterRecoveryConfigurationInternal ($location1 = "North Europe", $location2 = "Southeast Asia")
{
# Setup
$rg1 = Create-ResourceGroupForTest $location1
$rg2 = Create-ResourceGroupForTest $location2

try
{
$server1 = Create-ServerForTest $rg1 "12.0" $location1
$server2 = Create-ServerForTest $rg2 "12.0" $location2
$failoverPolicy = "Off"
$sdrcName = "test-sdrc-alias"

# Create and validate
#
$sdrc = New-AzureRmSqlServerDisasterRecoveryConfiguration -ResourceGroupName $rg1.ResourceGroupName -ServerName $server1.ServerName -VirtualEndpointName $sdrcName -PartnerResourceGroupName $rg2.ResourceGroupName -PartnerServerName $server2.ServerName

GetSdrcCheck $rg1 $server1 $sdrcName $rg2 $server2 $failoverPolicy "Primary"
GetSdrcCheck $rg2 $server2 $sdrcName $rg1 $server1 $failoverPolicy "Secondary"

# Failover and check
#
Set-AzureRmSqlServerDisasterRecoveryConfiguration -ResourceGroupName $rg2.ResourceGroupName -ServerName $server2.ServerName -VirtualEndpointName $sdrcName -Failover

GetSdrcCheck $rg2 $server2 $sdrcName $rg1 $server1 $failoverPolicy "Primary"
GetSdrcCheck $rg1 $server1 $sdrcName $rg2 $server2 $failoverPolicy "Secondary"

# Fail back and check
#
Set-AzureRmSqlServerDisasterRecoveryConfiguration -ResourceGroupName $rg1.ResourceGroupName -ServerName $server1.ServerName -VirtualEndpointName $sdrcName -Failover

GetSdrcCheck $rg1 $server1 $sdrcName $rg2 $server2 $failoverPolicy "Primary"
GetSdrcCheck $rg2 $server2 $sdrcName $rg1 $server1 $failoverPolicy "Secondary"

# Delete
#
Remove-AzureRmSqlServerDisasterRecoveryConfiguration -ResourceGroupName $rg1.ResourceGroupName -ServerName $server1.ServerName -VirtualEndpointName $sdrcName -Force
}
finally
{
Remove-ResourceGroupForTest $rg1
Remove-ResourceGroupForTest $rg2
}
}

function GetSdrcCheck ($resourceGroup, $server, $virtualEndpointName, $partnerResourceGroup, $partnerServer, $failoverPolicy, $role)
{
$sdrcGet = Get-AzureRmSqlServerDisasterRecoveryConfiguration -ResourceGroupName $resourceGroup.ResourceGroupName -ServerName $server.ServerName -VirtualEndpointName $virtualEndpointName

Assert-AreEqual $resourceGroup.ResourceGroupName $sdrcGet.ResourceGroupName
Assert-AreEqual $server.ServerName $sdrcGet.ServerName
Assert-AreEqual $virtualEndpointName $sdrcGet.VirtualEndpointName
Assert-AreEqual $partnerServer.ServerName $sdrcGet.PartnerServerName
Assert-AreEqual $failoverPolicy $sdrcGet.FailoverPolicy
Assert-AreEqual $role $sdrcGet.Role
}
Loading