Skip to content

Commit

Permalink
Merge pull request Azure#187 from huangpf/crp2
Browse files Browse the repository at this point in the history
[P0] Fix #1: Location & VM Plan
  • Loading branch information
markcowl committed Apr 28, 2015
2 parents c91d6c5 + b671845 commit 284befe
Show file tree
Hide file tree
Showing 25 changed files with 265 additions and 396 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,11 @@
<ItemGroup>
<Compile Include="Common\ComputeTestController.cs" />
<Compile Include="ScenarioTests\StorageAccountTests.cs" />
<Compile Include="ScenarioTests\TestVirtualMachineImageList.cs" />
<Compile Include="ScenarioTests\TestVirtualMachineList.cs" />
<Compile Include="ScenarioTests\VirtualMachinePlanTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineDataDiskTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineCaptureTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineProfileTests.cs" />
<Compile Include="ScenarioTests\AvailabilitySetTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineExtensionTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineNetworkInterfaceTests.cs" />
<Compile Include="ScenarioTests\TestVirtualMachineSizeAndUsage.cs" />
<Compile Include="ScenarioTests\VirtualMachinePIRv2Tests.cs" />
<Compile Include="ScenarioTests\UtilityFunctionTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineTests.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,36 @@
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.Azure.Commands.Compute.Models;
using System;
using Xunit;

namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public partial class VirtualMachineTests
public class UtilityFunctionTests
{
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachinePlan()
public void TestLocationStringExtension()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan");
}
string[] locations = new string[]
{
"West US",
"eastus",
"East Asia 2"
};

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachinePlan2()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan2");
Func<string, string> normalize = delegate(string s)
{
return string.IsNullOrEmpty(s) ? s : s.Replace(" ", string.Empty).ToLower();
};

foreach (var loc in locations)
{
var s1 = loc.Canonicalize();
var s2 = normalize(loc);
Assert.True(string.Equals(s1, s2));
}
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Test-SingleNetworkInterface
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

Expand Down Expand Up @@ -208,7 +208,7 @@ function Test-SingleNetworkInterfaceDnsSettings
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

Expand Down Expand Up @@ -318,7 +318,7 @@ function Test-MultipleNetworkInterface
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,61 @@ public void TestVirtualMachine()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachine");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineImageList()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineImageList");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineList()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineList");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineSizeAndUsage()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineSizeAndUsage");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineCapture()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineCapture");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineDataDisk()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineDataDisk");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachinePIRv2()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePIRv2");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachinePlan()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachinePlan2()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePlan2");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ function Test-VirtualMachineSizeAndUsage
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = Set-AzureVMSourceImage -VM $p -PublisherName $imgRef.PublisherName -Offer $imgRef.Offer -Skus $imgRef.Skus -Version $imgRef.Version;
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

Expand Down Expand Up @@ -620,7 +620,7 @@ function Test-VirtualMachinePIRv2
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

Expand Down Expand Up @@ -730,7 +730,7 @@ function Test-VirtualMachineCapture
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);

# TODO: Remove Data Disks for now
$p.StorageProfile.DataDisks = $null;
Expand Down Expand Up @@ -825,7 +825,7 @@ function Test-VirtualMachineDataDisk
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);

# Negative Tests on A0 Size + 2 Data Disks
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.";
Expand Down Expand Up @@ -901,10 +901,14 @@ function Test-VirtualMachinePlan
# Image Reference;
$p.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = ($imgRef | Set-AzureVMSourceImage -VM $p);

$plan = Get-ComputeTestResourceName;
$p = Set-AzureVMPlan -VM $p -PlanName $plan -Publisher $plan -Product $plan -PromotionCode $plan;
$p.Plan = New-Object Microsoft.Azure.Management.Compute.Models.Plan;
$p.Plan.Name = $plan;
$p.Plan.Publisher = $plan;
$p.Plan.Product = $plan;
$p.Plan.PromotionCode = $plan;

# Negative Tests on non-existing Plan
Assert-ThrowsContains { New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $p; } "User failed validation to purchase resources";
Expand Down Expand Up @@ -985,8 +989,12 @@ function Test-VirtualMachinePlan2
$vmmImgVerName = '1.0.0';
$imgRef = Get-AzureVMImageDetail -PublisherName $vmmImgPubName -Location $loc -Offer $vmmImgOfferName -Skus $vmmImgSkusName -Version $vmmImgVerName;
$plan = $imgRef.PurchasePlan;
$p = Set-AzureVMSourceImage -VM $p -ImageReference $imgRef;
$p = Set-AzureVMPlan -VM $p -PlanName $plan.Name -Publisher $plan.Publisher -Product $plan.Product;
$p = Set-AzureVMSourceImage -VM $p -PublisherName $imgRef.PublisherName -Offer $imgRef.Offer -Skus $imgRef.Skus -Version $imgRef.Version;
$p.Plan = New-Object Microsoft.Azure.Management.Compute.Models.Plan;
$p.Plan.Name = $plan.Name;
$p.Plan.Publisher = $plan.Publisher;
$p.Plan.Product = $plan.Product;
$p.Plan.PromotionCode = $null;
$p.OSProfile.WindowsConfiguration = $null;

New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $p;
Expand Down
Loading

0 comments on commit 284befe

Please sign in to comment.