Skip to content

Commit 0884f86

Browse files
committed
update test
1 parent 3613b14 commit 0884f86

File tree

3 files changed

+125
-2
lines changed

3 files changed

+125
-2
lines changed

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

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,28 @@ function Get-ComputeTestResourceName
2828
}
2929
}
3030

31-
$assetName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetAssetName($testName, "pstestrg")
31+
$oldErrorActionPreferenceValue = $ErrorActionPreference;
32+
$ErrorActionPreference = "SilentlyContinue";
33+
34+
try
35+
{
36+
$assetName = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::GetAssetName($testName, "pstestrg");
37+
}
38+
catch
39+
{
40+
if (($Error.Count -gt 0) -and ($Error[0].Exception.Message -like '*Unable to find type*'))
41+
{
42+
$assetName = Get-RandomItemName;
43+
}
44+
else
45+
{
46+
throw;
47+
}
48+
}
49+
finally
50+
{
51+
$ErrorActionPreference = $oldErrorActionPreferenceValue;
52+
}
3253

3354
return $assetName
3455
}
@@ -144,7 +165,7 @@ function Get-DefaultRDFEImage
144165

145166
<#
146167
.SYNOPSIS
147-
Gets default RDFE Image
168+
Gets default CRP Image
148169
#>
149170
function Get-DefaultCRPImage
150171
{
@@ -195,6 +216,19 @@ function Get-DefaultCRPImage
195216
return $vmimg;
196217
}
197218

219+
<#
220+
.SYNOPSIS
221+
Gets VMM Images
222+
#>
223+
function Get-MarketplaceImage
224+
{
225+
param([string] $location = "eastasia", [string] $pubFilter = '*', [string] $offerFilter = '*')
226+
227+
$imgs = Get-AzureVMImagePublisher -Location $location | where { $_.PublisherName -like $pubFilter } | Get-AzureVMImageOffer | where { $_.Offer -like $offerFilter } | Get-AzureVMImageSku | Get-AzureVMImage | Get-AzureVMImageDetail | where { $_.PurchasePlan -ne $null };
228+
229+
return $imgs;
230+
}
231+
198232
<#
199233
.SYNOPSIS
200234
Gets default VM config object

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,12 @@ public void TestVirtualMachinePlan()
2525
{
2626
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan");
2727
}
28+
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
public void TestVirtualMachinePlan2()
32+
{
33+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan2");
34+
}
2835
}
2936
}

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,4 +914,86 @@ function Test-VirtualMachinePlan
914914
# Cleanup
915915
Clean-ResourceGroup $rgname
916916
}
917+
}
918+
919+
920+
921+
<#
922+
.SYNOPSIS
923+
Test Virtual Machines Plan 2
924+
#>
925+
function Test-VirtualMachinePlan2
926+
{
927+
# Setup
928+
$rgname = Get-ComputeTestResourceName
929+
930+
try
931+
{
932+
# Common
933+
$loc = 'eastasia';
934+
New-AzureResourceGroup -Name $rgname -Location $loc;
935+
936+
# VM Profile & Hardware
937+
$vmsize = 'Standard_A0';
938+
$vmname = 'vm' + $rgname;
939+
$p = New-AzureVMConfig -VMName $vmname -VMSize $vmsize;
940+
# NRP
941+
$subnet = New-AzureVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
942+
$vnet = New-AzureVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -DnsServer "10.1.1.1" -Subnet $subnet;
943+
$vnet = Get-AzureVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
944+
$subnetId = $vnet.Subnets[0].Id;
945+
$pubip = New-AzurePublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
946+
$pubip = Get-AzurePublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
947+
$pubipId = $pubip.Id;
948+
$nic = New-AzureNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
949+
$nic = Get-AzureNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
950+
$nicId = $nic.Id;
951+
952+
$p = Add-AzureVMNetworkInterface -VM $p -Id $nicId;
953+
954+
# Storage Account (SA)
955+
$stoname = 'sto' + $rgname;
956+
$stotype = 'Standard_GRS';
957+
New-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
958+
$stoaccount = Get-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname;
959+
960+
$osDiskName = 'osDisk';
961+
$osDiskCaching = 'ReadWrite';
962+
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
963+
964+
$p = Set-AzureVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
965+
966+
# OS & Image
967+
$user = "Foo12";
968+
$password = 'BaR@123' + $rgname;
969+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
970+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
971+
$computerName = 'test';
972+
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
973+
$img = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201503.01-en.us-127GB.vhd';
974+
975+
# $p.StorageProfile.OSDisk = $null;
976+
$p = Set-AzureVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
977+
978+
# Image Reference
979+
$p.StorageProfile.SourceImage = $null;
980+
981+
# Pick a VMM Image
982+
$vmmImgPubName = 'a10networks';
983+
$vmmImgOfferName = 'a10-vthunder-adc';
984+
$vmmImgSkusName = 'vthunder_byol';
985+
$vmmImgVerName = '1.0.0';
986+
$imgRef = Get-AzureVMImageDetail -PublisherName $vmmImgPubName -Location $loc -Offer $vmmImgOfferName -Skus $vmmImgSkusName -Version $vmmImgVerName;
987+
$plan = $imgRef.PurchasePlan;
988+
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
989+
$p = Set-AzureVMPlan -VM $p -PlanName $plan.Name -Publisher $plan.Publisher -Product $plan.Product;
990+
$p.OSProfile.WindowsConfiguration = $null;
991+
992+
New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $p;
993+
}
994+
finally
995+
{
996+
# Cleanup
997+
Clean-ResourceGroup $rgname
998+
}
917999
}

0 commit comments

Comments
 (0)