Skip to content

Adding VirtualCluster related cmdlets and corresponding tests... #8932

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 6 commits into from
Apr 12, 2019

Conversation

milostod
Copy link
Contributor

@milostod milostod commented Apr 3, 2019

...and help files.

Description

This change adds cmdlets related to VirtualCluster resource. The intention is to enable customers to get information about virtual cluster(s) under their subscription and resource group, as well as to remove specified virtual cluster, which was a major ask from our customers. Explicit creation of new virtual clusters is not supported, as virtual cluster resource is only implicitly created when customer creates first managed instance in the specified subnet. Similarly, updates on virtual clusters are not currently supported.
Test coverage and recordings has been added for all chenges, as well as markdown help files.
Cmdlet design review is completed here: https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/271

Checklist

@adxsdkps
Copy link
Collaborator

adxsdkps commented Apr 3, 2019

Can one of the admins verify this patch?

@@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.28.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Sql" Version="1.29.0-preview" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: New NuGet package has been published from the Azure SDK for .NET repository

@milostod
Copy link
Contributor Author

milostod commented Apr 3, 2019

Note: there are some auto-generated changes in Az.Sql.md related to sensitivity classification/recommendation, as well as in Set-AzSqlDatabaseThreatDetectionPolicy.md and Set-AzSqlServerThreatDetectionPolicy.md. My guess is that original changes in these areas were not accompanied with md update through platyPS, so I included those in my change.

@cormacpayne
Copy link
Member

@azuresdkci add to whitelist

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

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

@milostod a few minor comments, otherwise LGTM

HelpMessage = "The name of the resource group.")]
[Parameter(ParameterSetName = GetByResourceGroupParameterSet,
Mandatory = false,
Position = 1,
Copy link
Member

Choose a reason for hiding this comment

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

@milostod please remove the Position property from optional parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

/// </summary>
[Parameter(ParameterSetName = RemoveByResourceIdParameterSet,
Mandatory = true,
Position = 0,
Copy link
Member

Choose a reason for hiding this comment

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

@milostod minor: you can remove this positional parameter since users will never be able to use it (if they provide a single string, PowerShell won't be able to differentiate between the Name/ResourceGroupName and ResourceId parameter sets, and since the Name/ResourceGroupName set is the default, it will choose that one and prompt the user to provide a value for -ResourceGroupName)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, thanks. I've made the change.

// Extract the resource group name from the ID.
// ID is in the form:
// /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Sql/virtualClusters/virtualClusterName
string[] segments = resp.Id.Split('/');
Copy link
Member

Choose a reason for hiding this comment

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

@milostod you can use the ResourceIdentifier class that's in our common ARM code to safely parse a provided resource id string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice, thanks for the comment.

@milostod
Copy link
Contributor Author

milostod commented Apr 5, 2019

@cormacpayne I've made changes we discussed. Windows and Linux builds failed in automated checks, although build works fine on my local machine. It seems I cannot request rebuild.

@milostod
Copy link
Contributor Author

@cormacpayne @maddieclayton, I've made changes and fixed merge conflicts, please review.

Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

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

Few very small comments, then this should be good to go.

function Test-GetVirtualCluster
{
# Setup
$location = "eastus"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please get location using Get-Location to ensure this will work on all clouds: https://github.com/Azure/azure-powershell/blob/master/tools/ScenarioTest.ResourceManager/Common.ps1#L583

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @maddieclayton , I used some pre-made resources to speed up the test because provisioning of a new virtual cluster takes several hours. I've made the changes to create everything in the test, however, each test takes almost 4 hours to execute. If this is not a problem, I'll commit the change. Please let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

@milostod It is fine to take 4 hours to record this test - because the SDK calls will be instantaneous in playback mode, it will not affect our CI, and having a test take 4 hours to record is much better than having to do manual set up that takes the same amount of time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maddieclayton I agree. I've made the changes, tests are now creating everything from scratch, including ResourceGroup, VNet and Subnet. Total running time was 7hrs:30min for two tests. I used Get-ProviderLocation since it uses Get-AzResourceProvider instead of Get-AzureRmResourceProvider command for which I had some trouble running locally.

$location = "eastus"
$rg = Create-ResourceGroupForTest $location

$rgName = "RG_MIPlayground"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please have all resource name be randomly generated using getAssetName: https://github.com/Azure/azure-powershell/blob/master/tools/ScenarioTest.ResourceManager/Common.ps1#L371

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. rgName is created in Create-ResourceGroupForTest using getAssetName. I kept hardcoded names for vnet and subnet as it seems that calling getAssetName multiple times in short period produces "queue is empty" error. I see multiple tests are keeping hardcoded values for vnet and subnet, probably for the same reason.

@@ -271,7 +272,7 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* Support Database Data Classification.'
ReleaseNotes = '* Add Virtual Cluster cmdlets'
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change, we will update during versioning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks.

@maddieclayton maddieclayton merged commit 25679d6 into Azure:master Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants