Skip to content

Updating pool and database cmdlets to include optional LicenseType param #6311

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 17 commits into from
May 30, 2018
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
6 changes: 6 additions & 0 deletions src/ResourceManager/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
- Additional information about change #1
-->
## Current Release
* Updated the following cmdlets with optional LicenseType parameter
- New-AzureRmSqlDatabase; Set-AzureRmSqlDatabase
- New-AzureRmSqlElasticPool; Set-AzureRmSqlElasticPool
- New-AzureRmSqlDatabaseCopy
- New-AzureRmSqlDatabaseSecondary
- Restore-AzureRmSqlDatabase

## Version 4.5.0
* Updated Auditing cmdlets to allow removing AuditActions or AuditActionGroups
Expand Down
27 changes: 21 additions & 6 deletions src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.19.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Sql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.1.15.0-preview\lib\net452\Microsoft.Azure.Management.Sql.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</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 @@ -639,15 +639,24 @@
<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.DatabaseCrudTests\TestVcoreDatabaseCreate.json">
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestVcoreDatabaseCreate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestVcoreDatabaseUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestVcoreDatabaseUpdateWithLicenseType.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestVcoreDatabaseUpdate.json">
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestVcoreDatabaseCreateWithLicenseType.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests\TestCreateDatabaseCopy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests\TestCreateVcoreDatabaseCopy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests\TestCreateSecondaryDatabase.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -747,10 +756,16 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCancelOperation.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestVcoreElasticPoolUpdate.json">
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestVcoreElasticPoolUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestVcoreElasticPoolCreate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestVcoreElasticPoolUpdateWithLicenseType.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestVcoreElasticPoolCreate.json">
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestVcoreElasticPoolCreateWithLicenseType.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.FailoverGroupTests\TestCreateFailoverGroup_AutomaticPolicy.json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public void TestVcoreDatabaseCreate()
RunPowerShellTest("Test-CreateVcoreDatabase");
}

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseCreateWithSampleName()
Expand Down Expand Up @@ -80,6 +87,13 @@ public void TestVcoreDatabaseUpdate()
RunPowerShellTest("Test-UpdateVcoreDatabase");
}

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDatabaseUpdateWithZoneRedundancy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Test-CreateDatabaseInternal ($location = "westcentralus")
$job1 | Wait-Job
$db = $job1.Output

Assert-AreEqual $databaseName $db.DatabaseName
Assert-AreEqual $databaseName $db.DatabaseName
Assert-NotNull $db.MaxSizeBytes
Assert-NotNull $db.Edition
Assert-NotNull $db.CurrentServiceObjectiveName
Expand Down Expand Up @@ -68,7 +68,7 @@ function Test-CreateDatabaseInternal ($location = "westcentralus")
Assert-AreEqual $dwdb.Edition DataWarehouse
Assert-AreEqual $dwdb.CurrentServiceObjectiveName DW100
Assert-AreEqual $dwdb.CollationName $collationName

# Create with all parameters
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
Expand Down Expand Up @@ -107,7 +107,7 @@ function Test-CreateDatabaseInternal ($location = "westcentralus")
#>
function Test-CreateVcoreDatabase
{
# Setup
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
$rg = Create-ResourceGroupForTest $location
$server = Create-ServerForTest $rg $location
Expand All @@ -120,7 +120,7 @@ function Test-CreateVcoreDatabase
$job1 | Wait-Job
$db = $job1.Output

Assert-AreEqual $databaseName $db.DatabaseName
Assert-AreEqual $databaseName $db.DatabaseName
Assert-NotNull $db.MaxSizeBytes
Assert-AreEqual GP_Gen4_2 $db.CurrentServiceObjectiveName
Assert-AreEqual 2 $db.Capacity
Expand All @@ -132,7 +132,7 @@ function Test-CreateVcoreDatabase
$job1 | Wait-Job
$db = $job1.Output

Assert-AreEqual $databaseName $db.DatabaseName
Assert-AreEqual $databaseName $db.DatabaseName
Assert-NotNull $db.MaxSizeBytes
Assert-AreEqual GP_Gen4_2 $db.CurrentServiceObjectiveName
Assert-AreEqual 2 $db.Capacity
Expand All @@ -144,6 +144,45 @@ function Test-CreateVcoreDatabase
}
}

<#
.SYNOPSIS
Tests creating a database with license type.
#>
function Test-CreateVcoreDatabaseWithLicenseType
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "West Central US"
$rg = Create-ResourceGroupForTest
$server = Create-ServerForTest $rg $location

try
{
# Create with Edition and RequestedServiceObjectiveName - Base Price
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -RequestedServiceObjectiveName GP_Gen4_1 -Edition GeneralPurpose -LicenseType BasePrice
Assert-AreEqual BasePrice $db.LicenseType

# Create with Edition and RequestedServiceObjectiveName - LicenseIncluded
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -RequestedServiceObjectiveName GP_Gen4_1 -Edition GeneralPurpose -LicenseType LicenseIncluded
Assert-AreEqual LicenseIncluded $db.LicenseType

# Create with VCore parameter set - BasePrice
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -VCore 2 -ComputeGeneration Gen4 -Edition GeneralPurpose -LicenseType BasePrice
Assert-AreEqual BasePrice $db.LicenseType

# Create with VCore parameter set - LicenseIncluded
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -VCore 2 -ComputeGeneration Gen4 -Edition GeneralPurpose -LicenseType LicenseIncluded
Assert-AreEqual LicenseIncluded $db.LicenseType
}
finally
{
Remove-ResourceGroupForTest $rg
}
}

<#
.SYNOPSIS
Tests creating a database with sample name.
Expand Down Expand Up @@ -245,13 +284,13 @@ function Test-UpdateDatabaseInternal ($location = "westcentralus")
# Setup
$rg = Create-ResourceGroupForTest
$server = Create-ServerForTest $rg $location

$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
-Edition Standard -MaxSizeBytes 250GB -RequestedServiceObjectiveName S0
Assert-AreEqual $db.DatabaseName $databaseName

# Database will be Standard s0 with maxsize: 268435456000 (250GB)
# Database will be Standard s0 with maxsize: 268435456000 (250GB)

try
{
Expand Down Expand Up @@ -307,11 +346,11 @@ function Test-UpdateDatabaseInternal ($location = "westcentralus")

<#
.SYNOPSIS
Tests updating a vcore database
Tests updating a vcore database
#>
function Test-UpdateVcoreDatabase ()
function Test-UpdateVcoreDatabase()
{
# Setup
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
$rg = Create-ResourceGroupForTest $location
$server = Create-ServerForTest $rg $location
Expand Down Expand Up @@ -385,6 +424,47 @@ function Test-UpdateVcoreDatabase ()
}
}

<#
.SYNOPSIS
Tests updating a vcore database license type
#>
function Test-UpdateVcoreDatabaseLicenseType()
{
# Setup
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
$rg = Create-ResourceGroupForTest $location
$server = Create-ServerForTest $rg $location

# Create vcore database
$databaseName = Get-DatabaseName
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -RequestedServiceObjectiveName GP_Gen4_1 -Edition GeneralPurpose
Assert-AreEqual $db.DatabaseName $databaseName
Assert-AreEqual $db.LicenseType LicenseIncluded # Default license type

try
{
# Alter with license type - License Included
$db1 = Set-AzureRmSqlDatabase -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName -LicenseType LicenseIncluded
Assert-AreEqual LicenseIncluded $db1.LicenseType

# Alter with license type - Base Price
$db1 = Set-AzureRmSqlDatabase -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName -LicenseType BasePrice
Assert-AreEqual BasePrice $db1.LicenseType

# Test piping - LicenseIncluded
$db1 = $db1 | Set-AzureRmSqlDatabase -LicenseType LicenseIncluded
Assert-AreEqual LicenseIncluded $db1.LicenseType

# Test piping - BasePrice
$db1 = $db1 | Set-AzureRmSqlDatabase -LicenseType BasePrice
Assert-AreEqual BasePrice $db1.LicenseType
}
finally
{
Remove-ResourceGroupForTest $rg
}
}

<#
.SYNOPSIS
Tests updating a database with zone redundancy
Expand All @@ -395,7 +475,7 @@ function Test-UpdateDatabaseWithZoneRedundant ()
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
$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
Expand Down Expand Up @@ -442,7 +522,7 @@ function Test-UpdateDatabaseWithZoneRedundantNotSpecified ()
$location = Get-Location "Microsoft.Sql" "operations" "Southeast Asia"
$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
Expand Down Expand Up @@ -480,7 +560,7 @@ function Test-RenameDatabase
{
$location = "westcentralus"
$server = Create-ServerForTest $rg $location

# Create with default values
$databaseName = Get-DatabaseName
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -MaxSizeBytes 1GB
Expand Down Expand Up @@ -528,17 +608,17 @@ function Test-GetDatabaseInternal ($location = "westcentralus")
# Setup
$rg = Create-ResourceGroupForTest
$server = Create-ServerForTest $rg $location

# Create with default values
$databaseName = Get-DatabaseName
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -MaxSizeBytes 1GB
Assert-AreEqual $db1.DatabaseName $databaseName

# Create database with non-defaults
# Create database with non-defaults
$databaseName = Get-DatabaseName
$db2 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
-CollationName "Japanese_Bushu_Kakusu_100_CS_AS" -MaxSizeBytes 1GB -Edition Basic -RequestedServiceObjectiveName Basic
Assert-AreEqual $db2.DatabaseName $databaseName
Assert-AreEqual $db2.DatabaseName $databaseName

try
{
Expand All @@ -556,21 +636,21 @@ function Test-GetDatabaseInternal ($location = "westcentralus")
$all = $server | Get-AzureRmSqlDatabase
Assert-AreEqual $all.Count 4 # 4 because master database is included

$gdb1 = Get-AzureRmSqlDatabase -ResourceGroupName $server.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db1.DatabaseName
Assert-NotNull $gdb1
Assert-AreEqual $db1.DatabaseName $gdb1.DatabaseName
Assert-AreEqual $db1.Edition $gdb1.Edition
Assert-AreEqual $db1.CollationName $gdb1.CollationName
Assert-AreEqual $db1.CurrentServiceObjectiveName $gdb1.CurrentServiceObjectiveName
Assert-AreEqual $db1.MaxSizeBytes $gdb1.MaxSizeBytes

$gdb2 = $db2 | Get-AzureRmSqlDatabase
Assert-NotNull $gdb2
Assert-AreEqual $db2.DatabaseName $gdb2.DatabaseName
Assert-AreEqual $db2.Edition $gdb2.Edition
Assert-AreEqual $db2.CollationName $gdb2.CollationName
Assert-AreEqual $db2.CurrentServiceObjectiveName $gdb2.CurrentServiceObjectiveName
Assert-AreEqual $db2.MaxSizeBytes $gdb2.MaxSizeBytes
$gdb1 = Get-AzureRmSqlDatabase -ResourceGroupName $server.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db1.DatabaseName
Assert-NotNull $gdb1
Assert-AreEqual $db1.DatabaseName $gdb1.DatabaseName
Assert-AreEqual $db1.Edition $gdb1.Edition
Assert-AreEqual $db1.CollationName $gdb1.CollationName
Assert-AreEqual $db1.CurrentServiceObjectiveName $gdb1.CurrentServiceObjectiveName
Assert-AreEqual $db1.MaxSizeBytes $gdb1.MaxSizeBytes

$gdb2 = $db2 | Get-AzureRmSqlDatabase
Assert-NotNull $gdb2
Assert-AreEqual $db2.DatabaseName $gdb2.DatabaseName
Assert-AreEqual $db2.Edition $gdb2.Edition
Assert-AreEqual $db2.CollationName $gdb2.CollationName
Assert-AreEqual $db2.CurrentServiceObjectiveName $gdb2.CurrentServiceObjectiveName
Assert-AreEqual $db2.MaxSizeBytes $gdb2.MaxSizeBytes
}
finally
{
Expand Down Expand Up @@ -634,17 +714,17 @@ function Test-RemoveDatabaseInternal ($location = "westcentralus")
# Setup
$rg = Create-ResourceGroupForTest
$server = Create-ServerForTest $rg $location

# Create with default values
$databaseName = Get-DatabaseName
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName -MaxSizeBytes 1GB
Assert-AreEqual $db1.DatabaseName $databaseName

# Create database with non-defaults
# Create database with non-defaults
$databaseName = Get-DatabaseName
$db2 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
-CollationName "Japanese_Bushu_Kakusu_100_CS_AS" -MaxSizeBytes 1GB -Edition Basic -RequestedServiceObjectiveName Basic
Assert-AreEqual $db2.DatabaseName $databaseName
Assert-AreEqual $db2.DatabaseName $databaseName

try
{
Expand All @@ -655,16 +735,16 @@ function Test-RemoveDatabaseInternal ($location = "westcentralus")
Assert-AreEqual $dwdb.DatabaseName $databaseName

Remove-AzureRmSqlDatabase -ResourceGroupName $server.ResourceGroupname -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName -Force

$all = $server | Get-AzureRmSqlDatabase
Assert-AreEqual $all.Count 3 # 3 because master database is included

Remove-AzureRmSqlDatabase -ResourceGroupName $server.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db1.DatabaseName -Force

$db2 | Remove-AzureRmSqlDatabase -Force
Remove-AzureRmSqlDatabase -ResourceGroupName $server.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db1.DatabaseName -Force

$db2 | Remove-AzureRmSqlDatabase -Force

$all = $server | Get-AzureRmSqlDatabase
Assert-AreEqual $all.Count 1 # 1 because master database is included
$all = $server | Get-AzureRmSqlDatabase
Assert-AreEqual $all.Count 1 # 1 because master database is included
}
finally
{
Expand Down
Loading