Skip to content

. #13

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 19 commits into from
Jun 2, 2015
Merged

. #13

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
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Common\ComputeTestController.cs" />
<Compile Include="ScenarioTests\VMDynamicTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineProfileTests.cs" />
<Compile Include="ScenarioTests\AvailabilitySetTests.cs" />
<Compile Include="ScenarioTests\VirtualMachineExtensionTests.cs" />
Expand Down Expand Up @@ -193,6 +194,18 @@
<Link>ScenarioTests\Common.ps1</Link>
<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\VMDynamicTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="ScenarioTests\VirtualMachineProfileTests.ps1">
Expand Down Expand Up @@ -276,6 +289,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineWithVMAgentAutoUpdate.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests\RunVMDynamicTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,40 @@ function Get-ComputeTestResourceName
return $assetName
}


<#
.SYNOPSIS
Gets test mode - 'Record' or 'Playback'
#>
function Get-ComputeTestMode
{
$oldErrorActionPreferenceValue = $ErrorActionPreference;
$ErrorActionPreference = "SilentlyContinue";

try
{
$testMode = [Microsoft.Azure.Test.HttpRecorder.HttpMockServer]::Mode;
$testMode = $testMode.ToString();
}
catch
{
if (($Error.Count -gt 0) -and ($Error[0].Exception.Message -like '*Unable to find type*'))
{
$testMode = 'Record';
}
else
{
throw;
}
}
finally
{
$ErrorActionPreference = $oldErrorActionPreferenceValue;
}

return $testMode;
}

######################
#
# Retry the given code block until it succeeds or times out.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

# Warning: This code was generated by a tool.
#
# Changes to this file may cause incorrect behavior and will be lost if the
# code is regenerated.


function get_vm_config_object
{
param ([string] $rgname, [string] $vmsize)

$vmname = 'vm' + $rgname;
$p = New-AzureVMConfig -VMName $vmname -VMSize $vmsize;

return $p;
}


function get_created_storage_account_name
{
param ([string] $loc, [string] $rgname)

$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';

$st = New-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$st = Get-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname;

return $stoname;
}


function create_and_setup_nic_ids
{
param ([string] $loc, [string] $rgname, $vmconfig)

$subnet = New-AzureVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -DnsServer "10.1.1.1" -Subnet $subnet;
$vnet = Get-AzureVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$nic_ids = @($null) * 1;
$nic0 = New-AzureNetworkInterface -Force -Name ('nic0' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId;
$nic_ids[0] = $nic0.Id;
$vmconfig = Add-AzureVMNetworkInterface -VM $vmconfig -Id $nic0.Id -Primary;

return $nic_ids;
}

function create_and_setup_vm_config_object
{
param ([string] $loc, [string] $rgname, [string] $vmsize)

$vmconfig = get_vm_config_object $rgname $vmsize

$user = "Foo12";
$password = "BaR#123" + $rgname;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = "cn" + $rgname;
$vmconfig = Set-AzureVMOperatingSystem -VM $vmconfig -Windows -ComputerName $computerName -Credential $cred;

return $vmconfig;
}


function setup_image_and_disks
{
param ([string] $loc, [string] $rgname, [string] $stoname, $vmconfig)

$osDiskName = 'osDisk';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$osDiskCaching = 'ReadWrite';

$vmconfig = Set-AzureVMOSDisk -VM $vmconfig -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

# Image Reference;
$vmconfig.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$vmconfig = ($imgRef | Set-AzureVMSourceImage -VM $vmconfig);

# TODO: Remove Data Disks for now
$vmconfig.StorageProfile.DataDisks = $null;

return $vmconfig;
}


function ps_vm_dynamic_test_func_1_pstestrg1166
{
# Setup
$rgname = 'pstestrg1166';

try
{
$loc = 'westeurope';
$vmsize = 'Standard_A5';

$st = New-AzureResourceGroup -Location $loc -Name $rgname;

$vmconfig = create_and_setup_vm_config_object $loc $rgname $vmsize;

# Setup Storage Account
$stoname = get_created_storage_account_name $loc $rgname;

# Setup Network Interface IDs
$nicids = create_and_setup_nic_ids $loc $rgname $vmconfig;

# Setup Image and Disks
$st = setup_image_and_disks $loc $rgname $stoname $vmconfig;

# Virtual Machine
$vmname = 'vm' + $rgname;
$st = New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $vmconfig;

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

# Remove
$st = Remove-AzureVM -Name $vmname -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

# Warning: This code was generated by a tool.
#
# Changes to this file may cause incorrect behavior and will be lost if the
# code is regenerated.


function get_vm_config_object
{
param ([string] $rgname, [string] $vmsize)

$vmname = 'vm' + $rgname;
$p = New-AzureVMConfig -VMName $vmname -VMSize $vmsize;

return $p;
}


function get_created_storage_account_name
{
param ([string] $loc, [string] $rgname)

$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';

$st = New-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$st = Get-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname;

return $stoname;
}


function create_and_setup_nic_ids
{
param ([string] $loc, [string] $rgname, $vmconfig)

$subnet = New-AzureVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -DnsServer "10.1.1.1" -Subnet $subnet;
$vnet = Get-AzureVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$nic_ids = @($null) * 1;
$nic0 = New-AzureNetworkInterface -Force -Name ('nic0' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId;
$nic_ids[0] = $nic0.Id;
$vmconfig = Add-AzureVMNetworkInterface -VM $vmconfig -Id $nic0.Id -Primary;

return $nic_ids;
}

function create_and_setup_vm_config_object
{
param ([string] $loc, [string] $rgname, [string] $vmsize)

$vmconfig = get_vm_config_object $rgname $vmsize

$user = "Foo12";
$password = "BaR#123" + $rgname;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = "cn" + $rgname;
$vmconfig = Set-AzureVMOperatingSystem -VM $vmconfig -Windows -ComputerName $computerName -Credential $cred;

return $vmconfig;
}


function setup_image_and_disks
{
param ([string] $loc, [string] $rgname, [string] $stoname, $vmconfig)

$osDiskName = 'osDisk';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$osDiskCaching = 'ReadWrite';

$vmconfig = Set-AzureVMOSDisk -VM $vmconfig -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

# Image Reference;
$vmconfig.StorageProfile.SourceImage = $null;
$imgRef = Get-DefaultCRPImage;
$vmconfig = ($imgRef | Set-AzureVMSourceImage -VM $vmconfig);

# TODO: Remove Data Disks for now
$vmconfig.StorageProfile.DataDisks = $null;

return $vmconfig;
}


function ps_vm_dynamic_test_func_2_pstestrg7266
{
# Setup
$rgname = 'pstestrg7266';

try
{
$loc = 'eastasia';
$vmsize = 'Standard_A5';

$st = New-AzureResourceGroup -Location $loc -Name $rgname;

$vmconfig = create_and_setup_vm_config_object $loc $rgname $vmsize;

# Setup Storage Account
$stoname = get_created_storage_account_name $loc $rgname;

# Setup Network Interface IDs
$nicids = create_and_setup_nic_ids $loc $rgname $vmconfig;

# Setup Image and Disks
$st = setup_image_and_disks $loc $rgname $stoname $vmconfig;

# Virtual Machine
$vmname = 'vm' + $rgname;
$st = New-AzureVM -ResourceGroupName $rgname -Location $loc -Name $vmname -VM $vmconfig;

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

# Remove
$st = Remove-AzureVM -Name $vmname -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Loading