Skip to content

Commit 25d8194

Browse files
committed
Fixed VM and VMSS Tests, Added SessionRecords, and updated VMSS Update Logic/Strategy Pass Ins
1 parent a2d6b22 commit 25d8194

File tree

10 files changed

+6348
-1454
lines changed

10 files changed

+6348
-1454
lines changed

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,5 +479,12 @@ public void TestProxyAgentSetting()
479479
{
480480
TestRunner.RunTestScript("Test-ProxyAgentSetting");
481481
}
482+
483+
[Fact]
484+
[Trait(Category.AcceptanceType, Category.CheckIn)]
485+
public void TestVMSSAddProxyAgentExtension()
486+
{
487+
TestRunner.RunTestScript("Test-VMSSAddProxyAgentExtension");
488+
}
482489
}
483490
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5965,4 +5965,54 @@ function Test-ProxyAgentSetting
59655965
# Cleanup
59665966
Clean-ResourceGroup $rgname;
59675967
}
5968+
}
5969+
5970+
<#
5971+
.SYNOPSIS
5972+
Test-VMSSAddProxyAgentExtension creates a VMSS with Enabled ProxyAgent and added ProxyAgentExtension
5973+
#>
5974+
function Test-VMSSAddProxyAgentExtension
5975+
{
5976+
# Setup
5977+
$rgname = Get-ComputeTestResourceName;
5978+
$loc = "eastus2";
5979+
5980+
5981+
try
5982+
{
5983+
# Common
5984+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
5985+
5986+
$vmssName = 'vmss' + $rgname;
5987+
$domainNameLabel1 = "d1" + $rgname;
5988+
5989+
$adminUsername = Get-ComputeTestResourceName;
5990+
$password = Get-PasswordForVM;
5991+
$adminPassword = $password | ConvertTo-SecureString -AsPlainText -Force;
5992+
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword);
5993+
$linuxImage = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest"
5994+
5995+
# Case 1: Create using simple parameter set
5996+
$vmss = New-AzVmss -ResourceGroupName $rgname -Location $loc -Credential $cred -VMScaleSetName $vmssName -DomainNameLabel $domainNameLabel1 -Image $linuxImage -EnableProxyAgent -AddProxyAgentExtension
5997+
5998+
# verify
5999+
Assert-AreEqual $vmss.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.Enabled $true
6000+
6001+
6002+
# Update vmss to add proxy agent extension
6003+
$VMSS = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName
6004+
$VMSS = Set-AzVmssProxyAgentSetting -VirtualMachineScaleSet $VMSS -EnableProxyAgent $true -AddProxyAgentExtension $true
6005+
$vmssUpdated = Update-AzVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $VMSS
6006+
6007+
6008+
6009+
# Validate
6010+
Assert-AreEqual $vmssUpdated.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.Enabled $true
6011+
Assert-AreEqual $vmssUpdated.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension $true
6012+
}
6013+
finally
6014+
{
6015+
# Cleanup
6016+
Clean-ResourceGroup $rgname;
6017+
}
59686018
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -696,12 +696,5 @@ public void TestVMAddProxyAgentExtension()
696696
{
697697
TestRunner.RunTestScript("Test-VMAddProxyAgentExtension");
698698
}
699-
700-
[Fact]
701-
[Trait(Category.AcceptanceType, Category.CheckIn)]
702-
public void TestVMSSAddProxyAgentExtension()
703-
{
704-
TestRunner.RunTestScript("Test-VMSSAddProxyAgentExtension");
705-
}
706699
}
707700
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7974,38 +7974,3 @@ function Test-VMAddProxyAgentExtension
79747974
Clean-ResourceGroup $resourceGroupName;
79757975
}
79767976
}
7977-
7978-
<#
7979-
.SYNOPSIS
7980-
Test-VMSSAddProxyAgentExtension creates a VMSS with Enabled ProxyAgent and added ProxyAgentExtension
7981-
#>
7982-
function Test-VMSSAddProxyAgentExtension
7983-
{
7984-
# Setup
7985-
$resourceGroupName = Get-ComputeTestResourceName;
7986-
$adminUsername = Get-ComputeTestResourceName;
7987-
$adminPassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
7988-
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $adminPassword);
7989-
$vmssName = 'VMSS1';
7990-
$imageName = "Canonical:0001-com-ubuntu-server-jammy:22_04-lts:latest";
7991-
7992-
7993-
try
7994-
{
7995-
New-AzVmss -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssName -Credential $cred -image $imageName -Location 'eastus2' -EnableProxyAgent -AddProxyAgentExtension
7996-
7997-
# Update vmss to add proxy agent extension
7998-
$VMSS = Get-AzVmss -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssName
7999-
$VMSS = Set-AzVmssProxyAgentSetting -VirtualMachineScaleSet $VMSS -EnableProxyAgent $true -AddProxyAgentExtension $true
8000-
Update-AzVmss -ResourceGroupName $resourceGroupName -Name $vmssName -VirtualMachineScaleSet $VMSS
8001-
8002-
# Validate
8003-
Assert-AreEqual $VMSS.SecurityProfile.ProxyAgentSettings.Enabled $true
8004-
Assert-AreEqual $VMSS.SecurityProfile.ProxyAgentSettings.AddProxyAgentExtension $true
8005-
}
8006-
finally
8007-
{
8008-
# Cleanup
8009-
Clean-ResourceGroup $resourceGroupName;
8010-
}
8011-
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests/TestVMSSAddProxyAgentExtension.json

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

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests/TestVirtualMachineScaleSetAddProxyAgentExtension.json

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

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVMAddProxyAgentExtension.json

Lines changed: 423 additions & 1137 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)