Skip to content

Make New-AzSqlInstance -StorageSizeInGB parameter optional #9203

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 7 commits into from
May 22, 2019
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
13 changes: 8 additions & 5 deletions src/Sql/Sql.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function Create-BasicManagedTestEnvironmentWithParams ($params, $location)
$vnetName = "cl_initial"
$subnetName = "Cool"
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id
$credentials = Get-ServerCredential
$licenseType = "BasePrice"
$storageSizeInGB = 32
Expand All @@ -214,7 +214,7 @@ function Create-BasicManagedTestEnvironmentWithParams ($params, $location)

$managedInstance = New-AzureRmSqlInstance -ResourceGroupName $params.rgname -Name $params.serverName `
-Location $location -AdministratorCredential $credentials -SubnetId $subnetId `
-LicenseType $licenseType -StorageSizeInGB $storageSizeInGB -Vcore $vCore -SkuName $skuName
-Vcore $vCore -SkuName $skuName

New-AzureRmSqlInstanceDatabase -ResourceGroupName $params.rgname -InstanceName $params.serverName -Name $params.databaseName -Collation $collation
}
Expand Down Expand Up @@ -700,21 +700,24 @@ function Create-ManagedInstanceForTest ($resourceGroup, $subnetId)
{
$managedInstanceName = Get-ManagedInstanceName
$credentials = Get-ServerCredential
$licenseType = "BasePrice"
$storageSizeInGB = 32
$vCore = 16
$skuName = "GP_Gen4"

$managedInstance = New-AzSqlInstance -ResourceGroupName $resourceGroup.ResourceGroupName -Name $managedInstanceName `
-Location $resourceGroup.Location -AdministratorCredential $credentials -SubnetId $subnetId `
-LicenseType $licenseType -StorageSizeInGB $storageSizeInGB -Vcore $vCore -SkuName $skuName
-Vcore $vCore -SkuName $skuName

return $managedInstance
}

<#
.SYNOPSIS
Create a virtual network

If resource group $resourceGroupName does not exist, then please create it before running the test.
We deliberately do not create it, because if we did then ResourceGroupCleaner (inside MockContext) would delete it
at the end of the test, which prevents us from reusing the subnet and therefore massively slows down
managed instance scenario tests.
#>
function CreateAndGetVirtualNetworkForManagedInstance ($vnetName, $subnetName, $location = "westcentralus", $resourceGroupName = "cl_one")
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sql/Sql.Test/ScenarioTests/ManagedDatabaseBackupTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Test-ManagedLiveDatabaseShortTermRetentionPolicy

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId

Expand Down Expand Up @@ -97,7 +97,7 @@ function Test-ManagedDeletedDatabaseShortTermRetentionPolicy

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Test-CreateManagedDatabase

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId

Expand Down Expand Up @@ -75,7 +75,7 @@ function Test-GetManagedDatabase

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId

Expand Down Expand Up @@ -130,7 +130,7 @@ function Test-RemoveManagedDatabase

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId

Expand Down Expand Up @@ -200,7 +200,7 @@ function Test-RestoreManagedDatabase

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId
$managedInstance2 = Create-ManagedInstanceForTest $rg2 $subnetId
Expand Down
45 changes: 24 additions & 21 deletions src/Sql/Sql.Test/ScenarioTests/ManagedInstanceCrudScenarioTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# limitations under the License.
# ----------------------------------------------------------------------------------

# Location to use for provisioning test managed instances
$instanceLocation = "eastus"

<#
.SYNOPSIS
Tests creating a managed instance
Expand All @@ -37,9 +40,9 @@ function Test-CreateManagedInstance
$proxyOverride = "Proxy"
try
{
# Setup VNET
# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location "newprovisioningtest"
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

# With SKU name specified
$job = New-AzSqlInstance -ResourceGroupName $rg.ResourceGroupName -Name $managedInstanceName `
Expand Down Expand Up @@ -109,9 +112,9 @@ function Test-SetManagedInstance
$vnetName = "vnet-newprovisioningtest3"
$subnetName = "ManagedInstance"

# Setup VNET
# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location "newprovisioningtest"
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId

Expand All @@ -125,14 +128,14 @@ function Test-SetManagedInstance

$managedInstance1 = Set-AzSqlInstance -ResourceGroupName $rg.ResourceGroupName -Name $managedInstance.ManagedInstanceName `
-AdministratorPassword $credentials.Password -LicenseType $licenseType -StorageSizeInGB $storageSizeInGB -Vcore $vCore -Force

Assert-AreEqual $managedInstance1.ManagedInstanceName $managedInstance.ManagedInstanceName
Assert-AreEqual $managedInstance1.AdministratorLogin $managedInstance.AdministratorLogin
Assert-AreEqual $managedInstance1.LicenseType $licenseType
Assert-AreEqual $managedInstance1.VCores $vCore
Assert-AreEqual $managedInstance1.StorageSizeInGB $storageSizeInGB
Assert-StartsWith ($managedInstance1.ManagedInstanceName + ".") $managedInstance1.FullyQualifiedDomainName

# Test using piping
$credentials = Get-ServerCredential

Expand All @@ -158,7 +161,7 @@ function Test-SetManagedInstance

$managedInstance3 = Set-AzSqlInstance -InputObject $managedInstance `
-AdministratorPassword $credentials.Password -LicenseType $licenseType -StorageSizeInGB $storageSizeInGB -Vcore $vCore -Force

Assert-AreEqual $managedInstance3.ManagedInstanceName $managedInstance.ManagedInstanceName
Assert-AreEqual $managedInstance3.AdministratorLogin $managedInstance.AdministratorLogin
Assert-AreEqual $managedInstance3.LicenseType $licenseType
Expand All @@ -177,7 +180,7 @@ function Test-SetManagedInstance
$managedInstance4 = Set-AzSqlInstance -ResourceId $managedInstance.Id `
-AdministratorPassword $credentials.Password -LicenseType $licenseType -StorageSizeInGB $storageSizeInGB -Vcore $vCore `
-PublicDataEndpointEnabled $publicDataEndpointEnabled -ProxyOverride $proxyOverride -Force

Assert-AreEqual $managedInstance4.ManagedInstanceName $managedInstance.ManagedInstanceName
Assert-AreEqual $managedInstance4.AdministratorLogin $managedInstance.AdministratorLogin
Assert-AreEqual $managedInstance4.LicenseType $licenseType
Expand All @@ -202,14 +205,14 @@ function Test-SetManagedInstance
function Test-GetManagedInstance
{
# Setup
$rg = Create-ResourceGroupForTest
$rg1 = Create-ResourceGroupForTest
$rg = Create-ResourceGroupForTest $instanceLocation
$rg1 = Create-ResourceGroupForTest $instanceLocation
$vnetName = "cl_initial"
$subnetName = "CooL"

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location "powershell_mi"
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstance1 = Create-ManagedInstanceForTest $rg $subnetId
$managedInstance2 = Create-ManagedInstanceForTest $rg1 $subnetId
Expand All @@ -225,7 +228,7 @@ function Test-GetManagedInstance
Assert-AreEqual $managedInstance1.LicenseType $resp1.LicenseType
Assert-AreEqual $managedInstance1.VCores $resp1.VCores
Assert-AreEqual $managedInstance1.StorageSizeInGB $resp1.StorageSizeInGB

$all = Get-AzSqlInstance -ResourceGroupName $rg.ResourceGroupName -Name *
Assert-AreEqual 1 $all.Count

Expand All @@ -252,20 +255,20 @@ function Test-GetManagedInstance
function Test-RemoveManagedInstance
{
# Setup
$rg = Create-ResourceGroupForTest
$rg = Create-ResourceGroupForTest $instanceLocation
$vnetName = "cl_initial"
$subnetName = "CooL"

# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location "powershell_mi"
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

try
{
# Test using parameters
$managedInstance1 = Create-ManagedInstanceForTest $rg $subnetId
Remove-AzSqlInstance -ResourceGroupName $rg.ResourceGroupName -Name $managedInstance1.ManagedInstanceName -Force

# Test using InputObject
$managedInstance2 = Create-ManagedInstanceForTest $rg $subnetId
Remove-AzSqlInstance -InputObject $managedInstance2 -Force
Expand Down Expand Up @@ -298,9 +301,9 @@ function Test-CreateManagedInstanceWithIdentity
$vnetName = "cl_initial"
$subnetName = "CooL"

# Setup VNET
# Setup VNET
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id

$managedInstanceName = Get-ManagedInstanceName
$version = "12.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function Test-VulnerabilityAssessmentManagedInstanceSettingsTest
$vnetName = "cl_initial"
$subnetName = "Cool"
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName }).Id
$subnetId = $virtualNetwork1.Subnets.where({ $_.Name -eq $subnetName })[0].Id
$credentials = Get-ServerCredential
$licenseType = "BasePrice"
$storageSizeInGB = 32
Expand Down
Loading