-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Compute] Add cmdlets for CRP Log Analytics. #5665
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
Changes from all commits
a11a9b3
db43c15
b0a0d51
17ed73f
32fae96
a247ecc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // ---------------------------------------------------------------------------------- | ||
| // | ||
| // 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.WindowsAzure.Commands.ScenarioTest; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests | ||
| { | ||
| public class LogAnalyticTests | ||
| { | ||
| public LogAnalyticTests(Xunit.Abstractions.ITestOutputHelper output) | ||
| { | ||
| ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output)); | ||
| } | ||
|
|
||
| [Fact] | ||
| [Trait(Category.AcceptanceType, Category.CheckIn)] | ||
| public void TestExportLogAnalyticThrottledRequestsNegative() | ||
| { | ||
| ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticThrottledRequestsNegative"); | ||
| } | ||
|
|
||
| [Fact] | ||
| [Trait(Category.AcceptanceType, Category.CheckIn)] | ||
| public void TestExportLogAnalyticRequestRateByIntervalNegative() | ||
| { | ||
| ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticRequestRateByIntervalNegative"); | ||
| } | ||
|
|
||
| [Fact] | ||
| [Trait(Category.AcceptanceType, Category.CheckIn)] | ||
| public void TestExportLogAnalytics() | ||
| { | ||
| ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalytics"); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # ---------------------------------------------------------------------------------- | ||
| # | ||
| # 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. | ||
| # ---------------------------------------------------------------------------------- | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Test Export Log Analytic Throttled Requests | ||
| #> | ||
| function Test-ExportLogAnalyticThrottledRequestsNegative | ||
| { | ||
| $loc = Get-ComputeOperationLocation; | ||
| $from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9; | ||
| $to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9; | ||
| $sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas'; | ||
| Assert-ThrowsContains { ` | ||
| $result = Export-AzureRmLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByResourceName;} ` | ||
| "the given SAS URI"; | ||
| } | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Test Export Log Analytic Request Rate By Interval | ||
| #> | ||
| function Test-ExportLogAnalyticRequestRateByIntervalNegative | ||
| { | ||
| $loc = Get-ComputeOperationLocation; | ||
| $from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9; | ||
| $to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9; | ||
| $sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas'; | ||
| $interval = "FiveMins"; | ||
| Assert-ThrowsContains { ` | ||
| $result = Export-AzureRmLogAnalyticRequestRateByInterval -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -IntervalLength $interval -GroupByThrottlePolicy -GroupByOperationName;} ` | ||
| "the given SAS URI"; | ||
| } | ||
|
|
||
| <# | ||
| .SYNOPSIS | ||
| Test Export Log Analytics positive scenario | ||
| #> | ||
| function Test-ExportLogAnalytics | ||
| { | ||
| $rgname = Get-ComputeTestResourceName; | ||
| $loc = Get-ComputeOperationLocation; | ||
| $stoname = 'sto' + $rgname; | ||
| $stotype = 'Standard_GRS'; | ||
| $container = "test"; | ||
| $sastoken = '?fakesas' | ||
|
|
||
| New-AzureRmResourceGroup -Name $rgname -Location $loc -Force; | ||
| New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype; | ||
| $key = Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname; | ||
| $context = New-AzureStorageContext -StorageAccountName $stoname -StorageAccountKey $key.Key1; | ||
|
|
||
| if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback) | ||
| { | ||
| New-AzureStorageContainer -Name $container -Context $context; | ||
| $sastoken = Get-AzureStorageContainer -Name $container -Context $context | New-AzureStorageContainerSASToken -Permission rwdl -Context $context; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| $from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9; | ||
| $to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9; | ||
| $sasuri = "https://$stoname.blob.core.windows.net/$container$sastoken"; | ||
| $interval = "FiveMins"; | ||
| $result = Export-AzureRmLogAnalyticRequestRateByInterval -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -IntervalLength $interval -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName; | ||
| Assert-AreEqual "Succeeded" $result.Status; | ||
| $output = $result | Out-String; | ||
| Assert-True { $output.Contains(".csv"); } | ||
| Assert-True { $output.Contains("RequestRateByInterval"); } | ||
|
|
||
| $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"); } | ||
| Assert-True { $output.Contains("ThrottledRequests"); } | ||
|
|
||
| if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback) | ||
| { | ||
| $blobs = Get-AzureStorageBlob -Container test -Context $context; | ||
| $request_blob = $blobs | where {$_.name.contains("RequestRateByInterval")}; | ||
| $throttle_blob = $blobs | where {$_.name.contains("ThrottledRequests")}; | ||
| Assert-NotNull $request_blob; | ||
| Assert-NotNull $throttle_blob; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| # Cleanup | ||
| Clean-ResourceGroup $rgname; | ||
| } | ||
| } | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,15 +175,13 @@ public override void ExecuteCmdlet() | |
| [Parameter( | ||
| ParameterSetName = "DefaultParameter", | ||
| Position = 3, | ||
| Mandatory = false)] | ||
| [AllowNull] | ||
| Mandatory = true)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a breaking change - why is this being added?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. resolved offline - cmdlet fails without the parameter specified. |
||
| public AccessLevel Access { get; set; } | ||
|
|
||
| [Parameter( | ||
| ParameterSetName = "DefaultParameter", | ||
| Position = 4, | ||
| Mandatory = false)] | ||
| [AllowNull] | ||
| public int DurationInSecond { get; set; } | ||
|
|
||
| [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] | ||
|
|
||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.