Skip to content

Commit dcad930

Browse files
authored
Merge pull request #5484 from markcowl/fixcap
Availability Set Name and Progress fix
2 parents b248bd3 + 8ee856f commit dcad930

File tree

5 files changed

+3331
-5
lines changed

5 files changed

+3331
-5
lines changed

src/Common/Commands.Common/AzureLongRunningJob.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ protected AzureLongRunningJob(string command, string name) : base(command, name)
8080
/// <typeparam name="T">The type of the cmdlet being executed</typeparam>
8181
public class AzureLongRunningJob<T> : AzureLongRunningJob, ICommandRuntime where T : AzurePSCmdlet
8282
{
83+
const int MaxRecords = 1000;
8384
string _status = "Running";
8485
T _cmdlet;
8586
ICommandRuntime _runtime;
@@ -671,7 +672,7 @@ public bool TransactionAvailable()
671672
public void WriteCommandDetail(string text)
672673
{
673674
ThrowIfJobFailedOrCancelled();
674-
if (Verbose.IsOpen)
675+
if (Verbose.IsOpen && Verbose.Count < MaxRecords)
675676
{
676677
Verbose.Add(new VerboseRecord(text));
677678
}
@@ -684,7 +685,7 @@ public void WriteCommandDetail(string text)
684685
public void WriteDebug(string text)
685686
{
686687
ThrowIfJobFailedOrCancelled();
687-
if (Debug.IsOpen)
688+
if (Debug.IsOpen && Debug.Count < MaxRecords)
688689
{
689690
Debug.Add(new DebugRecord(text));
690691
}
@@ -745,7 +746,7 @@ public void WriteObject(object sendToPipeline, bool enumerateCollection)
745746
public void WriteProgress(ProgressRecord progressRecord)
746747
{
747748
ThrowIfJobFailedOrCancelled();
748-
if (Progress.IsOpen)
749+
if (Progress.IsOpen && Progress.Count < MaxRecords)
749750
{
750751
Progress.Add(progressRecord);
751752
}
@@ -769,7 +770,7 @@ public void WriteProgress(long sourceId, ProgressRecord progressRecord)
769770
public void WriteVerbose(string text)
770771
{
771772
ThrowIfJobFailedOrCancelled();
772-
if (Verbose.IsOpen)
773+
if (Verbose.IsOpen && Verbose.Count < MaxRecords)
773774
{
774775
Verbose.Add(new VerboseRecord(text));
775776
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,12 @@ public void TestSimpleNewVm()
3131
{
3232
ComputeTestController.NewInstance.RunPsTest("Test-SimpleNewVm");
3333
}
34+
35+
[Fact]
36+
[Trait(Category.AcceptanceType, Category.CheckIn)]
37+
public void TestSimpleNewVmWithAvailabilitySet2()
38+
{
39+
ComputeTestController.NewInstance.RunPsTest("Test-SimpleNewVmWithAvailabilitySet2");
40+
}
3441
}
3542
}

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,53 @@ function Test-SimpleNewVm
3939
Clean-ResourceGroup $vmname
4040
}
4141
}
42+
43+
44+
<#
45+
.SYNOPSIS
46+
Test Simple Paremeter Set for New Vm
47+
#>
48+
function Test-SimpleNewVmWithAvailabilitySet2
49+
{
50+
# Setup
51+
$rgname = Get-ResourceName
52+
53+
try
54+
{
55+
$username = "admin01"
56+
$password = "werWER345#%^" | ConvertTo-SecureString -AsPlainText -Force
57+
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
58+
[string]$vmname = "myVM"
59+
[string]$asname = "myAvailabilitySet"
60+
61+
# Common
62+
$r = New-AzureRmResourceGroup -Name $rgname -Location "eastus"
63+
$a = New-AzureRmAvailabilitySet `
64+
-ResourceGroupName $rgname `
65+
-Name $asname `
66+
-Location "eastus" `
67+
-Sku "Aligned" `
68+
-PlatformUpdateDomainCount 2 `
69+
-PlatformFaultDomainCount 2
70+
71+
$x = New-AzureRmVM `
72+
-ResourceGroupName $rgname `
73+
-Name $vmname `
74+
-Credential $cred `
75+
-VirtualNetworkName "myVnet" `
76+
-SubnetName "mySubnet" `
77+
-OpenPorts 80,3389 `
78+
-PublicIpAddressName "myPublicIpAddress" `
79+
-SecurityGroupName "myNetworkSecurityGroup" `
80+
-AvailabilitySetName $asname `
81+
-DomainNameLabel "myvm-ad9300"
82+
83+
Assert-AreEqual $vmname $x.Name;
84+
Assert-AreEqual $a.Id $x.AvailabilitySetReference.Id
85+
}
86+
finally
87+
{
88+
# Cleanup
89+
Clean-ResourceGroup $rgname
90+
}
91+
}

0 commit comments

Comments
 (0)