Skip to content

Added zone redundant parameter to powershell commands. #4877

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 15 commits into from
Nov 1, 2017
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
5 changes: 5 additions & 0 deletions src/ResourceManager/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
* Adding support for list and cancel the asynchronous updateslo operation on the database
- update existing cmdlet Get-AzureRmSqlDatabaseActivity to return DB updateslo operation status.
- add new cmdlet Stop-AzureRmSqlDatabaseActivity for cancel the asynchronous updateslo operation on the database.
* Adding support for Zone Redundancy for databases and elastic pools
- Adding ZoneRedundant switch parameter to New-AzureRmSqlDatabase
- Adding ZoneRedundant switch parameter to Set-AzureRmSqlDatabase
- Adding ZoneRedundant switch parameter to New-AzureRmSqlElasticPool
- Adding ZoneRedundant switch parameter to Set-AzureRmSqlElasticPool
* Adding support for Server DNS Aliases
- Adding Get-AzureRmSqlServerDnsAlias cmdlet which gets server dns aliases by server and alias name or a list of server dns aliases for an azure Sql Server.
- Adding New-AzureRmSqlServerDnsAlias cmdlet which creates new server dns alias for a given Azure Sql server
Expand Down
21 changes: 21 additions & 0 deletions src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -656,15 +656,27 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreateWithSampleName.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreateWithZoneRedundancy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseGet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseGetWithZoneRedundancy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseRemove.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdateWithZoneRedundancy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdateWithZoneRedundancyNotSpecified.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests\TestCreateDatabaseCopy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -746,15 +758,24 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreateWithZoneRedundancy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolGet.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolGetWithZoneRedundancy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolRemove.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolUpdateWithZoneRedundancy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.FailoverGroupTests\TestCreateFailoverGroup_AutomaticPolicy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,48 @@ public void TestDatabaseCreateWithSampleName()
RunPowerShellTest("Test-CreateDatabaseWithSampleName");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseCreateWithZoneRedundancy()
{
RunPowerShellTest("Test-CreateDatabaseWithZoneRedundancy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseUpdate()
{
RunPowerShellTest("Test-UpdateDatabase");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseUpdateWithZoneRedundancy()
{
RunPowerShellTest("Test-UpdateDatabaseWithZoneRedundant");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseUpdateWithZoneRedundancyNotSpecified()
{
RunPowerShellTest("Test-UpdateDatabaseWithZoneRedundantNotSpecified");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseGet()
{
RunPowerShellTest("Test-GetDatabase");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseGetWithZoneRedundancy()
{
RunPowerShellTest("Test-GetDatabaseWithZoneRedundancy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseRemove()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ function Test-CreateDatabaseInternal ($location = "westcentralus")
function Test-CreateDatabaseWithSampleName
{
# Setup
$location = "westcentralus"
$rg = Create-ResourceGroupForTest
try
{
$server = Create-ServerForTest $rg
$server = Create-ServerForTest $rg $location

# Create with samplename
$databaseName = Get-DatabaseName
Expand All @@ -128,6 +129,52 @@ function Test-CreateDatabaseWithSampleName
}
}

<#
.SYNOPSIS
Tests creating a database with zone redundancy.
#>
function Test-CreateDatabaseWithZoneRedundancy
{
# Setup
$location = "eastus2"
$rg = Create-ResourceGroupForTest $location
try
{
$server = Create-ServerForTest $rg $location

# Create database with no zone redundancy set
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-DatabaseName $databaseName -Edition Premium
Assert-AreEqual $db.DatabaseName $databaseName
Assert-NotNull $db.Edition
Assert-NotNull $db.ZoneRedundant
Assert-AreEqual "false" $db.ZoneRedundant

# Create database with zone redundancy true
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-DatabaseName $databaseName -Edition Premium -ZoneRedundant
Assert-AreEqual $db.DatabaseName $databaseName
Assert-NotNull $db.Edition
Assert-NotNull $db.ZoneRedundant
Assert-AreEqual "true" $db.ZoneRedundant

# Create database with zone redundancy false
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-DatabaseName $databaseName -Edition Premium -ZoneRedundant:$false
Assert-AreEqual $db.DatabaseName $databaseName
Assert-NotNull $db.Edition
Assert-NotNull $db.ZoneRedundant
Assert-AreEqual "false" $db.ZoneRedundant
}
finally
{
Remove-ResourceGroupForTest $rg
}
}

<#
.SYNOPSIS
Tests updating a database
Expand Down Expand Up @@ -200,6 +247,88 @@ function Test-UpdateDatabaseInternal ($location = "westcentralus")
}
}

<#
.SYNOPSIS
Tests updating a database with zone redundancy
#>
function Test-UpdateDatabaseWithZoneRedundant ()
{
# Setup
$location = "eastus2"
$rg = Create-ResourceGroupForTest $location
$server = Create-ServerForTest $rg $location

$databaseName = Get-DatabaseName
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
-Edition Premium
Assert-AreEqual $db1.DatabaseName $databaseName
Assert-NotNull $db1.ZoneRedundant
Assert-AreEqual "false" $db1.ZoneRedundant

$databaseName = Get-DatabaseName
$db2 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
-Edition Premium -ZoneRedundant
Assert-AreEqual $db2.DatabaseName $databaseName
Assert-NotNull $db2.ZoneRedundant
Assert-AreEqual "true" $db2.ZoneRedundant

try
{
# Alter database with zone redundancy to true
$sdb1 = Set-AzureRmSqlDatabase -ResourceGroupName $db1.ResourceGroupName -ServerName $db1.ServerName -DatabaseName $db1.DatabaseName `
-ZoneRedundant
Assert-AreEqual $sdb1.DatabaseName $db1.DatabaseName
Assert-NotNull $sdb1.ZoneRedundant
Assert-AreEqual "true" $sdb1.ZoneRedundant

# Alter database with zone redundancy to false
$sdb2 = Set-AzureRmSqlDatabase -ResourceGroupName $db2.ResourceGroupName -ServerName $db2.ServerName -DatabaseName $db2.DatabaseName `
-ZoneRedundant:$false
Assert-AreEqual $sdb2.DatabaseName $db2.DatabaseName
Assert-NotNull $sdb2.ZoneRedundant
Assert-AreEqual "false" $sdb2.ZoneRedundant
}
finally
{
Remove-ResourceGroupForTest $rg
}
}

<#
.SYNOPSIS
Tests updating a database with zone redundancy not specified
#>
function Test-UpdateDatabaseWithZoneRedundantNotSpecified ()
{
# Setup
$location = "eastus2"
$rg = Create-ResourceGroupForTest $location
$server = Create-ServerForTest $rg $location

$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
-Edition Premium -ZoneRedundant
Assert-AreEqual $db.DatabaseName $databaseName
Assert-NotNull $db.ZoneRedundant
Assert-AreEqual "true" $db.ZoneRedundant

try
{
# Alter database with no zone redundancy set
$db1 = Set-AzureRmSqlDatabase -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName `
-Tags @{"tag_key"="tag_new_value2"}
Assert-AreEqual $db1.DatabaseName $db.DatabaseName
Assert-AreEqual True $db1.Tags.ContainsKey("tag_key")
Assert-AreEqual "tag_new_value2" $db1.Tags["tag_key"]
Assert-NotNull $db1.ZoneRedundant
Assert-AreEqual "true" $db1.ZoneRedundant
}
finally
{
Remove-ResourceGroupForTest $rg
}
}


<#
.SYNOPSIS
Expand Down Expand Up @@ -269,6 +398,43 @@ function Test-GetDatabaseInternal ($location = "westcentralus")
}
}

<#
.SYNOPSIS
Tests getting a database with zone redundancy.
#>
function Test-GetDatabaseWithZoneRedundancy
{
# Setup
$location = "eastus2"
$rg = Create-ResourceGroupForTest $location
try
{
$server = Create-ServerForTest $rg $location

# Create database with no zone redundancy set
$databaseName = Get-DatabaseName
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-DatabaseName $databaseName -Edition Premium -ZoneRedundant

$gdb1 = Get-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db1.DatabaseName
Assert-AreEqual $gdb1.DatabaseName $db1.DatabaseName
Assert-AreEqual "true" $gdb1.ZoneRedundant

# Create database with zone redundancy true
$databaseName = Get-DatabaseName
$db2 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-DatabaseName $databaseName -Edition Premium

$gdb2 = Get-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db2.DatabaseName
Assert-AreEqual $gdb2.DatabaseName $db2.DatabaseName
Assert-AreEqual "false" $gdb2.ZoneRedundant
}
finally
{
Remove-ResourceGroupForTest $rg
}
}


<#
.SYNOPSIS
Expand Down Expand Up @@ -333,7 +499,7 @@ function Test-RemoveDatabaseInternal ($location = "westcentralus")
#>
function Test-CancelDatabaseOperation
{
Test-CancelDatabaseOperationInternal "North Europe"
Test-CancelDatabaseOperationInternal
}

<#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,40 @@ public void TestElasticPoolCreate()
RunPowerShellTest("Test-CreateElasticPool");
}

[Fact]
public void TestElasticPoolCreateWithZoneRedundancy()
{
RunPowerShellTest("Test-CreateElasticPoolWithZoneRedundancy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestElasticPoolUpdate()
{
RunPowerShellTest("Test-UpdateElasticPool");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestElasticPoolUpdateWithZoneRedundancy()
{
RunPowerShellTest("Test-UpdateElasticPoolWithZoneRedundancy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestElasticPoolGet()
{
RunPowerShellTest("Test-GetElasticPool");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestElasticPoolGetWithZoneRedundancy()
{
RunPowerShellTest("Test-GetElasticPoolWithZoneRedundancy");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestElasticPoolRemove()
Expand Down
Loading