Skip to content

Commit 0addc20

Browse files
hyonholeeHovsep
authored andcommitted
Add -Redeploy parameter for Restart-AzureVM, add -Validate paramter for migration cmdlets, and add tests. (#2583)
1 parent d21a02e commit 0addc20

File tree

60 files changed

+4550
-1914
lines changed

Some content is hidden

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

60 files changed

+4550
-1914
lines changed

src/ServiceManagement/Common/Commands.Common.Test/Commands.Common.Test.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@
124124
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
125125
</Reference>
126126
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
127-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.8.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
127+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.13.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
128128
</Reference>
129129
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
130-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
130+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.6.0.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
131131
</Reference>
132132
<Reference Include="Microsoft.WindowsAzure.Storage, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
133133
<SpecificVersion>False</SpecificVersion>

src/ServiceManagement/Common/Commands.Common.Test/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.2.4-preview" targetFramework="net45" />
2020
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.0" targetFramework="net45" />
2121
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
22-
<package id="Microsoft.WindowsAzure.Management.Storage" version="6.0.0" targetFramework="net45" />
23-
<package id="Microsoft.WindowsAzure.Management.Compute" version="12.8.0" targetFramework="net45" />
22+
<package id="Microsoft.WindowsAzure.Management.Storage" version="6.0.1" targetFramework="net45" />
23+
<package id="Microsoft.WindowsAzure.Management.Compute" version="13.0.0" targetFramework="net45" />
2424
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />
2525
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
2626
<package id="System.Spatial" version="5.6.4" targetFramework="net45" />

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@
115115
<Reference Include="Microsoft.WindowsAzure.Management">
116116
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
117117
</Reference>
118-
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=12.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
118+
<Reference Include="Microsoft.WindowsAzure.Management.Compute, Version=13.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
119119
<SpecificVersion>False</SpecificVersion>
120-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.8.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
120+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Compute.13.0.0\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
121121
</Reference>
122122
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
123-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.1.2\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
123+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Network.7.1.3\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
124124
<Private>True</Private>
125125
</Reference>
126126
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
127-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.6.0.0\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
127+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Storage.6.0.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
128128
</Reference>
129129
<Reference Include="Microsoft.WindowsAzure.Management.WebSites, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
130130
<SpecificVersion>False</SpecificVersion>
@@ -289,6 +289,9 @@
289289
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunNewAzureComputeParameterObjectTests.json">
290290
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
291291
</None>
292+
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunRedeployVirtualMachineTest.json">
293+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
294+
</None>
292295
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceDeploymentExtensionCmdletTests.json">
293296
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
294297
</None>

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<#
1+
$PLACEHOLDER = "PLACEHOLDER1@";
2+
3+
<#
24
.SYNOPSIS
35
End to end DSC test that tests Get-AzureVMDscExtension cmdlet. It does the following:
46
1) Publishes a configuration to the default storage account using Publish-AzureVMDscConfiguration cmdlet
@@ -34,8 +36,7 @@ function Test-GetAzureVMDscExtension
3436

3537
# Test
3638
New-AzureService -ServiceName $svcName -Location $location
37-
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
38-
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password "p@ssw0rd"
39+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password $PLACEHOLDER
3940

4041
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName
4142

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

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
$PLACEHOLDER = "PLACEHOLDER1@";
16+
1517
<#
1618
.SYNOPSIS
1719
Tests Create-AzureVM with valid information.
@@ -33,8 +35,7 @@ function Test-GetAzureVM
3335

3436
# Test
3537
New-AzureService -ServiceName $svcName -Location $location
36-
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
37-
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password "p@ssw0rd"
38+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password $PLACEHOLDER
3839

3940
Get-AzureVM -ServiceName $svcName -Name $vmName
4041

@@ -92,7 +93,7 @@ function Run-StartAndStopMultipleVirtualMachinesTest
9293
$vmNameList = @("vm01", "vm02", "test04");
9394
$svcName = 'pstest' + (Get-CloudServiceName);
9495
$userName = "pstestuser";
95-
$password = "p@ssw0rd";
96+
$password = $PLACEHOLDER;
9697

9798
# Test
9899
New-AzureService -ServiceName $svcName -Location $location;
@@ -153,7 +154,7 @@ function Run-AutoGeneratedHostedServiceCmdletTests
153154
$vmNameList = @("vm01", "vm02", "test04");
154155
$svcName = 'pstest' + (Get-CloudServiceName);
155156
$userName = "pstestuser";
156-
$password = "p@ssw0rd";
157+
$password = $PLACEHOLDER;
157158

158159
try
159160
{
@@ -220,7 +221,7 @@ function Run-AutoGeneratedVirtualMachineCmdletTests
220221

221222
$svcName = 'pstest' + (Get-CloudServiceName);
222223
$userName = "pstestuser";
223-
$password = "p@ssw0rd";
224+
$password = $PLACEHOLDER;
224225

225226
try
226227
{
@@ -480,7 +481,7 @@ function Run-ServiceExtensionSetCmdletTests
480481

481482
$svcName = 'pstest' + (Get-CloudServiceName);
482483
$userName = "pstestuser";
483-
$password = "p@ssw0rd";
484+
$password = $PLACEHOLDER;
484485
$sPassword = ConvertTo-SecureString $password -AsPlainText -Force;
485486
$credential = New-Object System.Management.Automation.PSCredential ($userName, $sPassword);
486487

@@ -542,7 +543,7 @@ function Run-ServiceDeploymentExtensionCmdletTests
542543

543544
$svcName = 'pstest' + (Get-CloudServiceName);
544545
$userName = "pstestuser";
545-
$password = "p@ssw0rd";
546+
$password = $PLACEHOLDER;
546547
$sPassword = ConvertTo-SecureString $password -AsPlainText -Force;
547548
$credential = New-Object System.Management.Automation.PSCredential ($userName, $sPassword);
548549

@@ -630,8 +631,7 @@ function Test-MigrateAzureDeployment
630631

631632
# Test
632633
New-AzureService -ServiceName $svcName -Location $location;
633-
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
634-
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password "p@ssw0rd";
634+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password $PLACEHOLDER;
635635
Get-AzureVM -ServiceName $svcName -Name $vmName;
636636

637637
Move-AzureService -Prepare -ServiceName $svcName -DeploymentName $svcName -CreateNewVirtualNetwork;
@@ -670,10 +670,12 @@ function Test-MigrationAbortAzureDeployment
670670

671671
# Test
672672
New-AzureService -ServiceName $svcName -Location $location;
673-
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
674-
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password "p@ssw0rd";
673+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername "pstestuser" -Password $PLACEHOLDER -WaitForBoot;
675674
Get-AzureVM -ServiceName $svcName -Name $vmName;
676675

676+
Move-AzureService -Validate -ServiceName $svcName -DeploymentName $svcName -CreateNewVirtualNetwork;
677+
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName;
678+
677679
Move-AzureService -Prepare -ServiceName $svcName -DeploymentName $svcName -CreateNewVirtualNetwork;
678680
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName;
679681
Assert-AreEqual "Prepared" $vm.VM.MigrationState;
@@ -733,15 +735,15 @@ function Test-MigrationAbortAzureVNet
733735
# Test
734736

735737
Set-AzureVNetConfig -ConfigurationPath $vnetConfigPath;
738+
Get-AzureVNetSite;
736739

740+
Move-AzureVirtualNetwork -Validate -VirtualNetworkName $vnetName;
737741
Get-AzureVNetSite;
738742

739743
Move-AzureVirtualNetwork -Prepare -VirtualNetworkName $vnetName;
740-
741744
Get-AzureVNetSite;
742745

743746
Move-AzureVirtualNetwork -Abort -VirtualNetworkName $vnetName;
744-
745747
Get-AzureVNetSite;
746748

747749
# Cleanup
@@ -755,17 +757,17 @@ Tests Move-AzureStorageAccount with Prepare and Commit
755757
function Test-MigrateAzureStorageAccount
756758
{
757759
# Setup
758-
$location = "Central US";
760+
$location = "Central US";
759761
$storageName = getAssetName;
760762
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;
761-
Get-AzureStorageAccount -StorageAccountName $storageName;
763+
Get-AzureStorageAccount -StorageAccountName $storageName;
762764

763765
# Test
764766
Move-AzureStorageAccount -Prepare -StorageAccountName $storageName;
765767
Get-AzureStorageAccount -StorageAccountName $storageName;
766768

767769
Move-AzureStorageAccount -Commit -StorageAccountName $storageName;
768-
Assert-ThrowsContains { Get-AzureStorageAccount -StorageAccountName $storageName; } "ResourceNotFound";
770+
Assert-ThrowsContains { Get-AzureStorageAccount -StorageAccountName $storageName; } "ResourceNotFound";
769771
}
770772

771773
<#
@@ -775,12 +777,15 @@ Tests Move-AzureStorageAccount with Prepare and Abort
775777
function Test-MigrationAbortAzureStorageAccount
776778
{
777779
# Setup
778-
$location = "Central US";
780+
$location = "Central US";
779781
$storageName = getAssetName;
780782
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;
781-
Get-AzureStorageAccount -StorageAccountName $storageName;
783+
Get-AzureStorageAccount -StorageAccountName $storageName;
782784

783785
# Test
786+
Move-AzureStorageAccount -Validate -StorageAccountName $storageName;
787+
Get-AzureStorageAccount -StorageAccountName $storageName;
788+
784789
Move-AzureStorageAccount -Prepare -StorageAccountName $storageName;
785790
Get-AzureStorageAccount -StorageAccountName $storageName;
786791

@@ -806,7 +811,7 @@ function Test-NewAzureVMWithBYOL
806811
$licenseType = "Windows_Server";
807812
$imgName = getAssetName;
808813
$userName = "User" + $svcName;
809-
$pass = "User@" + $svcName;
814+
$pass = $PLACEHOLDER;
810815

811816
$media1 = "http://mybyolosimagerdfe.blob.core.windows.net/myvhd/" + $svcName + "0.vhd";
812817
$media2 = "http://mybyolosimagerdfe.blob.core.windows.net/myvhd/" + $svcName + "1.vhd";
@@ -848,3 +853,42 @@ function Test-NewAzureVMWithBYOL
848853
# Cleanup
849854
Cleanup-CloudService $svcName
850855
}
856+
857+
# Test Redeploy VM
858+
function Run-RedeployVirtualMachineTest
859+
{
860+
# Setup
861+
$location = Get-DefaultLocation;
862+
$imgName = Get-DefaultImage $location;
863+
864+
$storageName = 'pstest' + (getAssetName);
865+
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;
866+
867+
# Associate the new storage account with the current subscription
868+
Set-CurrentStorageAccountName $storageName;
869+
870+
$vmName = "vm01";
871+
$svcName = 'pstest' + (Get-CloudServiceName);
872+
$userName = "pstestuser";
873+
$password = $PLACEHOLDER;
874+
875+
# Test
876+
New-AzureService -ServiceName $svcName -Location $location;
877+
878+
try
879+
{
880+
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername $userName -Password $password;
881+
# Get VM
882+
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName;
883+
884+
# Test Redeploy
885+
Restart-AzureVM -Redeploy -ServiceName $svcName -Name $vmName;
886+
887+
$vm = Get-AzureVM -ServiceName $svcName -Name $vmName;
888+
}
889+
finally
890+
{
891+
# Cleanup
892+
Cleanup-CloudService $svcName;
893+
}
894+
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,14 @@ public void TestNewAzureVMWithBYOL()
204204
{
205205
this.RunPowerShellTest("Test-NewAzureVMWithBYOL");
206206
}
207+
208+
[Fact]
209+
[Trait(Category.Service, Category.ServiceManagement)]
210+
[Trait(Category.AcceptanceType, Category.CheckIn)]
211+
[Trait(Category.AcceptanceType, Category.BVT)]
212+
public void RunRedeployVirtualMachineTest()
213+
{
214+
this.RunPowerShellTest("Run-RedeployVirtualMachineTest");
215+
}
207216
}
208217
}

0 commit comments

Comments
 (0)