Skip to content

Commit ff9b345

Browse files
committed
Add 'Write-Output' for dynamic tests
1 parent 047f836 commit ff9b345

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,25 @@
1414

1515
function get_all_vm_locations
1616
{
17+
$st = Write-Output 'Getting all Azure location - Start';
18+
1719
$locations = Get-AzureLocation | where { $_.Name -like 'Microsoft.Compute/virtualMachines' } | select -ExpandProperty Locations;
1820

21+
$st = Write-Output 'Getting all Azure location - End';
22+
1923
return $locations;
2024
}
2125

2226
function get_all_standard_vm_sizes
2327
{
2428
param ([string] $location)
2529

30+
$st = Write-Output "Getting all VM sizes in location '${location}' - Start";
31+
2632
$vmsizes = Get-AzureVMSize -Location $location | where { $_.Name -like 'Standard_A*' -and $_.NumberOfCores -le 4 } | select -ExpandProperty Name;
2733

34+
$st = Write-Output "Getting all VM sizes in location [${location}] - End";
35+
2836
return $vmsizes;
2937
}
3038

@@ -33,6 +41,8 @@ function get_hash_int_value
3341
# Reference: http://www.cse.yorku.ca/~oz/hash.html
3442
param ([string] $seedstr)
3543

44+
$st = Write-Output "Computing hash for '${seedstr}' - Start";
45+
3646
if ($seedstr -eq $null) { $seedstr = ''; }
3747

3848
[System.Int32]$hash = 5381;
@@ -42,6 +52,10 @@ function get_hash_int_value
4252
$hash = ((($hash -shl 5) + $hash) + $c) % [System.Int32]::MaxValue;
4353
}
4454

55+
$st = Write-Output "Computing hash for '${seedstr}' - `$hash = ${hash}";
56+
57+
$st = Write-Output "Computing hash for '${seedstr}' - End";
58+
4559
return $hash;
4660
}
4761

@@ -75,9 +89,13 @@ function get_vm_config_object
7589
{
7690
param ([string] $rgname, [string] $vmsize)
7791
92+
$st = Write-Output "Creating VM Config Object - Start";
93+
7894
$vmname = 'vm' + $rgname;
7995
$p = New-AzureVMConfig -VMName $vmname -VMSize $vmsize;
8096
97+
$st = Write-Output "Creating VM Config Object - End";
98+
8199
return $p;
82100
}
83101
@@ -90,11 +108,17 @@ function get_created_storage_account_name
90108
{
91109
param ([string] $loc, [string] $rgname)
92110
111+
$st = Write-Output "Creating and getting storage account for '${loc}' and '${rgname}' - Start";
112+
93113
$stoname = 'sto' + $rgname;
94114
$stotype = 'Standard_GRS';
95115
116+
$st = Write-Output "Creating and getting storage account for '${loc}' and '${rgname}' - '${stotype}' & '${stoname}'";
117+
96118
$st = New-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
97119
$st = Get-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname;
120+
121+
$st = Write-Output "Creating and getting storage account for '${loc}' and '${rgname}' - End";
98122
99123
return $stoname;
100124
}
@@ -112,6 +136,8 @@ function create_and_setup_nic_ids
112136
{
113137
param ([string] $loc, [string] $rgname, $vmconfig)
114138
139+
$st = Write-Output "Creating and getting NICs for '${loc}' and '${rgname}' - Start";
140+
115141
$subnet = New-AzureVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
116142
$vnet = New-AzureVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -DnsServer "10.1.1.1" -Subnet $subnet;
117143
$vnet = Get-AzureVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
@@ -158,6 +184,7 @@ function create_and_setup_nic_ids
158184

159185
$fn_end =
160186
@'
187+
$st = Write-Output "Creating and getting NICs for '${loc}' and '${rgname}' - End";
161188
162189
return $nic_ids;
163190
}
@@ -174,6 +201,8 @@ function create_and_setup_vm_config_object
174201
{
175202
param ([string] $loc, [string] $rgname, [string] $vmsize)
176203
204+
$st = Write-Output "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - Start";
205+
177206
$vmconfig = get_vm_config_object $rgname $vmsize
178207
179208
$user = "Foo12";
@@ -183,6 +212,8 @@ function create_and_setup_vm_config_object
183212
$computerName = "cn" + $rgname;
184213
$vmconfig = Set-AzureVMOperatingSystem -VM $vmconfig -Windows -ComputerName $computerName -Credential $cred;
185214
215+
$st = Write-Output "Creating and setting up the VM config object for '${loc}', '${rgname}' and '${vmsize}' - End";
216+
186217
return $vmconfig;
187218
}
188219
@@ -197,6 +228,8 @@ function setup_image_and_disks
197228
{
198229
param ([string] $loc, [string] $rgname, [string] $stoname, $vmconfig)
199230
231+
$st = Write-Output "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - Start";
232+
200233
$osDiskName = 'osDisk';
201234
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
202235
$osDiskCaching = 'ReadWrite';
@@ -211,6 +244,8 @@ function setup_image_and_disks
211244
# Do not add any data disks
212245
$vmconfig.StorageProfile.DataDisks = $null;
213246
247+
$st = Write-Output "Setting up image and disks of VM config object jfor '${loc}', '${rgname}' and '${stoname}' - End";
248+
214249
return $vmconfig;
215250
}
216251
@@ -224,13 +259,17 @@ function Run-VMDynamicTests
224259
{
225260
param ([int] $num_total_generated_tests = 3, [string] $base_folder = '.\ScenarioTests\Generated')
226261

262+
$st = Write-Output 'Running VM Dynamic Tests - Start';
263+
227264
[bool] $isRecordMode = $true;
228265
$testMode = Get-ComputeTestMode;
229266
if ($testMode.ToLower() -eq 'playback')
230267
{
231268
$isRecordMode = $false;
232269
}
233270

271+
$st = Write-Output "Running VM Dynamic Tests - `$isRecordMode = $isRecordMode";
272+
234273
$generated_file_names = @($null) * $num_total_generated_tests;
235274
$generated_func_names = @($null) * $num_total_generated_tests;
236275
$generated_rgrp_names = @($null) * $num_total_generated_tests;
@@ -249,6 +288,8 @@ function Run-VMDynamicTests
249288

250289
$generated_func_name = 'ps_vm_dynamic_test_func_' + $index + '_' + $rgname_str;
251290
$generated_func_names[$i] = $generated_func_name;
291+
292+
$st = Write-Output "Running VM Dynamic Tests - File & Test Name #${index}: ${generated_file_name} & ${generated_func_name}";
252293
}
253294

254295
$locations = get_all_vm_locations;
@@ -261,7 +302,8 @@ function Run-VMDynamicTests
261302
$generated_file_name = $generated_file_names[$i];
262303
$generated_func_name = $generated_func_names[$i];
263304

264-
# $st = Write-Host ('Generating Test #' + (1 + $i));
305+
$st = Write-Output ('Running VM Dynamic Tests - Generating Test #' + (1 + $i));
306+
265307
# Generate New Dynamic Test Files
266308
$st = New-Item -Path $generated_file_name -Type File -Value '' -Force;
267309
$st = $comment_header_str | Out-File -Encoding ASCII -Append -FilePath $generated_file_name -Force;
@@ -322,6 +364,8 @@ function ${generated_func_name}
322364
323365
"@;
324366
$st = $fn_body | Out-File -Encoding ASCII -Append -FilePath $generated_file_name -Force;
367+
368+
$st = Write-Output ('Running VM Dynamic Tests - Generated Function #' + (1 + $i) + ' : ' + $fn_body);
325369
}
326370
}
327371

@@ -331,6 +375,11 @@ function ${generated_func_name}
331375
$st = . "$generated_file_name";
332376

333377
$generated_func_name = $generated_func_names[$i];
378+
379+
$st = Write-Output ('Running VM Dynamic Tests - Invoking Function #' + (1 + $i) + ' : ' + $generated_func_name);
380+
334381
$st = Invoke-Expression -Command $generated_func_name;
335382
}
383+
384+
$st = Write-Output 'Running VM Dynamic Tests - End';
336385
}

0 commit comments

Comments
 (0)