Skip to content

AzureRT PR S51 - Update Base Class & Fix Test Running Time Issue #561

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 9 commits into from
Jul 7, 2015
Merged
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
7 changes: 7 additions & 0 deletions src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
<Reference Include="Microsoft.WindowsAzure.Management.Compute">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Compute.12.2.0-preview\lib\net40\Microsoft.WindowsAzure.Management.Compute.dll</HintPath>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Network, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Network.7.0.0\lib\net40\Microsoft.WindowsAzure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Management.Storage">
<HintPath>..\..\packages\Microsoft.WindowsAzure.Management.Storage.5.1.1\lib\net40\Microsoft.WindowsAzure.Management.Storage.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -205,6 +209,9 @@
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunServiceManagementCloudExceptionTests.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\RunStartAndStopMultipleVirtualMachinesTest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.WindowsAzure.Commands.ScenarioTest.ServiceManagementTests\TestGetAzureLocation.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,68 @@ function Run-ServiceManagementCloudExceptionTests
Assert-ThrowsLike { $st = Get-AzureService -ServiceName '*' } $compare;
Assert-ThrowsLike { $st = Get-AzureVM -ServiceName '*' } $compare;
Assert-ThrowsLike { $st = Get-AzureAffinityGroup -Name '*' } $compare;
}

# Test Start/Stop-AzureVM for Multiple VMs
function Run-StartAndStopMultipleVirtualMachinesTest
{
# 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;

$vmNameList = @("vm01", "vm02", "test04");
$svcName = 'pstest' + (Get-CloudServiceName);
$userName = "pstestuser";
$password = "p@ssw0rd";

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

try
{
foreach ($vmName in $vmNameList)
{
New-AzureQuickVM -Windows -ImageName $imgName -Name $vmName -ServiceName $svcName -AdminUsername $userName -Password $password;
}

# Get VM List
$vmList = Get-AzureVM -ServiceName $svcName;

# Test Stop
Stop-AzureVM -Force -ServiceName $svcName -Name $vmNameList[0];
Stop-AzureVM -Force -ServiceName $svcName -Name $vmNameList[0],$vmNameList[1];
Stop-AzureVM -Force -ServiceName $svcName -Name $vmNameList;
Stop-AzureVM -Force -ServiceName $svcName -Name '*';
Stop-AzureVM -Force -ServiceName $svcName -Name 'vm*';
Stop-AzureVM -Force -ServiceName $svcName -Name 'vm*','test*';
Stop-AzureVM -Force -ServiceName $svcName -VM $vmList[0];
Stop-AzureVM -Force -ServiceName $svcName -VM $vmList[0],$vmList[1];
Stop-AzureVM -Force -ServiceName $svcName -VM $vmList;

# Test Start
Start-AzureVM -ServiceName $svcName -Name $vmNameList[0];
Start-AzureVM -ServiceName $svcName -Name $vmNameList[0],$vmNameList[1];
Start-AzureVM -ServiceName $svcName -Name $vmNameList;
Start-AzureVM -ServiceName $svcName -Name '*';
Start-AzureVM -ServiceName $svcName -Name 'vm*';
Start-AzureVM -ServiceName $svcName -Name 'vm*','test*';
Start-AzureVM -ServiceName $svcName -VM $vmList[0];
Start-AzureVM -ServiceName $svcName -VM $vmList[0],$vmList[1];
Start-AzureVM -ServiceName $svcName -VM $vmList;
}
catch
{

}
finally
{
# Cleanup
Cleanup-CloudService $svcName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Test;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;

namespace Microsoft.WindowsAzure.Commands.ScenarioTest
{
public partial class ServiceManagementTests
{
[Fact]
[Trait(Category.Service, Category.ServiceManagement)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.AcceptanceType, Category.BVT)]
public void TestGetAzureVM()
{
this.RunPowerShellTest("Test-GetAzureVM");
}

[Fact]
[Trait(Category.Service, Category.ServiceManagement)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
Expand All @@ -40,5 +44,14 @@ public void RunServiceManagementCloudExceptionTests()
{
this.RunPowerShellTest("Run-ServiceManagementCloudExceptionTests");
}

[Fact]
[Trait(Category.Service, Category.ServiceManagement)]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.AcceptanceType, Category.BVT)]
public void RunStartAndStopMultipleVirtualMachinesTest()
{
this.RunPowerShellTest("Run-StartAndStopMultipleVirtualMachinesTest");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,33 @@

using Microsoft.Azure.Common.Authentication;
using Microsoft.Azure.Test;
using Microsoft.WindowsAzure.Management;
using Microsoft.WindowsAzure.Management.Compute;
using Microsoft.WindowsAzure.Management.Network;
using Microsoft.WindowsAzure.Management.Storage;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Xunit;

namespace Microsoft.WindowsAzure.Commands.ScenarioTest
{
public partial class ServiceManagementTests
{
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper();

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetAzureVM()
{
this.RunPowerShellTest("Test-GetAzureVM");
}

protected void SetupManagementClients()
{
helper.SetupSomeOfManagementClients();
var rdfeTestFactory = new RDFETestEnvironmentFactory();
var managementClient = TestBase.GetServiceClient<ManagementClient>(rdfeTestFactory);
var computeClient = TestBase.GetServiceClient<ComputeManagementClient>(rdfeTestFactory);
var networkClient = TestBase.GetServiceClient<NetworkManagementClient>(rdfeTestFactory);
var storageClient = TestBase.GetServiceClient<StorageManagementClient>(rdfeTestFactory);

helper.SetupSomeOfManagementClients(
managementClient,
computeClient,
networkClient,
storageClient);
}

protected void RunPowerShellTest(params string[] scripts)
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Common/Commands.ScenarioTest/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Compute" version="12.2.0-preview" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Network" version="7.0.0" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
<package id="Microsoft.WindowsAzure.Management.WebSites" version="4.4.2-prerelease" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

namespace Microsoft.Azure.Commands.Compute
{
public partial class ComputeClient
public class ComputeClient
{
public IComputeManagementClient ComputeManagementClient { get; set; }
public IComputeManagementClient ComputeManagementClient { get; private set; }

public Action<string> VerboseLogger { get; set; }

public Action<string> ErrorLogger { get; set; }
Expand All @@ -32,9 +32,9 @@ public ComputeClient(AzureContext context)
{
}

public ComputeClient(IComputeManagementClient resourceManagementClient)
public ComputeClient(IComputeManagementClient computeManagementClient)
{
ComputeManagementClient = resourceManagementClient;
ComputeManagementClient = computeManagementClient;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
<Compile Include="IaaS\Network\RemoveAzurePublicIP.cs" />
<Compile Include="IaaS\Network\GetAzurePublicIP.cs" />
<Compile Include="IaaS\Network\RemoveAzureReservedIPAssociation.cs" />
<Compile Include="IaaS\Network\RemoveAzureVirtualIP.cs" />
<Compile Include="IaaS\Network\SetAzureDns.cs" />
<Compile Include="IaaS\Network\SetAzureInternalLoadBalancer.cs" />
<Compile Include="IaaS\Network\SetAzureNetworkSecurityGroupConfig.cs" />
Expand Down Expand Up @@ -309,7 +310,6 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="RemoveAzureVirtualIP.cs" />
<Compile Include="RoleSizes\GetAzureRoleSize.cs" />
<Compile Include="ServiceManagementProfile.cs" />
<Compile Include="AffinityGroups\SetAzureAffinityGroup.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ protected DeploymentGetResponse GetDeployment(string slot)
{
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private DeploymentGetResponse GetCurrentDeployment(out OperationStatusResponse o

DeploymentGetResponse deploymentGetResponse = null;
InvokeInOperationContext(() => deploymentGetResponse = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slot));
operation = GetOperationNewSM(deploymentGetResponse.RequestId);
operation = GetOperation(deploymentGetResponse.RequestId);

WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public virtual void NewPaaSDeploymentProcess()
{
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
}

Expand Down Expand Up @@ -225,7 +225,7 @@ public virtual void NewPaaSDeploymentProcess()
}
catch (CloudException ex)
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
});
}
Expand All @@ -249,7 +249,7 @@ private void AssertNoPersistenVmRoleExistsInDeployment(string slot)
{
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void ExecuteCommand()
{
if (ex.Response.StatusCode != HttpStatusCode.NotFound && IsVerbose() == false)
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
}

Expand Down Expand Up @@ -263,7 +263,7 @@ public void ExecuteCommand()
}
catch (CloudException ex)
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private DeploymentGetResponse GetCurrentDeployment(out OperationStatusResponse o

WriteVerboseWithTimestamp(Resources.GetDeploymentBeginOperation);
DeploymentGetResponse deploymentGetResponse = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, slot);
operation = GetOperationNewSM(deploymentGetResponse.RequestId);
operation = GetOperation(deploymentGetResponse.RequestId);
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);

return deploymentGetResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ internal void GetCurrentDeployment()
return;

CurrentDeploymentNewSM = ComputeClient.Deployments.GetBySlot(Service, NSM.DeploymentSlot.Production);
GetDeploymentOperationNewSM = GetOperationNewSM(CurrentDeploymentNewSM.RequestId);
GetDeploymentOperationNewSM = GetOperation(CurrentDeploymentNewSM.RequestId);
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
}
catch (CloudException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected virtual void ExecuteCommand()
try
{
CurrentDeploymentNewSM = this.ComputeClient.Deployments.GetBySlot(this.ServiceName, DeploymentSlot.Production);
GetDeploymentOperationNewSM = GetOperationNewSM(CurrentDeploymentNewSM.RequestId);
GetDeploymentOperationNewSM = GetOperation(CurrentDeploymentNewSM.RequestId);
WriteVerboseWithTimestamp(Resources.GetDeploymentCompletedOperation);
}
catch (CloudException ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public VirtualNetworkConfigContext GetVirtualNetworkConfigProcess()
WriteVerboseWithTimestamp(string.Format(Resources.AzureVNetConfigBeginOperation, CommandRuntime.ToString()));

var netcfg = this.NetworkClient.Networks.GetConfiguration();
var operation = GetOperationNewSM(netcfg.RequestId);
var operation = GetOperation(netcfg.RequestId);

WriteVerboseWithTimestamp(string.Format(Resources.AzureVNetConfigCompletedOperation, CommandRuntime.ToString()));

Expand Down Expand Up @@ -81,7 +81,7 @@ public VirtualNetworkConfigContext GetVirtualNetworkConfigProcess()
}
else
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IEnumerable<VirtualNetworkSiteContext> GetVirtualNetworkSiteProcess()
}
}

var operation = GetOperationNewSM(response.RequestId);
var operation = GetOperation(response.RequestId);
WriteVerboseWithTimestamp(string.Format(Resources.AzureVNetSiteCompletedOperation, CommandRuntime.ToString()));
result = sites.Select(site => ContextFactory<NetworkListResponse.VirtualNetworkSite, VirtualNetworkSiteContext>(site, operation));
}
Expand All @@ -72,7 +72,7 @@ public IEnumerable<VirtualNetworkSiteContext> GetVirtualNetworkSiteProcess()
}
else
{
this.WriteExceptionDetails(ex);
WriteExceptionError(ex);
}
}
});
Expand Down
Loading