Skip to content

Commit a756a4b

Browse files
authored
Merge pull request #629 from Azure/dev
huangpf PR: dev <- Azure:dev
2 parents f705bee + fe88464 commit a756a4b

File tree

11 files changed

+5744
-5778
lines changed

11 files changed

+5744
-5778
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/ConfigFiles/DiagnosticsExtensionConfig.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
</Metrics>
3232
</DiagnosticMonitorConfiguration>
3333
</WadCfg>
34-
<StorageAccount>definedinconfigstorage</StorageAccount>
34+
<StorageAccount>[StorageAccountName]</StorageAccount>
3535
</PublicConfig>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"storageAccountName": "definedinconfigstorage"
2+
"storageAccountName": "[StorageAccountName]"
33
}

src/ResourceManager/Compute/Commands.Compute.Test/ConfigFiles/DiagnosticsExtensionPublicConfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@
9797
"overallQuotaInMB": 4096
9898
}
9999
},
100-
"StorageAccount": "definedinconfigstorage"
100+
"StorageAccount": "[StorageAccountName]"
101101
}

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

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
<#
16+
.SYNOPSIS
17+
Generate new WAD config file from given template and storage account name
18+
#>
19+
function New-WADConfigFromTemplate ($inputPath, $outputPath, $storageAccountName)
20+
{
21+
(Get-Content $inputPath).replace('[StorageAccountName]', $storageAccountName) | Set-Content $outputPath;
22+
}
23+
1524
<#
1625
.SYNOPSIS
1726
Test the basic usage of the Set/Get/Remove virtual machine diagnostics extension command
@@ -28,7 +37,7 @@ function Test-DiagnosticsExtensionBasic
2837
$vmname = $vm.Name
2938

3039
# This is the storage name defined in config file
31-
$storagename = 'definedinconfigstorage'
40+
$storagename = 'stoinconfig' + $rgname
3241
$storagetype = 'Standard_GRS'
3342
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
3443

@@ -40,8 +49,13 @@ function Test-DiagnosticsExtensionBasic
4049
Assert-Null $extension
4150
}
4251

52+
$configTemplate = "$TestOutputRoot\ConfigFiles\DiagnosticsExtensionConfig.xml";
53+
$configFilePath = "$TestOutputRoot\ConfigFiles\config-$rgname.xml";
54+
55+
New-WADConfigFromTemplate $configTemplate $configFilePath $storagename;
56+
4357
# Test Set and Get command. It should use the storage account defined in configuration file
44-
Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath "$TestOutputRoot\ConfigFiles\DiagnosticsExtensionConfig.xml"
58+
Set-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname -DiagnosticsConfigurationPath $configFilePath
4559
$extension = Get-AzureRmVMDiagnosticsExtension -ResourceGroupName $rgname -VMName $vmname
4660

4761
Assert-NotNull $extension
@@ -60,6 +74,11 @@ function Test-DiagnosticsExtensionBasic
6074
{
6175
# Cleanup
6276
Clean-ResourceGroup $rgname
77+
78+
if (Test-Path $configFilePath)
79+
{
80+
Remove-Item $configFilePath;
81+
}
6382
}
6483
}
6584

@@ -80,7 +99,7 @@ function Test-DiagnosticsExtensionSepcifyStorageAccountName
8099
$vmname = $vm.Name
81100

82101
# This storage name will be used in command line directly when set diagnostics extension
83-
$storagename = 'definedincommandline'
102+
$storagename = 'stoincmd' + $rgname
84103
$storagetype = 'Standard_GRS'
85104
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype
86105

@@ -228,7 +247,7 @@ function Test-VmssDiagnosticsExtension
228247
$diagExtType = 'IaaSDiagnostics';
229248

230249
# This storage name will be used in command line directly when set diagnostics extension
231-
$storagename = 'definedinconfigstorage';
250+
$storagename = 'stoinconfig' + $rgname;
232251
$storagetype = 'Standard_GRS';
233252
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $storagename -Location $loc -Type $storagetype;
234253

@@ -242,8 +261,15 @@ function Test-VmssDiagnosticsExtension
242261

243262
# Full parameter test
244263
$version = '1.5';
245-
$publicSettingFilePath = "$TestOutputRoot\ConfigFiles\DiagnosticsExtensionPublicConfig.json";
246-
$privateSettingFilePath = "$TestOutputRoot\ConfigFiles\DiagnosticsExtensionPrivateConfig.json";
264+
$publicSettingTemplate = "$TestOutputRoot\ConfigFiles\DiagnosticsExtensionPublicConfig.json";
265+
$privateSettingTemplate = "$TestOutputRoot\ConfigFiles\DiagnosticsExtensionPrivateConfig.json";
266+
267+
$publicSettingFilePath = "$TestOutputRoot\ConfigFiles\publicconfig-$rgname.json";
268+
$privateSettingFilePath = "$TestOutputRoot\ConfigFiles\privateconfig-$rgname.json";
269+
270+
New-WADConfigFromTemplate $publicSettingTemplate $publicSettingFilePath $storagename
271+
New-WADConfigFromTemplate $privateSettingTemplate $privateSettingFilePath $storagename
272+
247273
$vmss = Add-AzureRmVmssDiagnosticsExtension -VirtualMachineScaleSet $vmss -Name $extname -SettingFilePath $publicSettingFilePath `
248274
-ProtectedSettingFilePath $privateSettingFilePath -TypeHandlerVersion $version -AutoUpgradeMinorVersion $false -Force;
249275

@@ -292,5 +318,15 @@ function Test-VmssDiagnosticsExtension
292318
{
293319
# Cleanup
294320
Clean-ResourceGroup $rgname
321+
322+
if (Test-Path $publicSettingFilePath)
323+
{
324+
Remove-Item $publicSettingFilePath;
325+
}
326+
327+
if (Test-Path $privateSettingFilePath)
328+
{
329+
Remove-Item $privateSettingFilePath;
330+
}
295331
}
296332
}

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

Lines changed: 1212 additions & 1547 deletions
Large diffs are not rendered by default.

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

Lines changed: 1034 additions & 981 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: 1233 additions & 1394 deletions
Large diffs are not rendered by default.

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

Lines changed: 1296 additions & 1013 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)