Skip to content

Commit a247ecc

Browse files
committed
Update LogAnalyticTests
1 parent 32fae96 commit a247ecc

13 files changed

+1409
-409
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Common/ComputeTestController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public void RunPsTestWorkflow(
155155
helper.RMStorageModule,
156156
helper.GetRMModulePath("AzureRM.Compute.psd1"),
157157
helper.GetRMModulePath("AzureRM.Network.psd1"),
158+
helper.RMStorageDataPlaneModule,
158159
"AzureRM.Storage.ps1",
159160
"AzureRM.Resources.ps1");
160161

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/LogAnalyticTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public LogAnalyticTests(Xunit.Abstractions.ITestOutputHelper output)
2626

2727
[Fact]
2828
[Trait(Category.AcceptanceType, Category.CheckIn)]
29-
public void TestExportLogAnalyticThrottledRequests()
29+
public void TestExportLogAnalyticThrottledRequestsNegative()
3030
{
31-
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticThrottledRequests");
31+
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticThrottledRequestsNegative");
3232
}
3333

3434
[Fact]
3535
[Trait(Category.AcceptanceType, Category.CheckIn)]
36-
public void TestExportLogAnalyticRequestRateByInterval()
36+
public void TestExportLogAnalyticRequestRateByIntervalNegative()
3737
{
38-
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticRequestRateByInterval");
38+
ComputeTestController.NewInstance.RunPsTest("Test-ExportLogAnalyticRequestRateByIntervalNegative");
3939
}
4040

4141
[Fact]

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/LogAnalyticTests.ps1

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
.SYNOPSIS
1717
Test Export Log Analytic Throttled Requests
1818
#>
19-
function Test-ExportLogAnalyticThrottledRequests
19+
function Test-ExportLogAnalyticThrottledRequestsNegative
2020
{
21-
$loc = "West Central US";
21+
$loc = Get-ComputeOperationLocation;
2222
$from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9;
2323
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
2424
$sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas';
@@ -31,9 +31,9 @@ function Test-ExportLogAnalyticThrottledRequests
3131
.SYNOPSIS
3232
Test Export Log Analytic Request Rate By Interval
3333
#>
34-
function Test-ExportLogAnalyticRequestRateByInterval
34+
function Test-ExportLogAnalyticRequestRateByIntervalNegative
3535
{
36-
$loc = "West Central US";
36+
$loc = Get-ComputeOperationLocation;
3737
$from = Get-Date -Year 2018 -Month 2 -Day 27 -Hour 9;
3838
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
3939
$sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas';
@@ -49,22 +49,23 @@ Test Export Log Analytics positive scenario
4949
#>
5050
function Test-ExportLogAnalytics
5151
{
52-
$rgname = "hyleelog";
53-
$loc = "West Central US";
52+
$rgname = Get-ComputeTestResourceName;
53+
$loc = Get-ComputeOperationLocation;
5454
$stoname = 'sto' + $rgname;
5555
$stotype = 'Standard_GRS';
5656
$container = "test";
5757
$sastoken = '?fakesas'
5858

59-
#
60-
# In order to record this test, run the following manually in a separate Azure Powershell and replace the value of SAT token.
61-
#
62-
#New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
63-
#New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
64-
#$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;
65-
#Set-AzureRmcurrentStorageAccount -ResourceGroupName $rgname -Name $stoname;
66-
#New-AzureStorageContainer -Name $container;
67-
#$sastoken = Get-AzureStorageContainer -Name $container | New-AzureStorageContainerSASToken -Permission rwdl;
59+
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
60+
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
61+
$key = Get-AzureRmStorageAccountKey -ResourceGroupName $rgname -Name $stoname;
62+
$context = New-AzureStorageContext -StorageAccountName $stoname -StorageAccountKey $key.Key1;
63+
64+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
65+
{
66+
New-AzureStorageContainer -Name $container -Context $context;
67+
$sastoken = Get-AzureStorageContainer -Name $container -Context $context | New-AzureStorageContainerSASToken -Permission rwdl -Context $context;
68+
}
6869

6970
try
7071
{
@@ -76,16 +77,26 @@ function Test-ExportLogAnalytics
7677
Assert-AreEqual "Succeeded" $result.Status;
7778
$output = $result | Out-String;
7879
Assert-True { $output.Contains(".csv"); }
79-
#Assert-AreEqual "a" $output;
80+
Assert-True { $output.Contains("RequestRateByInterval"); }
8081

8182
$result = Export-AzureRmLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
8283
Assert-AreEqual "Succeeded" $result.Status;
8384
$output = $result | Out-String;
8485
Assert-True { $output.Contains(".csv"); }
86+
Assert-True { $output.Contains("ThrottledRequests"); }
87+
88+
if ([Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode -ne [Microsoft.Azure.Test.HttpRecorder.HttpRecorderMode]::Playback)
89+
{
90+
$blobs = Get-AzureStorageBlob -Container test -Context $context;
91+
$request_blob = $blobs | where {$_.name.contains("RequestRateByInterval")};
92+
$throttle_blob = $blobs | where {$_.name.contains("ThrottledRequests")};
93+
Assert-NotNull $request_blob;
94+
Assert-NotNull $throttle_blob;
95+
}
8596
}
8697
finally
8798
{
8899
# Cleanup
89-
#Clean-ResourceGroup $rgname;
100+
Clean-ResourceGroup $rgname;
90101
}
91102
}

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.LogAnalyticTests/TestExportLogAnalyticRequestRateByInterval.json

Lines changed: 0 additions & 151 deletions
This file was deleted.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.LogAnalyticTests/TestExportLogAnalyticRequestRateByIntervalNegative.json

Lines changed: 202 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)