Skip to content

Vmss #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 12, 2016
Merged

Vmss #130

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ResourceManager/Compute/AzureRM.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@{

# Version number of this module.
ModuleVersion = '1.2.2'
ModuleVersion = '1.2.3'

# ID used to uniquely identify this module
GUID = '0a83c907-1ffb-4d87-a492-c65ac7d7ed37'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Compute">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.1.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.1.1-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -230,15 +230,6 @@
<None Include="ScenarioTests\DummyConfig.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Generated\VirtualMachineDynamicTest1.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Generated\VirtualMachineDynamicTest2.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\Generated\VirtualMachineDynamicTest3.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\RunnerTests.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -394,6 +385,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineTags.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithBYOL.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithDifferentStorageResource.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public void ExecuteRunnerTests()
var credential = new ClientCredential(testEnv.ClientId, envDictionary["ApplicationSecret"]);

var result = authenticationContext.AcquireToken("https://management.core.windows.net/", clientCredential: credential);

Assert.NotNull(result.AccessToken);
envDictionary["RawToken"] = result.AccessToken;

Expand All @@ -54,7 +55,11 @@ public void ExecuteRunnerTests()
var testClassInstance = constructorInfo.Invoke(new object[] {});
var testMethod = type.GetMethod(method);

Console.WriteLine("Invoking method : " + testMethod);

testMethod.Invoke(testClassInstance, new object[] {});

Console.WriteLine("Method " + testMethod + " has finished");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AvailabilitySetTests;TestAvailabilitySet
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.ComputeCloudExceptionTests;RunComputeCloudExceptionTests
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests;TestLinuxVirtualMachine
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineProfileTests;TestVirtualMachineProfile
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests;RunVMDynamicTests
Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests;RunVMDynamicTests
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.IO;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
Expand All @@ -24,7 +26,7 @@ public partial class VMDynamicTests
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void RunVMDynamicTests()
{
ComputeTestController.NewInstance.RunPsTest("Run-VMDynamicTests");
ComputeTestController.NewInstance.RunPsTest("Run-VMDynamicTests -num_total_generated_tests 1");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,11 @@ public void TestVirtualMachineWithEmptyAuc()
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineWithEmptyAuc");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineWithBYOL()
{
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineWithBYOL");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2091,3 +2091,129 @@ function Test-VirtualMachineWithEmptyAuc
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Virtual Machines
#>
function Test-VirtualMachineWithBYOL
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = "Southeast Asia";
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = 'Standard_A4';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -DnsServer "10.1.1.1" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;

$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;

# Adding the same Nic but not set it Primary
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId -Primary;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Primary $true;

# Storage Account (SA)
$stoname = "mybyolosimage";
$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$userImageUrl = "https://mybyolosimage.blob.core.windows.net/vhdsrc2/win2012-tag0.vhd";

$p = Set-AzureRmVMOSDisk -VM $p -Windows -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -SourceImage $userImageUrl -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
Assert-AreEqual $p.StorageProfile.DataDisks.Count 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;

# OS & Image
$user = "Foo12";
$password = 'BaR@123' + $rgname;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$licenseType = "Windows_Server";

$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent -EnableAutoUpdate;

Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;

# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -LicenseType $licenseType -VM $p;

# Get VM
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;

$output = $vm1 | Out-String;
Write-Verbose ('Output String : ' + $output);
Assert-AreEqual $vm1.Name $vmname;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $nicId;

Assert-AreEqual $vm1.OSProfile.AdminUsername $user;
Assert-AreEqual $vm1.OSProfile.ComputerName $computerName;
Assert-AreEqual $vm1.HardwareProfile.VmSize $vmsize;
Assert-AreEqual $vm1.LicenseType $licenseType;

Assert-AreEqual $true $vm1.DiagnosticsProfile.BootDiagnostics.Enabled;

Get-AzureRmVM -ResourceGroupName $rgname -Name $vmname `
| Add-AzureRmVMDataDisk -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri2 -CreateOption Empty `
| Update-AzureRmVM;

$vm2 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;

Assert-AreEqual $vm2.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $vm2.NetworkProfile.NetworkInterfaces[0].Id $nicId;
Assert-AreEqual $vm2.StorageProfile.DataDisks.Count 2;

Assert-AreEqual $vm2.OSProfile.AdminUsername $user;
Assert-AreEqual $vm2.OSProfile.ComputerName $computerName;
Assert-AreEqual $vm2.HardwareProfile.VmSize $vmsize;
Assert-AreEqual $vm2.LicenseType $licenseType;
Assert-NotNull $vm2.Location;

# Remove All VMs
Get-AzureRmVM -ResourceGroupName $rgname | Remove-AzureRmVM -ResourceGroupName $rgname -Force;
$vms = Get-AzureRmVM -ResourceGroupName $rgname;
Assert-AreEqual $vms $null;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading