Skip to content

Commit 5582237

Browse files
committed
Update Tests
1 parent c79eaed commit 5582237

File tree

4 files changed

+108164
-693
lines changed

4 files changed

+108164
-693
lines changed

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ function Get-ComputeTestLocation
9494
return $env:AZURE_COMPUTE_TEST_LOCATION;
9595
}
9696

97+
# Get Compute Default Test Location
98+
function Get-ComputeDefaultLocation
99+
{
100+
$test_location = Get-ComputeTestLocation;
101+
if ($test_location -eq '' -or $test_location -eq $null)
102+
{
103+
$test_location = 'westus';
104+
}
105+
106+
return $test_location;
107+
}
108+
97109
# Cleans the created resource group
98110
function Clean-ResourceGroup($rgname)
99111
{
@@ -197,6 +209,36 @@ function Get-DefaultVMSize
197209
return $vmSizes[0].Name;
198210
}
199211

212+
213+
<#
214+
.SYNOPSIS
215+
Gets default RDFE Image
216+
#>
217+
function Get-DefaultRDFEImage
218+
{
219+
param([string] $loca = "East Asia", [string] $query = '*Windows*Data*Center*')
220+
221+
$d = (Azure\Get-AzureVMImage | where {$_.ImageName -like $query -and ($_.Location -like "*;$loca;*" -or $_.Location -like "$loca;*" -or $_.Location -like "*;$loca" -or $_.Location -eq "$loca")});
222+
223+
if ($d -eq $null)
224+
{
225+
return $null;
226+
}
227+
else
228+
{
229+
return $d[-1].ImageName;
230+
}
231+
}
232+
233+
<#
234+
.SYNOPSIS
235+
Gets default storage type string
236+
#>
237+
function Get-DefaultStorageType
238+
{
239+
return 'Standard_GRS';
240+
}
241+
200242
<#
201243
.SYNOPSIS
202244
Gets default CRP Image

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

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,12 @@ function Test-VirtualMachinePlan2
961961
try
962962
{
963963
# Common
964-
$loc = 'westus';
964+
$loc = Get-ComputeDefaultLocation;
965+
965966
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
966967

967968
# VM Profile & Hardware
968-
$vmsize = 'Standard_A0';
969+
$vmsize = Get-DefaultVMSize;
969970
$vmname = 'vm' + $rgname;
970971
$p = New-AzureVMConfig -VMName $vmname -VMSize $vmsize;
971972
# NRP
@@ -984,7 +985,7 @@ function Test-VirtualMachinePlan2
984985

985986
# Storage Account (SA)
986987
$stoname = 'sto' + $rgname;
987-
$stotype = 'Standard_GRS';
988+
$stotype = Get-DefaultStorageType;
988989
New-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
989990
$stoaccount = Get-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname;
990991

@@ -1001,18 +1002,13 @@ function Test-VirtualMachinePlan2
10011002
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
10021003
$computerName = 'test';
10031004
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
1004-
$img = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201503.01-en.us-127GB.vhd';
10051005

10061006
# $p.StorageProfile.OSDisk = $null;
10071007
$p = Set-AzureVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
10081008

10091009
# Image Reference
10101010
# Pick a VMM Image
1011-
$vmmImgPubName = 'a10networks';
1012-
$vmmImgOfferName = 'a10-vthunder-adc';
1013-
$vmmImgSkusName = 'vthunder_byol';
1014-
$vmmImgVerName = '1.0.0';
1015-
$imgRef = Get-AzureVMImage -PublisherName $vmmImgPubName -Location $loc -Offer $vmmImgOfferName -Skus $vmmImgSkusName -Version $vmmImgVerName;
1011+
$imgRef = (Get-MarketplaceImage)[0];
10161012
$plan = $imgRef.PurchasePlan;
10171013
$p = Set-AzureVMSourceImage -VM $p -PublisherName $imgRef.PublisherName -Offer $imgRef.Offer -Skus $imgRef.Skus -Version $imgRef.Version;
10181014
$p.Plan = New-Object Microsoft.Azure.Management.Compute.Models.Plan;
@@ -1321,11 +1317,12 @@ function Test-LinuxVirtualMachine
13211317
# Test Image Cmdlet Output Format
13221318
function Test-VMImageCmdletOutputFormat
13231319
{
1324-
$locStr = 'westus';
1325-
$publisher = 'MicrosoftWindowsServer';
1326-
$offer = 'WindowsServer';
1327-
$sku = '2008-R2-SP1';
1328-
$ver = '2.0.201503';
1320+
$locStr = Get-ComputeDefaultLocation;
1321+
$imgRef = Get-DefaultCRPImage -loc $locStr;
1322+
$publisher = $imgRef.PublisherName;
1323+
$offer = $imgRef.Offer;
1324+
$sku = $imgRef.Skus;
1325+
$ver = $imgRef.Version;
13291326

13301327
Assert-OutputContains " Get-AzureVMImagePublisher -Location $locStr" @('Id', 'Location', 'PublisherName');
13311328

src/ResourceManager/Compute/Commands.Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVMImageCmdletOutputFormat.json

Lines changed: 387 additions & 127 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)