Skip to content

Commit 2cce725

Browse files
committed
Add some unit tests for EventHub support
1 parent 5280d36 commit 2cce725

File tree

5 files changed

+220
-1
lines changed

5 files changed

+220
-1
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/Commands.ServiceManagement.Test.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@
457457
<DesignTime>True</DesignTime>
458458
<DependentUpon>Resource.resx</DependentUpon>
459459
</Compile>
460+
<Compile Include="UnitTests\Cmdlets\IaaS\Extensions\Diagnostics\DiagnosticsHelperTest.cs" />
460461
<Compile Include="UnitTests\Cmdlets\IaaS\Extensions\DSC\DscExtensionConfigurationParsingHelperTests.cs" />
461462
<Compile Include="UnitTests\Cmdlets\IaaS\Extensions\DSC\DscExtensionSettingsSerializerTests.cs" />
462463
<Compile Include="UnitTests\Cmdlets\IaaS\Extensions\DSC\GetAzureVMDscExtensionStatusUnitTest.cs" />
@@ -577,6 +578,12 @@
577578
<None Include="Resources\wrongPara_VHD.csv">
578579
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
579580
</None>
581+
<None Include="Resources\Diagnostics\diagnostics.wadcfgx">
582+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
583+
</None>
584+
<None Include="Resources\Diagnostics\config.json">
585+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
586+
</None>
580587
</ItemGroup>
581588
<ItemGroup>
582589
<Content Include="FunctionalTests\ExtensionTests\MicrosoftAntimalware\AntimalwareConfig.xml" />
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
{
2+
"PublicConfig": {
3+
"WadCfg": {
4+
"DiagnosticMonitorConfiguration": {
5+
"DiagnosticInfrastructureLogs": {
6+
"scheduledTransferLogLevelFilter": "Error"
7+
},
8+
"Directories": {
9+
"IISLogs": {
10+
"containerName": "wad-iis-logfiles"
11+
},
12+
"FailedRequestLogs": {
13+
"containerName": "wad-failedrequestlogs"
14+
},
15+
"scheduledTransferPeriod": "PT1M"
16+
},
17+
"PerformanceCounters": {
18+
"PerformanceCounterConfiguration": [
19+
{
20+
"annotation": [
21+
22+
],
23+
"counterSpecifier": "\\Memory\\Available MBytes",
24+
"sampleRate": "PT15S",
25+
"sinks": "HotPath"
26+
},
27+
{
28+
"annotation": [
29+
30+
],
31+
"counterSpecifier": "\\Web Service(_Total)\\ISAPI Extension Requests/sec",
32+
"sampleRate": "PT3M"
33+
},
34+
{
35+
"annotation": [
36+
37+
],
38+
"counterSpecifier": "\\Web Service(_Total)\\Bytes Total/Sec",
39+
"sampleRate": "PT3M"
40+
},
41+
{
42+
"annotation": [
43+
44+
],
45+
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Requests/Sec",
46+
"sampleRate": "PT3M"
47+
},
48+
{
49+
"annotation": [
50+
51+
],
52+
"counterSpecifier": "\\ASP.NET Applications(__Total__)\\Errors Total/Sec",
53+
"sampleRate": "PT3M"
54+
},
55+
{
56+
"annotation": [
57+
58+
],
59+
"counterSpecifier": "\\ASP.NET\\Requests Queued",
60+
"sampleRate": "PT3M"
61+
},
62+
{
63+
"annotation": [
64+
65+
],
66+
"counterSpecifier": "\\ASP.NET\\Requests Rejected",
67+
"sampleRate": "PT3M"
68+
},
69+
{
70+
"annotation": [
71+
72+
],
73+
"counterSpecifier": "\\Processor(_Total)\\% Processor Time",
74+
"sampleRate": "PT3M"
75+
}
76+
],
77+
"scheduledTransferPeriod": "PT1M"
78+
},
79+
"WindowsEventLog": {
80+
"sinks": "HotPath",
81+
"DataSource": [
82+
{
83+
"name": "Application!*[System[(Level=1 or Level=2 or Level=3)]]"
84+
},
85+
{
86+
"name": "Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]"
87+
}
88+
],
89+
"scheduledTransferPeriod": "PT1M"
90+
},
91+
"CrashDumps": {
92+
"CrashDumpConfiguration": [
93+
{
94+
"processName": "WaIISHost.exe"
95+
},
96+
{
97+
"processName": "WaWorkerHost.exe"
98+
},
99+
{
100+
"processName": "w3wp.exe"
101+
}
102+
]
103+
},
104+
"Logs": {
105+
"scheduledTransferLogLevelFilter": "Error",
106+
"scheduledTransferPeriod": "PT1M"
107+
},
108+
"overallQuotaInMB": 4096
109+
},
110+
"SinksConfig": {
111+
"Sink": [
112+
{
113+
"name": "HotPath",
114+
"EventHub": {
115+
"Url": "Url",
116+
"SharedAccessKeyName": "sasKeyName"
117+
}
118+
}
119+
]
120+
}
121+
},
122+
"StorageAccount": "yanmingv2vm9503"
123+
},
124+
"PrivateConfig": {
125+
"storageAccountName": "storageAccountName",
126+
"storageAccountKey": "storageAccountKey",
127+
"storageAccountEndPoint": "https://core.windows.net/",
128+
"EventHub": {
129+
"Url": "Url",
130+
"SharedAccessKeyName": "sasKeyName",
131+
"SharedAccessKey": "sasKey"
132+
}
133+
}
134+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<DiagnosticsConfiguration xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
3+
<PublicConfig>
4+
<WadCfg>
5+
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
6+
<DiagnosticInfrastructureLogs scheduledTransferLogLevelFilter="Error" />
7+
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error" />
8+
<Directories scheduledTransferPeriod="PT1M">
9+
<IISLogs containerName="wad-iis-logfiles" />
10+
<FailedRequestLogs containerName="wad-failedrequestlogs" />
11+
</Directories>
12+
<WindowsEventLog scheduledTransferPeriod="PT1M">
13+
<DataSource name="Application!*[System[(Level=1 or Level=2 or Level=3)]]" />
14+
<DataSource name="Windows Azure!*[System[(Level=1 or Level=2 or Level=3 or Level=4)]]" />
15+
</WindowsEventLog>
16+
<CrashDumps containerName="wad-crashdumps" dumpType="Mini">
17+
<CrashDumpConfiguration processName="WaIISHost.exe" />
18+
<CrashDumpConfiguration processName="WaWorkerHost.exe" />
19+
<CrashDumpConfiguration processName="w3wp.exe" />
20+
</CrashDumps>
21+
<PerformanceCounters scheduledTransferPeriod="PT1M">
22+
<PerformanceCounterConfiguration counterSpecifier="\Memory\Available MBytes" sampleRate="PT3M" />
23+
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\ISAPI Extension Requests/sec" sampleRate="PT3M" />
24+
<PerformanceCounterConfiguration counterSpecifier="\Web Service(_Total)\Bytes Total/Sec" sampleRate="PT3M" />
25+
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Requests/Sec" sampleRate="PT3M" />
26+
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET Applications(__Total__)\Errors Total/Sec" sampleRate="PT3M" />
27+
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Queued" sampleRate="PT3M" />
28+
<PerformanceCounterConfiguration counterSpecifier="\ASP.NET\Requests Rejected" sampleRate="PT3M" />
29+
<PerformanceCounterConfiguration counterSpecifier="\Processor(_Total)\% Processor Time" sampleRate="PT3M" />
30+
</PerformanceCounters>
31+
<Metrics resourceId="dummy">
32+
<MetricAggregation scheduledTransferPeriod="PT1M"/>
33+
</Metrics>
34+
</DiagnosticMonitorConfiguration>
35+
</WadCfg>
36+
<StorageAccount></StorageAccount>
37+
</PublicConfig>
38+
<PrivateConfig>
39+
<StorageAccount name="" key="" endpoint="" />
40+
<EventHub Url="Url" SharedAccessKeyName="sasKeyName" SharedAccessKey="sasKey"/>
41+
</PrivateConfig>
42+
<IsEnabled>true</IsEnabled>
43+
</DiagnosticsConfiguration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Collections;
2+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Common;
3+
using Xunit;
4+
5+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.UnitTests.Cmdlets.IaaS.Extensions.Diagnostics
6+
{
7+
public class DiagnosticsHelperTest
8+
{
9+
[Fact]
10+
public void TestGetEventHubFromJsonConfig()
11+
{
12+
var table = new Hashtable();
13+
DiagnosticsHelper.AddEventHubPrivateConfig(table, @"Resources\Diagnostics\config.json");
14+
15+
var eventHubConfig = table["EventHub"] as Hashtable;
16+
Assert.NotNull(eventHubConfig);
17+
Assert.Equal(eventHubConfig["Url"], "Url");
18+
Assert.Equal(eventHubConfig["SharedAccessKeyName"], "sasKeyName");
19+
Assert.Equal(eventHubConfig["SharedAccessKey"], "sasKey");
20+
}
21+
22+
[Fact]
23+
public void TestGetEventHubFromXmlConfig()
24+
{
25+
var table = new Hashtable();
26+
DiagnosticsHelper.AddEventHubPrivateConfig(table, @"Resources\Diagnostics\diagnostics.wadcfgx");
27+
28+
var eventHubConfig = table["EventHub"] as Hashtable;
29+
Assert.NotNull(eventHubConfig);
30+
Assert.Equal(eventHubConfig["Url"], "Url");
31+
Assert.Equal(eventHubConfig["SharedAccessKeyName"], "sasKeyName");
32+
Assert.Equal(eventHubConfig["SharedAccessKey"], "sasKey");
33+
}
34+
}
35+
}

src/ServiceManagement/Compute/Commands.ServiceManagement/Common/DiagnosticsHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public static Hashtable GetPrivateDiagnosticsConfiguration(string configurationP
263263
return privateConfig;
264264
}
265265

266-
private static void AddEventHubPrivateConfig(Hashtable privateConfig, string configurationPath)
266+
internal static void AddEventHubPrivateConfig(Hashtable privateConfig, string configurationPath)
267267
{
268268
var eventHubUrl = GetConfigValueFromPrivateConfig(configurationPath, EventHubElemStr, EventHubUrlAttr);
269269
var eventHubSharedAccessKeyName = GetConfigValueFromPrivateConfig(configurationPath, EventHubElemStr, EventHubSharedAccessKeyNameAttr);

0 commit comments

Comments
 (0)