Skip to content

Commit 537e844

Browse files
author
Hovsep
committed
Merge pull request Azure#1708 from yantang-msft/JsonConfig
Support Json format config file when enable diagnostics extension
2 parents 30a8f01 + c2c4c86 commit 537e844

File tree

16 files changed

+11394
-5487
lines changed

16 files changed

+11394
-5487
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@
213213
<Link>ScenarioTests\Common.ps1</Link>
214214
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
215215
</None>
216+
<Content Include="ConfigFiles\DiagnosticsExtensionConfig.json">
217+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
218+
</Content>
216219
<None Include="ScenarioTests\AddVhdTests.ps1">
217220
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
218221
</None>
@@ -281,6 +284,9 @@
281284
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests\TestDiagnosticsExtensionSepcifyStorageAccountName.json">
282285
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
283286
</None>
287+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests\TestDiagnosticsExtensionSupportJsonConfig.json">
288+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
289+
</None>
284290
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DscExtensionTests\TestGetAzureRmVMDscExtension.json">
285291
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
286292
</None>
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"WadCfg": {
3+
"DiagnosticMonitorConfiguration": {
4+
"DiagnosticInfrastructureLogs": {
5+
"scheduledTransferLogLevelFilter": "Error"
6+
},
7+
"Directories": {
8+
"IISLogs": {
9+
"containerName": "wad-iis-logfiles"
10+
},
11+
"FailedRequestLogs": {
12+
"containerName": "wad-failedrequestlogs"
13+
},
14+
"scheduledTransferPeriod": "PT1M"
15+
},
16+
"PerformanceCounters": {
17+
"PerformanceCounterConfiguration": [
18+
{
19+
"annotation": [],
20+
"counterSpecifier": "\\Memory\\Available MBytes",
21+
"sampleRate": "PT3M"
22+
},
23+
{
24+
"annotation": [],
25+
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
26+
"sampleRate": "PT3M"
27+
},
28+
{
29+
"annotation": [],
30+
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
31+
"sampleRate": "PT3M"
32+
},
33+
{
34+
"annotation": [],
35+
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
36+
"sampleRate": "PT3M"
37+
},
38+
{
39+
"annotation": [],
40+
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
41+
"sampleRate": "PT3M"
42+
},
43+
{
44+
"annotation": [],
45+
"counterSpecifier": "\\ASP.NET\\Requests Queued",
46+
"sampleRate": "PT3M"
47+
},
48+
{
49+
"annotation": [],
50+
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
51+
"sampleRate": "PT3M"
52+
},
53+
{
54+
"annotation": [],
55+
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
56+
"sampleRate": "PT3M"
57+
}
58+
],
59+
"scheduledTransferPeriod": "PT1M"
60+
},
61+
"WindowsEventLog": {
62+
"DataSource": [
63+
{
64+
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
65+
},
66+
{
67+
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
68+
}
69+
],
70+
"scheduledTransferPeriod": "PT1M"
71+
},
72+
"CrashDumps": {
73+
"CrashDumpConfiguration": [
74+
{
75+
"processName": "WaIISHost.exe"
76+
},
77+
{
78+
"processName": "WaWorkerHost.exe"
79+
},
80+
{
81+
"processName": "w3wp.exe"
82+
}
83+
]
84+
},
85+
"Logs": {
86+
"scheduledTransferLogLevelFilter": "Error",
87+
"scheduledTransferPeriod": "PT1M"
88+
},
89+
"overallQuotaInMB": 4096
90+
}
91+
}
92+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,12 @@ public void TestDiagnosticsExtensionCantListSepcifyStorageAccountKey()
3939
{
4040
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionCantListSepcifyStorageAccountKey");
4141
}
42+
43+
[Fact]
44+
[Trait(Category.AcceptanceType, Category.CheckIn)]
45+
public void TestDiagnosticsExtensionSupportJsonConfig()
46+
{
47+
ComputeTestController.NewInstance.RunPsTest("Test-DiagnosticsExtensionSupportJsonConfig");
48+
}
4249
}
4350
}

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,47 @@ function Test-DiagnosticsExtensionCantListSepcifyStorageAccountKey
136136
$storagename = 'notexiststorage'
137137
Assert-ThrowsContains `
138138
{ Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath '.\ConfigFiles\DiagnosticsExtensionConfig.xml' -StorageAccountName $storagename } `
139-
'Failed to list storage account key'
139+
'Storage account key'
140+
}
141+
finally
142+
{
143+
# Cleanup
144+
Clean-ResourceGroup $rgname
145+
}
146+
}
147+
148+
<#
149+
.SYNOPSIS
150+
Test that we support config file in json format
151+
#>
152+
function Test-DiagnosticsExtensionSupportJsonConfig
153+
{
154+
$rgname = Get-ComputeTestResourceName
155+
$loc = Get-ComputeVMLocation
156+
157+
try
158+
{
159+
# Setup
160+
$vm = Create-VirtualMachine -rgname $rgname -loc $loc
161+
$vmname = $vm.Name
162+
$storagename = $vmname + "storage"
163+
$storagetype = 'Standard_GRS'
164+
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
165+
166+
# If diagnostics extension already exist, remove it
167+
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
168+
if ($extension) {
169+
Remove-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
170+
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
171+
Assert-Null $extension
172+
}
173+
174+
Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath '.\ConfigFiles\DiagnosticsExtensionConfig.json' -StorageAccountName $storagename
175+
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
176+
177+
Assert-NotNull $extension
178+
$settings = $extension.PublicSettings | ConvertFrom-Json
179+
Assert-AreEqual $settings.storageAccount $storagename
140180
}
141181
finally
142182
{

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests/TestDiagnosticsExtensionBasic.json

Lines changed: 1366 additions & 1806 deletions
Large diffs are not rendered by default.

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.DiagnosticsExtensionTests/TestDiagnosticsExtensionSepcifyStorageAccountName.json

Lines changed: 1537 additions & 3486 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)