Skip to content

Commit

Permalink
Merge pull request #710 from huangpf/dev
Browse files Browse the repository at this point in the history
AzureRT S52 PR #1
  • Loading branch information
stankovski committed Aug 11, 2015
2 parents 6b1a958 + 699553a commit c0400e5
Show file tree
Hide file tree
Showing 22 changed files with 122,482 additions and 714 deletions.
17 changes: 16 additions & 1 deletion src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@
<None Include="Resources\CredentialTests\Common.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\ServiceManagement\Files\OneWebOneWorker.cscfg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\ServiceManagement\Files\OneWebOneWorker.cspkg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.AutomationTests\TestAutomationConfigureRunbook.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand All @@ -220,6 +226,9 @@
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunAutoGeneratedHostedServiceCmdletTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunAutoGeneratedServiceExtensionCmdletTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunAutoGeneratedVirtualMachineCmdletTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand All @@ -232,6 +241,12 @@
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunNewAzureComputeParameterObjectTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceDeploymentExtensionCmdletTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceExtensionSetCmdletTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceManagementCloudExceptionTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -567,4 +582,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,35 @@ function Cleanup-Storage
}
}

<#
.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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
**********************************************************************************************
This file was generated by a tool from the project file: ServiceConfiguration.Cloud.cscfg
Changes to this file may cause incorrect behavior and will be lost if the file is regenerated.
**********************************************************************************************
-->
<ServiceConfiguration serviceName="OneWebOneWorker" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2012-10.1.8">
<Role name="WebRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
<Role name="WorkerRole1">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ function Run-NewAzureComputeParameterObjectTests
}
}

# Run Set-AzurePlatformVMImage Cmdlet Negative Tests
function Run-AzurePlatformVMImageNegativeTest
{
$location = Get-DefaultLocation;
Expand All @@ -363,4 +364,207 @@ function Run-AzurePlatformVMImageNegativeTest
{ Set-AzurePlatformVMImage -ImageName $imgName -Permission $mode } `
"ForbiddenError: This operation is not allowed for this subscription.";
}
}

# Run Auto-Generated Service Extension Cmdlet Tests
function Run-AutoGeneratedServiceExtensionCmdletTests
{
# Setup
$location = Get-DefaultLocation;

$storageName = 'pstest' + (getAssetName);
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;

# Associate the new storage account with the current subscription
Set-CurrentStorageAccountName $storageName;

$svcName = 'pstest' + (Get-CloudServiceName);

try
{
# Create Hosted Service Parameters
$svcCreateParams = New-AzureComputeParameterObject -FriendlyName 'HostedServiceCreateParameters';
$svcCreateParams.ServiceName = $svcName;
$svcCreateParams.Location = $location;
$svcCreateParams.Description = $svcName;
$svcCreateParams.Label = $svcName;

# Invoke Hosted Service Create
$st = Invoke-AzureComputeMethod -MethodName 'HostedServiceCreate' -ArgumentList $svcCreateParams;
Assert-AreEqual $st.StatusCode 'Created';
Assert-NotNull $st.RequestId;

# New-AzureDeployment (in Azure.psd1)
$testMode = Get-ComputeTestMode;
if ($testMode.ToLower() -ne 'playback')
{
$cspkg = '.\Resources\ServiceManagement\Files\OneWebOneWorker.cspkg';
}
else
{
$cspkg = "https://${storageName}.blob.azure.windows.net/blob/OneWebOneWorker.cspkg";
}
$cscfg = '.\Resources\ServiceManagement\Files\OneWebOneWorker.cscfg';

$st = New-AzureDeployment -ServiceName $svcName -Package $cspkg -Configuration $cscfg -Label $svcName -Slot Production;

$deployment = Get-AzureDeployment -ServiceName $svcName -Slot Production;
$config = $deployment.Configuration;

# Invoke Hosted Service Add Extension
$p1 = New-AzureComputeArgumentList -MethodName HostedServiceAddExtension;
$p1[0].Value = $svcName;
$p1[1].Value.Id = 'test';
$p1[1].Value.PublicConfiguration =
@"
<?xml version="1.0" encoding="UTF-8"?>
<PublicConfig>
<UserName>pstestuser</UserName>
<Expiration></Expiration>
</PublicConfig>
"@;
$p1[1].Value.PrivateConfiguration =
@"
<?xml version="1.0" encoding="UTF-8"?>
<PrivateConfig>
<Password>pstestuser</Password>
</PrivateConfig>
"@;
$p1[1].Value.ProviderNamespace = 'Microsoft.Windows.Azure.Extensions';
$p1[1].Value.Type = 'RDP';
$p1[1].Value.Version = '1.*';
$d1 = ($p1 | select -ExpandProperty Value);
$st = Invoke-AzureComputeMethod -MethodName HostedServiceAddExtension -ArgumentList $d1;

# Invoke Deployment Change Configuration
$p2 = New-AzureComputeArgumentList -MethodName DeploymentChangeConfigurationBySlot;
$p2[0].Value = $svcName;
$p2[1].Value = [Microsoft.WindowsAzure.Management.Compute.Models.DeploymentSlot]::Production;
$p2[2].Value = New-Object -TypeName Microsoft.WindowsAzure.Management.Compute.Models.DeploymentChangeConfigurationParameters;
$p2[2].Value.Configuration = $deployment.Configuration;
$p2[2].Value.ExtensionConfiguration = New-Object -TypeName Microsoft.WindowsAzure.Management.Compute.Models.ExtensionConfiguration;
$p2[2].Value.ExtensionConfiguration.AllRoles.Add('test');
$d2 = ($p2 | select -ExpandProperty Value);
$st = Invoke-AzureComputeMethod -MethodName DeploymentChangeConfigurationBySlot -ArgumentList $d2;

# Invoke Hosted Service Delete
$st = Invoke-AzureComputeMethod -MethodName 'HostedServiceDeleteAll' -ArgumentList $svcName;
Assert-AreEqual $st.StatusCode 'OK';
Assert-NotNull $st.RequestId;
}
finally
{
# Cleanup
Cleanup-CloudService $svcName;
}
}

# Run Service Extension Set Cmdlet Tests
function Run-ServiceExtensionSetCmdletTests
{
# Setup
$location = Get-DefaultLocation;
$imgName = Get-DefaultImage $location;

$storageName = 'pstest' + (getAssetName);
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;

# Associate the new storage account with the current subscription
Set-CurrentStorageAccountName $storageName;

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

# Test
New-AzureService -ServiceName $svcName -Location $location;

try
{
# New-AzureDeployment (in Azure.psd1)
$cspkg = '.\Resources\ServiceManagement\Files\OneWebOneWorker.cspkg';
$cscfg = '.\Resources\ServiceManagement\Files\OneWebOneWorker.cscfg';

# Staging 1st
$st = New-AzureDeployment -ServiceName $svcName -Package $cspkg -Configuration $cscfg -Label $svcName -Slot Staging;
$st = Set-AzureServiceRemoteDesktopExtension -ServiceName $svcName -Slot Staging -Credential $credential;
$ex = Get-AzureServiceExtension -ServiceName $svcName -Slot Staging;
$st = Move-AzureDeployment -ServiceName $svcName;
$ex = Get-AzureServiceExtension -ServiceName $svcName -Slot Production;

# Staging 2nd
$st = New-AzureDeployment -ServiceName $svcName -Package $cspkg -Configuration $cscfg -Label $svcName -Slot Staging;
$st = Set-AzureServiceRemoteDesktopExtension -ServiceName $svcName -Slot Staging -Credential $credential;
$ex = Get-AzureServiceExtension -ServiceName $svcName -Slot Staging;
$st = Move-AzureDeployment -ServiceName $svcName;
$ex = Get-AzureServiceExtension -ServiceName $svcName -Slot Production;

# Set Extensions
$st = Set-AzureServiceRemoteDesktopExtension -ServiceName $svcName -Slot Production -Credential $credential;
$st = Set-AzureServiceRemoteDesktopExtension -ServiceName $svcName -Slot Staging -Credential $credential;
}
finally
{
# Cleanup
Cleanup-CloudService $svcName;
}
}


# Run Service Deployment Extension Cmdlet Tests
function Run-ServiceDeploymentExtensionCmdletTests
{
# Setup
$location = Get-DefaultLocation;
$imgName = Get-DefaultImage $location;

$storageName = 'pstest' + (getAssetName);
New-AzureStorageAccount -StorageAccountName $storageName -Location $location;

# Associate the new storage account with the current subscription
Set-CurrentStorageAccountName $storageName;

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

# Test
New-AzureService -ServiceName $svcName -Location $location;

try
{
# New-AzureDeployment (in Azure.psd1)
$cspkg = '.\Resources\ServiceManagement\Files\OneWebOneWorker.cspkg';
$cscfg = '.\Resources\ServiceManagement\Files\OneWebOneWorker.cscfg';

$rdpCfg1 = New-AzureServiceRemoteDesktopExtensionConfig -Credential $credential -Role WebRole1
$rdpCfg2 = New-AzureServiceRemoteDesktopExtensionConfig -Credential $credential -Role WorkerRole1;
$adCfg1 = New-AzureServiceADDomainExtensionConfig -Role WebRole1 -WorkgroupName 'test1';
$adCfg2 = New-AzureServiceADDomainExtensionConfig -Role WorkerRole1 -WorkgroupName 'test2';

$st = New-AzureDeployment -ServiceName $svcName -Package $cspkg -Configuration $cscfg -Label $svcName -Slot Production -ExtensionConfiguration $rdpCfg1,$adCfg1;
$exts = Get-AzureServiceExtension -ServiceName $svcName -Slot Production;
Assert-True { $exts.Count -eq 2 };

$st = New-AzureDeployment -ServiceName $svcName -Package $cspkg -Configuration $cscfg -Label $svcName -Slot Staging -ExtensionConfiguration $rdpCfg2,$adCfg2;
$exts = Get-AzureServiceExtension -ServiceName $svcName -Slot Staging;
Assert-True { $exts.Count -eq 2 };

$st = Set-AzureDeployment -Config -ServiceName $svcName -Configuration $cscfg -Slot Production -ExtensionConfiguration $rdpCfg2;
$exts = Get-AzureServiceExtension -ServiceName $svcName -Slot Production;
Assert-True { $exts.Count -eq 1 };

$st = Set-AzureDeployment -Config -ServiceName $svcName -Configuration $cscfg -Slot Staging -ExtensionConfiguration $rdpCfg1,$adCfg1;
$exts = Get-AzureServiceExtension -ServiceName $svcName -Slot Staging;
Assert-True { $exts.Count -eq 2 };
}
finally
{
# Cleanup
Cleanup-CloudService $svcName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,32 @@ public void RunAzurePlatformVMImageNegativeTest()
{
this.RunPowerShellTest("Run-AzurePlatformVMImageNegativeTest");
}

[Fact]
[Trait(Category.Service, Category.ServiceManagement)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.AcceptanceType, Category.BVT)]
public void RunAutoGeneratedServiceExtensionCmdletTests()
{
this.RunPowerShellTest("Run-AutoGeneratedServiceExtensionCmdletTests");
}

[Fact]
[Trait(Category.Service, Category.ServiceManagement)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.AcceptanceType, Category.BVT)]
public void RunServiceExtensionSetCmdletTests()
{
this.RunPowerShellTest("Run-ServiceExtensionSetCmdletTests");
}

[Fact]
[Trait(Category.Service, Category.ServiceManagement)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.AcceptanceType, Category.BVT)]
public void RunServiceDeploymentExtensionCmdletTests()
{
this.RunPowerShellTest("Run-ServiceDeploymentExtensionCmdletTests");
}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.0.19.2-preview\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Compute, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.7.0.0-preview\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Compute, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.8.2.0\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -299,6 +299,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineCapture.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachineListWithPaging.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests\TestVirtualMachinePIRv2.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand All @@ -323,6 +326,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VMDynamicTests\RunVMDynamicTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Templates\azuredeploy.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
Expand Down
Loading

0 comments on commit c0400e5

Please sign in to comment.