Skip to content

Commit fda7468

Browse files
committed
Merge pull request #80 from Azure/dev
.
2 parents 719cb5d + f12e985 commit fda7468

File tree

67 files changed

+14629
-3971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+14629
-3971
lines changed

ChangeLog.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
## 2015.09.03 version 0.9.8
22
* Azure Compute (ARM) Cmdlets
3-
* Add -Launch parameter for Get-AzureRemoteDesktopFile cmdlet
3+
* Added -Launch parameter for Get-AzureRemoteDesktopFile cmdlet
4+
* Added Id parameter for VM cmdlets to support piping scenario without ResourceGroupName parameter
5+
* Added Set-AzureVMDataDisk cmdlet
6+
* Added Add-AzureVhd cmdlet
7+
* Changed the output format of Get image cmdlets as a table
8+
* Fixed Set-AzureVMAccessExtension cmdlet
9+
* Azure Compute (Service Management) cmdlets
10+
* Changed the warning message to a non-terminating error message for ResourceNotFound in VM cmdlets
11+
* Exposed ComputeImageConfig in Get-AzurePlatformVMImage cmdlet
12+
* Fixed Publish-AzurePlatformExtension and Set-AzurePlatformExtension cmdlets
413
* Azure Backup - added the following cmdlets
514
* Backup-AzureRMBackupItem
615
* Register-AzureRMBackupContainer

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/ServiceManagementTests.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ Tests Create-AzureVM with valid information.
1818
#>
1919
function Test-GetAzureVM
2020
{
21-
# Setup
21+
# Virtual Machine cmdlets are now showing a non-terminating error message for ResourceNotFound
22+
# To continue script, $ErrorActionPreference should be set to 'SilentlyContinue'.
23+
$ErrorActionPreference='SilentlyContinue';
2224

25+
# Setup
2326
$location = Get-DefaultLocation
2427
$imgName = Get-DefaultImage $location
2528

@@ -74,6 +77,10 @@ function Run-ServiceManagementCloudExceptionTests
7477
# Test Start/Stop-AzureVM for Multiple VMs
7578
function Run-StartAndStopMultipleVirtualMachinesTest
7679
{
80+
# Virtual Machine cmdlets are now showing a non-terminating error message for ResourceNotFound
81+
# To continue script, $ErrorActionPreference should be set to 'SilentlyContinue'.
82+
$ErrorActionPreference='SilentlyContinue';
83+
7784
# Setup
7885
$location = Get-DefaultLocation;
7986
$imgName = Get-DefaultImage $location;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
</ItemGroup>
155155
<ItemGroup>
156156
<Compile Include="Common\ComputeTestController.cs" />
157+
<Compile Include="ScenarioTests\AddVhdTests.cs" />
157158
<Compile Include="ScenarioTests\ComputeCloudExceptionTests.cs" />
158159
<Compile Include="ScenarioTests\VMDynamicTests.cs" />
159160
<Compile Include="ScenarioTests\VirtualMachineProfileTests.cs" />
@@ -204,6 +205,9 @@
204205
<Link>ScenarioTests\Common.ps1</Link>
205206
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
206207
</None>
208+
<None Include="ScenarioTests\AddVhdTests.ps1">
209+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
210+
</None>
207211
<None Include="ScenarioTests\ComputeCloudExceptionTests.ps1">
208212
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
209213
</None>
@@ -239,6 +243,9 @@
239243
<None Include="ScenarioTests\VirtualMachineTests.ps1">
240244
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
241245
</None>
246+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AddVhdTests\TestAddVhd.json">
247+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
248+
</None>
242249
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.AvailabilitySetTests\TestAvailabilitySet.json">
243250
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
244251
</None>
@@ -305,6 +312,9 @@
305312
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineListWithPaging.json">
306313
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
307314
</None>
315+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePiping.json">
316+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
317+
</None>
308318
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePIRv2.json">
309319
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
310320
</None>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
19+
{
20+
public class AddVhdTests
21+
{
22+
[Fact(Skip = "TODO: only works for live mode")]
23+
[Trait(Category.RunType, Category.LiveOnly)]
24+
public void TestAddVhd()
25+
{
26+
ComputeTestController.NewInstance.RunPsTest("Test-AddVhd");
27+
}
28+
}
29+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
Test Add Vhd
18+
#>
19+
function Test-AddVhd
20+
{
21+
# Setup
22+
$rgname = Get-ComputeTestResourceName
23+
24+
try
25+
{
26+
# Common
27+
$loc = Get-ComputeVMLocation;
28+
New-AzureResourceGroup -Name $rgname -Location $loc -Force;
29+
30+
# Storage Account (SA)
31+
$stoname = 'sto' + $rgname;
32+
$stotype = 'Standard_GRS';
33+
New-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
34+
$stoaccount = Get-AzureStorageAccount -ResourceGroupName $rgname -Name $stoname;
35+
$storageKey = Get-AzureStorageAccountKey -ResourceGroupName $rgname -Name $stoname;
36+
$vhdContainerName = 'vhds';
37+
38+
$path = (get-item -path ".\").FullName;
39+
40+
$csvFile = "upload_VHD.csv";
41+
$csvPath = "..\..\..\..\..\ServiceManagement\Compute\Commands.ServiceManagement.Test\Resources\" + $csvFile;
42+
$testData = Import-Csv $csvPath;
43+
44+
foreach ($testItem in $testData)
45+
{
46+
$vhdLocalPath = 'e:\vhdstore\' + $testItem.vhdName;
47+
$vhdName = GetFileNameWithoutExtension $testItem.vhdName;
48+
$vhdDestUri = [System.String]::Format("{0}{1}/{2}{3}.vhd", $stoaccount.PrimaryEndpoints.Blob.AbsoluteUri, $vhdContainerName, $vhdName, $rgname);
49+
Write-Output ("Start Uploading... : " + $testItem.vhdName);
50+
51+
$vhdUploadContext = Add-AzureVhd -ResourceGroupName $rgname -Destination $vhdDestUri -LocalFilePath $vhdLocalPath -NumberOfUploaderThreads 1;
52+
Start-Sleep -s 5;
53+
54+
Write-Output ("Destination Uri :" + $vhdUploadContext.DestinationUri);
55+
Write-Output ("Local File :" + $vhdUploadContext.LocalFilePath.FullName);
56+
Write-Output ("Uploading Ended.");
57+
58+
Assert-NotNull $vhdUploadContext;
59+
Assert-AreEqual $vhdDestUri $vhdUploadContext.DestinationUri;
60+
Assert-AreEqual $vhdLocalPath $vhdUploadContext.LocalFilePath.FullName;
61+
62+
Write-Output ($vhdDestUri);
63+
Write-Output ($storageKey.Key1);
64+
65+
$destBlobHandle = GetBlobHandle $vhdDestUri $storageKey.Key1;
66+
Assert-True {VerifyMD5hash $destBlobHandle $testItem.md5hash};
67+
}
68+
}
69+
finally
70+
{
71+
# Cleanup
72+
Clean-ResourceGroup $rgname
73+
}
74+
}
75+
76+
function GetFileNameWithoutExtension ($fileName)
77+
{
78+
$fileName.Substring(0, $fileName.IndexOf('.'));
79+
}
80+
81+
function GetBlobHandle
82+
{
83+
param([string] $blobString, [string] $storageKey)
84+
85+
$blobPath = [Microsoft.WindowsAzure.Commands.Sync.Download.BlobUri] $null;
86+
[Microsoft.WindowsAzure.Commands.Sync.Download.BlobUri]::TryParseUri($blobString, [REF]$blobPath);
87+
$blob = [Microsoft.WindowsAzure.Commands.Sync.Download.BlobHandle]::new($blobPath, $storageKey);
88+
return [Microsoft.WindowsAzure.Commands.Sync.Download.BlobHandle] $blob;
89+
}
90+
91+
function VerifyMD5hash
92+
{
93+
param([System.Object] $blobHandle, [string] $md5hash)
94+
95+
$blobMd5 = $blobHandle.Blob.Properties.ContentMD5;
96+
Write-Output ("MD5 hash of the local file: " + $md5hash);
97+
if ([System.String]::IsNullOrEmpty($blobMd5))
98+
{
99+
Write-Output ("The blob does not have MD5 value!!!");
100+
return $false;
101+
}
102+
else
103+
{
104+
Write-Output ("MD5 hash of blob, "+ $blobHandle.Blob.Uri.ToString() + ", is "+ $blobMd5);
105+
return $blobMd5.Equals($md5hash);
106+
}
107+
}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,6 @@ function Test-VirtualMachineAccessExtension
726726
Assert-AreEqual $p.OSProfile.AdminPassword $password;
727727
Assert-AreEqual $p.OSProfile.WindowsConfiguration.ProvisionVMAgent $true;
728728

729-
# TODO : The test is outdated, need re-recording and re-enabling these fields for validation
730-
#
731-
# Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer;
732-
# Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
733-
# Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus;
734-
# Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;
735-
736729
# Virtual Machine
737730
# TODO: Still need to do retry for New-AzureVM for SA, even it's returned in Get-.
738731
New-AzureVM -ResourceGroupName $rgname -Location $loc -VM $p;
@@ -758,6 +751,7 @@ function Test-VirtualMachineAccessExtension
758751
Assert-AreEqual $ext.TypeHandlerVersion $extver;
759752
Assert-AreEqual $ext.UserName $user2;
760753
Assert-NotNull $ext.ProvisioningState;
754+
Assert-True {$ext.PublicSettings.Contains("UserName")};
761755

762756
$ext = Get-AzureVMAccessExtension -ResourceGroupName $rgname -VMName $vmname -Name $extname -Status;
763757
Assert-AreEqual $ext.ResourceGroupName $rgname;
@@ -767,20 +761,14 @@ function Test-VirtualMachineAccessExtension
767761
Assert-AreEqual $ext.TypeHandlerVersion $extver;
768762
Assert-NotNull $ext.ProvisioningState;
769763
Assert-NotNull $ext.Statuses;
764+
Assert-True {$ext.PublicSettings.Contains("UserName")};
770765

771766
# Get VM
772767
$vm1 = Get-AzureVM -Name $vmname -ResourceGroupName $rgname;
773768
Assert-AreEqual $vm1.Name $vmname;
774769
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces.Count 1;
775770
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].ReferenceUri $nicId;
776771

777-
# TODO : The test is outdated, need re-recording and re-enabling these fields for validation
778-
#
779-
# Assert-AreEqual $vm1.StorageProfile.ImageReference.Offer $imgRef.Offer;
780-
# Assert-AreEqual $vm1.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
781-
# Assert-AreEqual $vm1.StorageProfile.ImageReference.Sku $imgRef.Skus;
782-
# Assert-AreEqual $vm1.StorageProfile.ImageReference.Version $imgRef.Version;
783-
784772
Assert-AreEqual $vm1.OSProfile.AdminUsername $user;
785773
Assert-AreEqual $vm1.OSProfile.ComputerName $computerName;
786774
Assert-AreEqual $vm1.HardwareProfile.VirtualMachineSize $vmsize;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ public void TestVirtualMachine()
2626
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachine");
2727
}
2828

29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
public void TestVirtualMachinePiping()
32+
{
33+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachinePiping");
34+
}
35+
2936
[Fact]
3037
[Trait(Category.AcceptanceType, Category.CheckIn)]
3138
public void TestLinuxVirtualMachine()

0 commit comments

Comments
 (0)