Skip to content

Commit 284befe

Browse files
committed
Merge pull request Azure#187 from huangpf/crp2
[P0] Fix #1: Location & VM Plan
2 parents c91d6c5 + b671845 commit 284befe

25 files changed

+265
-396
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,11 @@
146146
<ItemGroup>
147147
<Compile Include="Common\ComputeTestController.cs" />
148148
<Compile Include="ScenarioTests\StorageAccountTests.cs" />
149-
<Compile Include="ScenarioTests\TestVirtualMachineImageList.cs" />
150-
<Compile Include="ScenarioTests\TestVirtualMachineList.cs" />
151-
<Compile Include="ScenarioTests\VirtualMachinePlanTests.cs" />
152-
<Compile Include="ScenarioTests\VirtualMachineDataDiskTests.cs" />
153-
<Compile Include="ScenarioTests\VirtualMachineCaptureTests.cs" />
154149
<Compile Include="ScenarioTests\VirtualMachineProfileTests.cs" />
155150
<Compile Include="ScenarioTests\AvailabilitySetTests.cs" />
156151
<Compile Include="ScenarioTests\VirtualMachineExtensionTests.cs" />
157152
<Compile Include="ScenarioTests\VirtualMachineNetworkInterfaceTests.cs" />
158-
<Compile Include="ScenarioTests\TestVirtualMachineSizeAndUsage.cs" />
159-
<Compile Include="ScenarioTests\VirtualMachinePIRv2Tests.cs" />
153+
<Compile Include="ScenarioTests\UtilityFunctionTests.cs" />
160154
<Compile Include="ScenarioTests\VirtualMachineTests.cs" />
161155
<Compile Include="Properties\Resources.Designer.cs">
162156
<AutoGen>True</AutoGen>

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachinePlanTests.cs renamed to src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/UtilityFunctionTests.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,36 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Microsoft.Azure.Commands.Compute.Models;
17+
using System;
1618
using Xunit;
1719

1820
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
1921
{
20-
public partial class VirtualMachineTests
22+
public class UtilityFunctionTests
2123
{
2224
[Fact]
2325
[Trait(Category.AcceptanceType, Category.CheckIn)]
24-
public void TestVirtualMachinePlan()
26+
public void TestLocationStringExtension()
2527
{
26-
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan");
27-
}
28+
string[] locations = new string[]
29+
{
30+
"West US",
31+
"eastus",
32+
"East Asia 2"
33+
};
2834

29-
[Fact]
30-
[Trait(Category.AcceptanceType, Category.CheckIn)]
31-
public void TestVirtualMachinePlan2()
32-
{
33-
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan2");
35+
Func<string, string> normalize = delegate(string s)
36+
{
37+
return string.IsNullOrEmpty(s) ? s : s.Replace(" ", string.Empty).ToLower();
38+
};
39+
40+
foreach (var loc in locations)
41+
{
42+
var s1 = loc.Canonicalize();
43+
var s2 = normalize(loc);
44+
Assert.True(string.Equals(s1, s2));
45+
}
3446
}
3547
}
3648
}

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function Test-SingleNetworkInterface
102102
# Image Reference;
103103
$p.StorageProfile.SourceImage = $null;
104104
$imgRef = Get-DefaultCRPImage;
105-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
105+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
106106
Assert-NotNull $p.StorageProfile.ImageReference;
107107
Assert-Null $p.StorageProfile.SourceImageId;
108108

@@ -208,7 +208,7 @@ function Test-SingleNetworkInterfaceDnsSettings
208208
# Image Reference;
209209
$p.StorageProfile.SourceImage = $null;
210210
$imgRef = Get-DefaultCRPImage;
211-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
211+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
212212
Assert-NotNull $p.StorageProfile.ImageReference;
213213
Assert-Null $p.StorageProfile.SourceImageId;
214214

@@ -318,7 +318,7 @@ function Test-MultipleNetworkInterface
318318
# Image Reference;
319319
$p.StorageProfile.SourceImage = $null;
320320
$imgRef = Get-DefaultCRPImage;
321-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
321+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
322322
Assert-NotNull $p.StorageProfile.ImageReference;
323323
Assert-Null $p.StorageProfile.SourceImageId;
324324

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,61 @@ public void TestVirtualMachine()
2525
{
2626
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachine");
2727
}
28+
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
public void TestVirtualMachineImageList()
32+
{
33+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineImageList");
34+
}
35+
36+
[Fact]
37+
[Trait(Category.AcceptanceType, Category.CheckIn)]
38+
public void TestVirtualMachineList()
39+
{
40+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineList");
41+
}
42+
43+
[Fact]
44+
[Trait(Category.AcceptanceType, Category.CheckIn)]
45+
public void TestVirtualMachineSizeAndUsage()
46+
{
47+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineSizeAndUsage");
48+
}
49+
50+
[Fact]
51+
[Trait(Category.AcceptanceType, Category.CheckIn)]
52+
public void TestVirtualMachineCapture()
53+
{
54+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineCapture");
55+
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void TestVirtualMachineDataDisk()
60+
{
61+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineDataDisk");
62+
}
63+
64+
[Fact]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void TestVirtualMachinePIRv2()
67+
{
68+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePIRv2");
69+
}
70+
71+
[Fact]
72+
[Trait(Category.AcceptanceType, Category.CheckIn)]
73+
public void TestVirtualMachinePlan()
74+
{
75+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan");
76+
}
77+
78+
[Fact]
79+
[Trait(Category.AcceptanceType, Category.CheckIn)]
80+
public void TestVirtualMachinePlan2()
81+
{
82+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan2");
83+
}
2884
}
2985
}

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ function Test-VirtualMachineSizeAndUsage
454454
# Image Reference;
455455
$p.StorageProfile.SourceImage = $null;
456456
$imgRef = Get-DefaultCRPImage;
457-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
457+
$p = Set-AzureVMSourceImage -VM $p -PublisherName $imgRef.PublisherName -Offer $imgRef.Offer -Skus $imgRef.Skus -Version $imgRef.Version;
458458
Assert-NotNull $p.StorageProfile.ImageReference;
459459
Assert-Null $p.StorageProfile.SourceImageId;
460460

@@ -620,7 +620,7 @@ function Test-VirtualMachinePIRv2
620620
# Image Reference;
621621
$p.StorageProfile.SourceImage = $null;
622622
$imgRef = Get-DefaultCRPImage;
623-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
623+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
624624
Assert-NotNull $p.StorageProfile.ImageReference;
625625
Assert-Null $p.StorageProfile.SourceImageId;
626626

@@ -730,7 +730,7 @@ function Test-VirtualMachineCapture
730730
# Image Reference;
731731
$p.StorageProfile.SourceImage = $null;
732732
$imgRef = Get-DefaultCRPImage;
733-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
733+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
734734

735735
# TODO: Remove Data Disks for now
736736
$p.StorageProfile.DataDisks = $null;
@@ -825,7 +825,7 @@ function Test-VirtualMachineDataDisk
825825
# Image Reference;
826826
$p.StorageProfile.SourceImage = $null;
827827
$imgRef = Get-DefaultCRPImage;
828-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
828+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
829829

830830
# Negative Tests on A0 Size + 2 Data Disks
831831
Assert-ThrowsContains { New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $p; } "The maximum number of data disks allowed to be attached to a VM is 1.";
@@ -901,10 +901,14 @@ function Test-VirtualMachinePlan
901901
# Image Reference;
902902
$p.StorageProfile.SourceImage = $null;
903903
$imgRef = Get-DefaultCRPImage;
904-
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
904+
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
905905

906906
$plan = Get-ComputeTestResourceName;
907-
$p = Set-AzureVMPlan -VM $p -PlanName $plan -Publisher $plan -Product $plan -PromotionCode $plan;
907+
$p.Plan = New-Object Microsoft.Azure.Management.Compute.Models.Plan;
908+
$p.Plan.Name = $plan;
909+
$p.Plan.Publisher = $plan;
910+
$p.Plan.Product = $plan;
911+
$p.Plan.PromotionCode = $plan;
908912

909913
# Negative Tests on non-existing Plan
910914
Assert-ThrowsContains { New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $p; } "User failed validation to purchase resources";
@@ -985,8 +989,12 @@ function Test-VirtualMachinePlan2
985989
$vmmImgVerName = '1.0.0';
986990
$imgRef = Get-AzureVMImageDetail -PublisherName $vmmImgPubName -Location $loc -Offer $vmmImgOfferName -Skus $vmmImgSkusName -Version $vmmImgVerName;
987991
$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;
992+
$p = Set-AzureVMSourceImage -VM $p -PublisherName $imgRef.PublisherName -Offer $imgRef.Offer -Skus $imgRef.Skus -Version $imgRef.Version;
993+
$p.Plan = New-Object Microsoft.Azure.Management.Compute.Models.Plan;
994+
$p.Plan.Name = $plan.Name;
995+
$p.Plan.Publisher = $plan.Publisher;
996+
$p.Plan.Product = $plan.Product;
997+
$p.Plan.PromotionCode = $null;
990998
$p.OSProfile.WindowsConfiguration = $null;
991999

9921000
New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $p;

0 commit comments

Comments
 (0)