Skip to content

Add instance pool, instance pool usages cmdlets, and update managed instance cmdlets to support instance pools. #9744

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 26 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9dcd58d
Update permissive record matcher, fix recording of TestGetManagedData…
Jul 23, 2019
efb2aa0
Updates to permissive record matcher to allow ignoring specific resou…
Jul 24, 2019
6d29512
Fixes to constructor / tests
Jul 24, 2019
7b6891f
Add instance pool and instance pool usages cmdlets
Jul 24, 2019
d51104e
Add scenario tests, instance pool tests, managed instance in instance…
Jul 29, 2019
6028fcc
Update get managed instance
Jul 29, 2019
28a0a7e
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
Jul 29, 2019
49b40c8
Update get azure sql managed instance cmdlet
Jul 29, 2019
08dc8f4
Updates to sql change log
Jul 29, 2019
7ef6198
Add updated and new cmdlet help files
Jul 30, 2019
7e88555
Merge branch 'master' into instancePoolsMaster
johnpaulkee Jul 30, 2019
b862d37
Update InstancePoolCrudTests.ps1 that had password warning not suppre…
Jul 30, 2019
6077627
Remove supports should process from GetAzureSqlInstancePoolUsage
Jul 30, 2019
e14e325
Update positions for RemoveAzureSqlManagedInstance
Jul 30, 2019
8d9d5d1
Add license headers and remove positional values for non mandatory pa…
Jul 30, 2019
2a3d1bd
Add license to instance pool crud tests, add default parameter sets t…
Jul 30, 2019
29eabfc
Update markdown help files and add online version
Jul 30, 2019
514cb03
Update to tests based on feedback
Jul 30, 2019
c2a4770
Update get sql instance
Jul 31, 2019
cb5cc3f
Updates post static analysis review
Jul 31, 2019
d1c6ce0
Reset breaking change to test build
Jul 31, 2019
da039b7
Add breaking changes
Jul 31, 2019
6447dd4
update breaking changes once more
Jul 31, 2019
401e987
Add table formats for pools and usages
Jul 31, 2019
c972fc5
Update permissive record matcher based on feedback
Jul 31, 2019
af5b8cc
Create new cloned permissive record matcher named permissive record m…
Aug 2, 2019
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 @@ -14,6 +14,7 @@

using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using System.Collections.Generic;
using Xunit;
using Xunit.Abstractions;
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;
Expand All @@ -32,6 +33,9 @@ protected override void SetupManagementClients(RestTestFramework.MockContext con

public AdvancedDataSecurityManagedInstanceTests(ITestOutputHelper output) : base(output)
{
base.resourceTypesToIgnoreApiVersion = new string[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnpaulkee TBD on this change 😁

"Microsoft.Sql/managedInstances"
};
}

[Fact]
Expand Down
69 changes: 61 additions & 8 deletions src/Sql/Sql.Test/ScenarioTests/Common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ Creates the basic test environment needed to perform the Sql data security tests
function Create-BasicManagedTestEnvironmentWithParams ($params, $location)
{
New-AzureRmResourceGroup -Name $params.rgname -Location $location
# Setup VNET

# Setup VNET
$vnetName = "cl_initial"
$subnetName = "Cool"
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName
Expand Down Expand Up @@ -235,7 +235,7 @@ function Create-DataMaskingTestEnvironment ($testSuffix)
New-AzSqlServer -ResourceGroupName $params.rgname -ServerName $params.serverName -ServerVersion "12.0" -Location "West Central US" -SqlAdministratorCredentials $credentials
New-AzSqlServerFirewallRule -ResourceGroupName $params.rgname -ServerName $params.serverName -StartIpAddress 0.0.0.0 -EndIpAddress 255.255.255.255 -FirewallRuleName "ddmRule"
New-AzSqlDatabase -ResourceGroupName $params.rgname -ServerName $params.serverName -DatabaseName $params.databaseName

if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -eq "Record")
{
$fullServerName = $params.serverName + ".database.windows.net"
Expand Down Expand Up @@ -358,11 +358,11 @@ function Get-ManagedInstanceForTdeTest ($params)
$rg = Create-ResourceGroupForTest
$vnetName = "cl_initial"
$subnetName = "Cool"
# Setup VNET

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

$managedInstance = Create-ManagedInstanceForTest $rg $subnetId
Set-AzKeyVaultAccessPolicy -VaultName $params.vaultName -ObjectId $managedInstance.Identity.PrincipalId -PermissionsToKeys get, list, wrapKey, unwrapKey

Expand Down Expand Up @@ -495,7 +495,7 @@ function Get-ProviderLocation($provider)
if ($location -eq $null)
{
return "East US"
}
}
else
{
return $location.Locations[0]
Expand Down Expand Up @@ -539,7 +539,7 @@ function Get-ServerCredential
$serverLogin = "testusername"
<#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test passwords only valid for the duration of the test")]#>
$serverPassword = "t357ingP@s5w0rd!"
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
$credentials = new-object System.Management.Automation.PSCredential($serverLogin, ($serverPassword | ConvertTo-SecureString -asPlainText -Force))
return $credentials
}

Expand Down Expand Up @@ -738,6 +738,59 @@ function Create-ManagedInstanceForTest ($resourceGroup, $subnetId)
return $managedInstance
}

<#
.SYNOPSIS
Creates a managed instance in an instance pool
#>
function Create-ManagedInstanceInInstancePoolForTest ($instancePool)
{
$managedInstanceName = Get-ManagedInstanceName
$credentials = Get-ServerCredential
$vCore = 2
$managedInstance = $instancePool | New-AzSqlInstance -Name $managedInstanceName -VCore $vCore -AdministratorCredential $credentials -StorageSizeInGb 32 -PublicDataEndpointEnabled
return $managedInstance
}

function Remove-ManagedInstancesInInstancePool($instancePool)
{
$instancePool | Get-AzSqlInstance | Remove-AzSqlInstance -Force
}


function Get-InstancePoolTestProperties()
{
$tags = @{ instance="Pools" };
$instancePoolTestProperties = @{
resourceGroup = "instancePoolCSSdemo"
name = "cssinstancepool0"
subnetName = "InstancePool"
vnetName = "vnet-cssinstancepool0"
tags = $tags
computeGen = "Gen5"
edition = "GeneralPurpose"
location = "canadacentral"
licenseType = "LicenseIncluded"
vCores = 16
}
return $instancePoolTestProperties
}

<#
.SYNOPSIS
Creates an instance pool for Sql instance pool CRUD tests
#>
function Create-InstancePoolForTest()
{
$props = Get-InstancePoolTestProperties
$virtualNetwork = CreateAndGetVirtualNetworkForManagedInstance $props.vnetName $props.subnetName $props.location $props.resourceGroup
$subnetId = $virtualNetwork.Subnets.where({ $_.Name -eq $props.subnetName })[0].Id
$instancePool = New-AzSqlInstancePool -ResourceGroupName $props.resourceGroup -Name $props.name `
-Location $props.location -SubnetId $subnetId -VCore $props.vCores `
-Edition $props.Edition -ComputeGeneration $props.computeGen `
-LicenseType $props.licenseType -Tag $props.tags
return $instancePool
}

<#
.SYNOPSIS
Create a virtual network
Expand Down
3 changes: 3 additions & 0 deletions src/Sql/Sql.Test/ScenarioTests/DataClassificationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public class DataClassificationTests : SqlTestsBase
{
public DataClassificationTests(ITestOutputHelper output) : base(output)
{
base.resourceTypesToIgnoreApiVersion = new string[] {
"Microsoft.Sql/managedInstances"
};
}

protected override void SetupManagementClients(RestTestFramework.MockContext context)
Expand Down
136 changes: 136 additions & 0 deletions src/Sql/Sql.Test/ScenarioTests/InstancePoolCrudTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// ----------------------------------------------------------------------------------
//
// 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;
using Xunit.Abstractions;
using RestTestFramework = Microsoft.Rest.ClientRuntime.Azure.TestFramework;

namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests
{
public class InstancePoolCrudTests : SqlTestsBase
{
public InstancePoolCrudTests(ITestOutputHelper output) : base(output)
{
}

protected override void SetupManagementClients(RestTestFramework.MockContext context)
{
var sqlClient = GetSqlClient(context);
var newResourcesClient = GetResourcesClient(context);
var networkClient = GetNetworkClient(context);
Helper.SetupSomeOfManagementClients(sqlClient, newResourcesClient, networkClient);
}

#region Instance pool

/// <summary>
/// Tests creation of an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateInstancePool()
{
RunPowerShellTest("Test-CreateInstancePool");
}

/// <summary>
/// Tests updating an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateInstancePool()
{
RunPowerShellTest("Test-UpdateInstancePool");
}

/// <summary>
/// Tests getting an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetInstancePool()
{
RunPowerShellTest("Test-GetInstancePool");
}

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

#endregion

#region Managed Instance

/// <summary>
/// Tests creation of a managed instance in an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestCreateManagedInstanceInInstancePool()
{
RunPowerShellTest("Test-CreateManagedInstanceInInstancePool");
}

/// <summary>
/// Tests getting all managed instances in an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetManagedInstanceInInstancePool()
{
RunPowerShellTest("Test-GetManagedInstanceInInstancePool");
}

/// <summary>
/// Tests updating a managed instance in an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestUpdateManagedInstanceInInstancePool()
{
RunPowerShellTest("Test-UpdateManagedInstanceInInstancePool");
}

/// <summary>
/// Tests updating a managed instance in an instance pool
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestDeleteManagedInstanceInInstancePool()
{
RunPowerShellTest("Test-DeleteManagedInstanceInInstancePool");
}

#endregion

#region Instance Pool Usages

/// <summary>
/// Tests getting the instance pool usage
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetInstancePoolUsage()
{
RunPowerShellTest("Test-GetInstancePoolUsage");
}

#endregion
}
}
Loading