Skip to content

Conversation

@hyonholee
Copy link
Contributor

@hyonholee hyonholee commented Mar 2, 2018

Design review accepted : https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/13

This PR also contains the following bug fixes.

#5189

#5101

#3735

Description

Checklist

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.

Will check this again when test coverage is added.

Copy link
Contributor

Choose a reason for hiding this comment

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

Both of these tests should have a positive test case (can you create a new blob and container and put the logs there?)

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 cannot check in SAS Uri to GitHub because of credscan. If I add a positive case with real SAS Uri and then remove secrets, then anyone who runs this test with record mode will fail. Wayne already tested this manually and I also can see that this Powershell command sends a correct REST call from recorded json file.

Copy link
Contributor

@maddieclayton maddieclayton Mar 3, 2018

Choose a reason for hiding this comment

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

If you create a new storage account in test, do the manipulations there, and remove the storage account, you should not have a security issue. I believe that this code is working now, but we need positive tests to ensure it continues working in the future.

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 added positive test case. Note that storage cmdlets are not available in compute test, so I had to manually run those cmdlets. So I commented out any manual steps in the tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you are able to access the cmdlets, as it is being done here:

New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
. Am I not understanding this code correctly? Network also uses dataplane Storage cmdlets and has no additional information in the test csproj:
New-AzureStorageContainer -Name $containerName -Context $context

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 update the test

#>
function Test-ExportLogAnalyticThrottledRequests
{
$loc = "West Central US";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use Get-Location everywhere a location is set: https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/Common.ps1#L583

Please ensure you specify all three parameter values.

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 this API is only available in this location. Get-Location gives a different location, so I need to give a specific location for this API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that you are able to access the cmdlets, as it is being done here:

New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
. Am I not understanding this code correctly? Network also uses dataplane Storage cmdlets and has no additional information in the test csproj:
New-AzureStorageContainer -Name $containerName -Context $context

#>
function Test-ExportLogAnalytics
{
$rgname = "hyleelog";
Copy link
Contributor

Choose a reason for hiding this comment

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

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 manually give this value, because I created the resource group manually for setting up my test. (because I cannot run storage cmdlets during the test.) So, I should not use getassetname because it gives a random name.

$result = Export-AzureRmLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
Assert-AreEqual "Succeeded" $result.Status;
$output = $result | Out-String;
Assert-True { $output.Contains(".csv"); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to check this file to ensure it has the right format?

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 don't think checking the content of the file is a scope of Powershell cmdlets test. It should be checked during the API test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we check the blob to ensure the file is there?

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.

.SYNOPSIS
Test Export Log Analytic Request Rate By Interval
#>
function Test-ExportLogAnalyticRequestRateByInterval
Copy link
Contributor

Choose a reason for hiding this comment

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

Change test names to reflect that this is a test for failure.

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

Position = 3,
Mandatory = false)]
[AllowNull]
Mandatory = true)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about breaking changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

resolved offline.

## SYNTAX

```
Export-AzureRmLogAnalyticRequestRateByInterval [-FromTime] <DateTime> [-GroupByOperationName]
Copy link
Contributor

Choose a reason for hiding this comment

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

Regenerate this once you reorder the parameters in cs file so that this syntax makes sense.

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 think the help generator has a bug. The parameters have positional values except switch parameters, but the help generator does not generate Syntax correctly according to the positional values.

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't own the help generator, so if you would like to file a bug you can do so here: https://github.com/PowerShell/platyPS. For now, the best way to solve this issue is order the parameters in the cs file in the order you want them shown in the syntax.

```
### -GroupByOperationName
Group query result by by Operation Name.
Copy link
Contributor

Choose a reason for hiding this comment

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

you say by twice

```
### -GroupByOperationName
Group query result by by Operation Name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here

"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'MaxUnhealthyInstancePercent'.","Change the type for parameter 'MaxUnhealthyInstancePercent' back to 'System.Nullable`1[System.Int32]'."
"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'SkuCapacity'.","Change the type for parameter 'SkuCapacity' back to 'System.Nullable`1[System.Int32]'."
"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]' for parameter 'OsDiskCaching'.","Change the type for parameter 'OsDiskCaching' back to 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]'."
"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.GrantAzureRmDiskAccess","Grant-AzureRmDiskAccess","0","2030","The parameter 'Access' is no longer optional for the parameter set 'DefaultParameter' for cmdlet 'Grant-AzureRmDiskAccess'.","Make 'Access' optional for the parameter set 'DefaultParameter'."
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove these two lines, we are not accepting breaking changes in non preview modules until May.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually a bug fix. Access should be a mandatory in CRP API. not giving this value in Powershell results in a bad request.

Copy link
Contributor

Choose a reason for hiding this comment

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

Approved offline.

…nto loganalytics

# Conflicts:
#	src/ResourceManager/Compute/ChangeLog.md
@hyonholee hyonholee force-pushed the loganalytics branch 2 times, most recently from 99608dc to 90b5c52 Compare March 7, 2018 04:02
Copy link
Contributor

Choose a reason for hiding this comment

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

If you set the "preferredLocation" parameter in Get-Location, it will be set to that location if it is available in the service.

Copy link
Contributor

Choose a reason for hiding this comment

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

please use getassetname for all resources.

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 Get-ComputeTestResourceName uses getassetname.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we determined that you are able to run the storage cmdlets here. Why are these lines still commented out?

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 the test framework does not work with data plane cmdlets in playback mode. If I uncomment these lines, this test only works in record mode test.

$result = Export-AzureRmLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
Assert-AreEqual "Succeeded" $result.Status;
$output = $result | Out-String;
Assert-True { $output.Contains(".csv"); }
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we check the blob to ensure the file is there?

Position = 3,
Mandatory = false)]
[AllowNull]
Mandatory = true)]
Copy link
Contributor

Choose a reason for hiding this comment

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

resolved offline - cmdlet fails without the parameter specified.

Mandatory = true,
ValueFromPipelineByPropertyName = true,
ValueFromPipeline = false)]
[AllowNull]
Copy link
Contributor

Choose a reason for hiding this comment

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

ping

});
}


Copy link
Contributor

Choose a reason for hiding this comment

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

ping

Position = 3,
Mandatory = false)]
[AllowNull]
Mandatory = true)]
Copy link
Contributor

Choose a reason for hiding this comment

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

resolved offline.

## SYNTAX

```
Export-AzureRmLogAnalyticRequestRateByInterval [-FromTime] <DateTime> [-GroupByOperationName]
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't own the help generator, so if you would like to file a bug you can do so here: https://github.com/PowerShell/platyPS. For now, the best way to solve this issue is order the parameters in the cs file in the order you want them shown in the syntax.

"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'MaxUnhealthyInstancePercent'.","Change the type for parameter 'MaxUnhealthyInstancePercent' back to 'System.Nullable`1[System.Int32]'."
"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[System.Int32]' for parameter 'SkuCapacity'.","Change the type for parameter 'SkuCapacity' back to 'System.Nullable`1[System.Int32]'."
"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.UpdateAzureRmVmss","Update-AzureRmVmss","0","2020","The cmdlet 'Update-AzureRmVmss' no longer supports the type 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]' for parameter 'OsDiskCaching'.","Change the type for parameter 'OsDiskCaching' back to 'System.Nullable`1[Microsoft.Azure.Management.Compute.Models.CachingTypes]'."
"Microsoft.Azure.Commands.Compute.dll","Microsoft.Azure.Commands.Compute.Automation.GrantAzureRmDiskAccess","Grant-AzureRmDiskAccess","0","2030","The parameter 'Access' is no longer optional for the parameter set 'DefaultParameter' for cmdlet 'Grant-AzureRmDiskAccess'.","Make 'Access' optional for the parameter set 'DefaultParameter'."
Copy link
Contributor

Choose a reason for hiding this comment

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

Approved offline.

@hyonholee hyonholee force-pushed the loganalytics branch 3 times, most recently from 3890923 to 7b500c8 Compare March 8, 2018 21:50
@maddieclayton
Copy link
Contributor

@maddieclayton
Copy link
Contributor

failing on demand test is now skipped, okay to merge.

@maddieclayton maddieclayton merged commit afcbd6f into Azure:preview Mar 9, 2018
@hyonholee hyonholee deleted the loganalytics branch March 9, 2018 19:18
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.

3 participants