Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ public void TestVirtualMachineScaleSetNewEncryptionAtHost()
TestRunner.RunTestScript("Test-VirtualMachineScaleSetEncryptionAtHost");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineScaleSetOrchestrationVM()
{
TestRunner.RunTestScript("Test-VirtualMachineScaleSetOrchestrationVM");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineScaleSetOrchestrationModeFaultDomain()
{
TestRunner.RunTestScript("Test-VirtualMachineScaleSetOrchestrationModeFaultDomain");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineScaleSetAssignedHost()
Expand Down
168 changes: 164 additions & 4 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2537,17 +2537,177 @@ function Test-VirtualMachineScaleSetEncryptionAtHost
}
}

<#
.SYNOPSIS
create a VMSS in orchestration mode then add a vm to it
#>
function Test-VirtualMachineScaleSetOrchestrationVM
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = "eastus"
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# New VMSS Parameters
$vmssName = 'vmssOrchestrationMode' + $rgname;
$vmName = 'vm' + $rgname;
$domainName = 'domain' + $rgname;
$adminUsername = 'Foo12';
$adminPassword = $PLACEHOLDER;

$securePassword = ConvertTo-SecureString $adminPassword -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $securePassword);



$VmssConfigWithoutVmProfile = new-azvmssconfig -location $loc -platformfaultdomain 1
$VmssWithoutVmProfile = new-azvmss -resourcegroupname $rgname -vmscalesetname $vmssName -virtualmachinescaleset $VmssConfigWithoutVmProfile

$vm = new-azvm -resourcegroupname $rgname -location $loc -name $vmname -credential $cred -domainnamelabel $domainName -vmssid $VmssWithoutVmProfile.id


Assert-AreEqual $VmssWithoutVmProfile.id $vm.virtualmachinescaleset.id

}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Testing the new OrchestrationMode and PlatformFaultDomainCount parameters when creating VMSS objects.
OrchestrationMode has several requirements
-PlatformFaultDomainCount is passed in.
-The VMSS VMProfile is not passed in.
-The Zone has only 1 zone.
-The SinglePlacementGroup parameter is false
#>
function Test-VirtualMachineScaleSetOrchestrationModeFaultDomain
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = Get-Location "Microsoft.Compute" "virtualMachines";
$loc = $loc.Replace(' ', '');
New-AzResourceGroup -Name $rgname -Location $loc -Force;

$orchestrationMode = "VM";
$licenseType = "Windows_Server";
$platformFaultDomainCount = 5;
$platformFaultDomainCountConfig = 3;
$zone = "2";
$zones = @("2", "3");
$domainNameLabel = $rgname + "domain";
$VmSku = "Standard_D2s_v3";
$vmssname = "MyVmss";
$username = "admin01";
$password = "ComepresaP13123fdsa" | ConvertTo-SecureString -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

### PlatformFaultDomainCount tests
$vmss = New-AzVmss -Name $vmssname -ResourceGroup $rgname -Credential $cred -Zone $zone -VmSize $VmSku -DomainNameLabel $domainNameLabel -PlatformFaultDomainCount $platformFaultDomainCount;

Assert-NotNull $vmss;
Assert-AreEqual $vmss.PlatformFaultDomainCount $platformFaultDomainCount;


$vmssConfigFaultDomain = New-AzVmssConfig -Location $loc -OrchestrationMode $orchestrationMode -PlatformFaultDomainCount $platformFaultDomainCountConfig;
Assert-NotNull $vmssConfigFaultDomain;
Assert-AreEqual $vmssConfigFaultDomain.PlatformFaultDomainCount $platformFaultDomainCountConfig;

#If a VMProfile exists in the config exists, the cmdlet fails.
Assert-ThrowsContains { New-AzVmssConfig -Location $loc -OrchestrationMode $orchestrationMode -PlatformFaultDomainCount $platformFaultDomainCountConfig -LicenseType $licenseType -SkuCapacity 2 -SkuName 'Standard_E4-2ds_v4'; } "The selected orchestration mode is in preview, and does not support the specified VMSS configuration. The configuration caused the 'VirtualMachineScaleSetVMProfile' to be created, which is not allowed with the orchestration mode.";

#If OrchestrationMode is given without PlatformFaultDomainCount, the cmdlet fails.
Assert-ThrowsContains { New-AzVmssConfig -Location $loc -OrchestrationMode $orchestrationMode; } "The selected orchestration mode is in preview, and does not support the specified VMSS configuration. The parameter 'PlatformFaultDomainCount' is required with an orchestration mode.";

#If SinglePlacementGroup is passed as 'true' with OrchestrationMode, the cmdlet fails.
Assert-ThrowsContains { New-AzVmssConfig -Location $loc -OrchestrationMode $orchestrationMode -PlatformFaultDomainCount $platformFaultDomainCountConfig -SinglePlacementGroup $true; } "The selected orchestration mode is in preview, and does not support the specified VMSS configuration. The parameter 'SinglePlacementGroup' is not allowed with an orchestration mode.";

#If multiple zones are passed in with OrchestrationMode, the cmdlet fails.
Assert-ThrowsContains { New-AzVmssConfig -Location $loc -OrchestrationMode $orchestrationMode -PlatformFaultDomainCount $platformFaultDomainCountConfig -Zone $zones; } "The selected orchestration mode is in preview, and does not support the specified VMSS configuration. The parameter 'Zone' cannot have more than one zone with an orchestration mode.";


### New-AzVmss OrchestrationMode tests
$vmssnameOMode = $vmssname + "OMode";

$vmssConfigOMode = New-AzVmssConfig -Location $loc -platformfaultdomain 1 -OrchestrationMode $orchestrationMode;
Assert-AreEqual $orchestrationMode $vmssConfigOMode.OrchestrationMode;

# Test if the OrchestrationMode requirements are met in Default Parameter Set.
$vmssDefaultParamSet = New-AzVmss -Name $vmssnameOMode -ResourceGroup $rgname -VirtualMachineScaleSet $vmssConfigOMode;
Assert-AreEqual $null $vmssDefaultParamSet.VirtualMachineProfile;#Comment for Review: I'm pretty sure this assumption is correct.

# Test if the OrchestrationMode requirements are met in Simple Parameter Set.
$vmssSimpleParamSet = New-AzVmss -Name $vmssnameOMode -ResourceGroup $rgname -Credential $cred -Zone $zone -DomainNameLabel $domainNameLabel -PlatformFaultDomainCount 1 -OrchestrationMode $orchestrationMode;
Assert-AreEqual $null $vmssSimpleParamSet.VirtualMachineProfile; #I am sure this assumption is correct.
#Comment for Review:
#currently an error stating 'Parameter sku is not allowed' with the new VMSSStrategy method if I include those params in the Strategy method.
#I think the sku cannot be passed in (on a CRP level) wihtout some of the other stuff.
#TODO: Had to remove SKu and UpgradePolicy from the VMSSStrategy method. Worth including my own error? Include those in the OrchestrationMode requirements?

# Test the OrchestrationMode requirements are enforced when parameters used to create the VMProfile values were set by piped in cmdlets.

# SRP
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;

# NRP
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;

# New VMSS Parameters
$vmssNamePipeParameters = 'vmssWithPipedParams';
$adminUsername = 'Foo12';
$adminPassword = $PLACEHOLDER;

$securePassword = ConvertTo-SecureString $adminPassword -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($adminUsername, $securePassword);

$imgRef = Get-DefaultCRPImage -loc $loc;
$ipCfg = New-AzVmssIPConfig -Name 'test' -SubnetId $subnetId;

$vmss = New-AzVmssConfig -Location $loc -SkuCapacity 2 -SkuName 'Standard_E4-2ds_v4' -UpgradePolicyMode 'Manual' -OrchestrationMode $orchestrationMode -PlatformFaultDomainCount $platformFaultDomainCountConfig `
| Add-AzVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg `
| Set-AzVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
| Set-AzVmssStorageProfile -OsDiskCreateOption 'FromImage' -OsDiskCaching 'None' `
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion 'latest' `
-ImageReferencePublisher $imgRef.PublisherName ;

Assert-ThrowsContains { $vmssResult1 = New-AzVmss -ResourceGroupName $rgname -Name $vmssNamePipeParameters -VirtualMachineScaleSet $vmss; } "The selected orchestration mode is in preview, and does not support the specified VMSS configuration. The 'VirtualMachineScaleSetVMProfile' is not null.";
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
testing encryptionAtHost cmdlet for
new-azvmss - create vmss using simple parameter set and hostencryption tag.
update-azvmss test boolean parameter
new-azvmssconfig
#>
function Test-VirtualMachineScaleSetAssignedHost
function Test-VirtualMachineScaleSetAssignedHost
{
# Setup
$rgname = Get-ComputeTestResourceName
# Setup
$rgname = Get-ComputeTestResourceName

try
{
Expand Down Expand Up @@ -2582,4 +2742,4 @@ function Test-VirtualMachineScaleSetAssignedHost
# Cleanup
Clean-ResourceGroup $rgname
}
}
}

Large diffs are not rendered by default.

Loading