Skip to content

Commit b449be4

Browse files
committed
Merge pull request #405 from huangpf/dev
AzureRT PR S49 #1
2 parents 3d88c8c + 9cec9e3 commit b449be4

File tree

16 files changed

+1619
-139
lines changed

16 files changed

+1619
-139
lines changed

src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@
203203
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.AutomationTests\TestAutomationSuspendAndResumeJob.json">
204204
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
205205
</None>
206+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.AzureVMTests\TestGetAzureVM.json">
207+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
208+
</None>
206209
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.SchedulerTests\TestSchedulerEndToEnd.json">
207210
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
208211
</None>
@@ -284,10 +287,10 @@
284287
<Compile Include="Resources\ResourceLocator.cs" />
285288
<Compile Include="Scheduler\SchedulerTests.cs" />
286289
<Compile Include="ServiceBusTests\ServiceBusAuthorizationRuleTests.cs" />
290+
<Compile Include="ServiceManagement\GetVMTests.cs" />
287291
<Compile Include="StorageTests\StorageContainerTest.cs" />
288292
<Compile Include="StorageTests\StorageContextTest.cs" />
289293
<Compile Include="StoreTests\StoreTests.cs" />
290-
<Compile Include="ServiceManagement\VMProvisionScenarioTests.cs" />
291294
<Compile Include="TrafficManagerTests\TrafficManagerTests.cs" />
292295
<Compile Include="WAPackIaaS\CloudService\CmdletTestCloudServiceBase.cs" />
293296
<Compile Include="WAPackIaaS\CloudService\GetWAPackCloudServiceTests.cs" />
@@ -408,7 +411,7 @@
408411
<None Include="Resources\CloudService\Cache\mc.tgz">
409412
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
410413
</None>
411-
<None Include="Resources\ServiceManagement\VMProvisionTests.ps1">
414+
<None Include="Resources\ServiceManagement\AzureVMTests.ps1">
412415
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
413416
</None>
414417
<None Include="Resources\ServiceManagement\Common.ps1">

src/Common/Commands.ScenarioTest/Resources/ServiceManagement/VMProvisionTests.ps1 renamed to src/Common/Commands.ScenarioTest/Resources/ServiceManagement/AzureVMTests.ps1

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,30 @@
1818
.SYNOPSIS
1919
Tests Create-AzureVM with valid information.
2020
#>
21-
function Test-CreateWindowsAzureQuickVM
21+
function Test-GetAzureVM
2222
{
2323
# Setup
24+
2425
$location = Get-DefaultLocation
26+
$imgName = Get-DefaultImage $location
27+
28+
29+
$storageName = getAssetName
30+
New-AzureStorageAccount -StorageAccountName $storageName -Location $location
31+
32+
Set-CurrentStorageAccountName $storageName
33+
34+
$vmName = "vm1"
35+
$svcName = Get-CloudServiceName
2536

2637
# Test
27-
New-AzureQuickVM -Windows -ImageName $imageName -Name $newAzureQuickVMName -ServiceName $newAzureQuickVMSvcName -Password "p@ssw0rd" -Location $location
28-
}
38+
New-AzureService -ServiceName $svcName -Location $location
39+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password "p@ssw0rd"
40+
41+
Get-AzureVM -ServiceName $svcName -Name $vmName
42+
43+
44+
# Cleanup
45+
Cleanup-CloudService $svcName
46+
}
47+

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

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,79 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
1516
<#
1617
.SYNOPSIS
17-
Sets
18+
Sets the default storage account
1819
#>
1920
function Set-CurrentStorageAccountName
2021
{
21-
Get-AzureSubscription -Default | Set-AzureSubscription -CurrentStorageAccountName ""
22-
}
22+
param([string] $storageAccountName)
23+
$currentSubscription = Get-AzureSubscription -Current
24+
25+
Set-AzureSubscription -SubscriptionId $currentSubscription.SubscriptionId -CurrentStorageAccountName $storageAccountName
26+
}
27+
28+
<#
29+
.SYNOPSIS
30+
Gets the default location
31+
#>
32+
function Get-DefaultLocation
33+
{
34+
return (Get-AzureLocation)[0].Name
35+
}
36+
37+
<#
38+
.SYNOPSIS
39+
Gets the default image
40+
#>
41+
function Get-DefaultImage
42+
{
43+
param([string] $loc)
44+
return (Get-AzureVMImage | where {$_.OS -eq "Windows"} | where {$_.Location.Contains($loc)})[0].ImageName
45+
}
46+
47+
48+
<#
49+
.SYNOPSIS
50+
Gets valid and available cloud service name.
51+
#>
52+
function Get-CloudServiceName
53+
{
54+
return getAssetName
55+
}
56+
57+
<#
58+
.SYNOPSIS
59+
Cleanup cloud service
60+
#>
61+
function Cleanup-CloudService
62+
{
63+
param([string] $name)
64+
try
65+
{
66+
Remove-AzureService -ServiceName $name -Force
67+
}
68+
catch
69+
{
70+
Write-Warning "Cannot Remove the Cloud Service"
71+
}
72+
}
73+
74+
<#
75+
.SYNOPSIS
76+
Cleanup storage
77+
#>
78+
function Cleanup-Storage
79+
{
80+
param([string] $name)
81+
Remove-AzureStorageAccount -StorageAccountName $name
82+
try
83+
{
84+
Remove-AzureStorageAccount -StorageAccountName $name
85+
}
86+
catch
87+
{
88+
Write-Warning "Cannot Remove the Storage Account"
89+
}
90+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.Azure.Common.Authentication;
16+
using Microsoft.Azure.Test;
17+
using System.Collections.Generic;
18+
using System.IO;
19+
using System.Linq;
20+
using Xunit;
21+
22+
namespace Microsoft.WindowsAzure.Commands.ScenarioTest
23+
{
24+
public class AzureVMTests
25+
{
26+
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper();
27+
28+
#region Get-AzureVM Scenario Tests
29+
30+
[Fact]
31+
[Trait(Category.Service, Category.ServiceManagement)]
32+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
33+
[Trait(Category.AcceptanceType, Category.BVT)]
34+
public void TestGetAzureVM()
35+
{
36+
this.RunPowerShellTest("Test-GetAzureVM");
37+
}
38+
#endregion
39+
40+
protected void SetupManagementClients()
41+
{
42+
helper.SetupSomeOfManagementClients();
43+
}
44+
45+
protected void RunPowerShellTest(params string[] scripts)
46+
{
47+
using (UndoContext context = UndoContext.Current)
48+
{
49+
context.Start(TestUtilities.GetCallingClass(1), TestUtilities.GetCurrentMethodName(2));
50+
51+
SetupManagementClients();
52+
53+
List<string> modules = Directory.GetFiles("Resources\\ServiceManagement", "*.ps1").ToList();
54+
modules.Add("Common.ps1");
55+
56+
helper.SetupEnvironment(AzureModule.AzureServiceManagement);
57+
helper.SetupModules(AzureModule.AzureServiceManagement, modules.ToArray());
58+
59+
helper.RunPowerShellTest(scripts);
60+
}
61+
}
62+
}
63+
}

src/Common/Commands.ScenarioTest/ServiceManagement/VMProvisionScenarioTests.cs

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

src/Common/Commands.ScenarioTest/SessionRecords/Microsoft.WindowsAzure.Commands.ScenarioTest.AzureVMTests/TestGetAzureVM.json

Lines changed: 1293 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
<Compile Include="Extension\GetAzureVMExtensionCommand.cs" />
165165
<Compile Include="Images\GetAzureVMImageCommand.cs" />
166166
<Compile Include="Models\HashTableExtensions.cs" />
167+
<Compile Include="Models\PSOperation.cs" />
167168
<Compile Include="Extension\VMAccess\GetAzureVMAccessExtension.cs" />
168169
<Compile Include="Extension\VMAccess\RemoveAzureVMAccessExtension.cs" />
169170
<Compile Include="Extension\VMAccess\SetAzureVMAccessExtension.cs" />
@@ -175,7 +176,6 @@
175176
<Compile Include="Images\GetAzureVMImageOfferCommand.cs" />
176177
<Compile Include="Images\GetAzureVMImageDetailCommand.cs" />
177178
<Compile Include="Images\VirtualMachineImageBaseCmdlet.cs" />
178-
<Compile Include="Models\PSOperationContext.cs" />
179179
<Compile Include="Models\PSUsage.cs" />
180180
<Compile Include="Models\PSVirtualMachineExtensionImage.cs" />
181181
<Compile Include="Models\PSVirtualMachineImage.cs" />

src/ResourceManager/Compute/Commands.Compute/Microsoft.Azure.Commands.Compute.format.ps1xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
//
4+
// Copyright (c) Microsoft and contributors. All rights reserved.
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
//
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
19+
// Warning: This code was generated by a tool.
20+
//
21+
// Changes to this file may cause incorrect behavior and will be lost if the
22+
// code is regenerated.
23+
-->
224
<Configuration>
325
<ViewDefinitions>
426
<View>
@@ -10,6 +32,10 @@
1032
<ListEntries>
1133
<ListEntry>
1234
<ListItems>
35+
<ListItem>
36+
<Label>ResourceGroupName</Label>
37+
<PropertyName>ResourceGroupName</PropertyName>
38+
</ListItem>
1339
<ListItem>
1440
<Label>Id</Label>
1541
<PropertyName>Id</PropertyName>
@@ -128,6 +154,10 @@
128154
<ListEntries>
129155
<ListEntry>
130156
<ListItems>
157+
<ListItem>
158+
<Label>ResourceGroupName</Label>
159+
<PropertyName>ResourceGroupName</PropertyName>
160+
</ListItem>
131161
<ListItem>
132162
<Label>Id</Label>
133163
<PropertyName>Id</PropertyName>

0 commit comments

Comments
 (0)