Skip to content

Commit b7857d3

Browse files
authored
[Canary] MTU packets transfer+register specific RPs (#310)
* MTU packets transfer+register specific RPs * Add a timeout for subscription deletion check
1 parent 349d21f commit b7857d3

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

CanaryValidator/Canary.Tests.ps1

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ param (
104104
[parameter(HelpMessage="List of usecases to be excluded from execution")]
105105
[Parameter(ParameterSetName="default", Mandatory=$false)]
106106
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
107-
[string[]]$ExclusionList = ("GetAzureStackInfraRoleInstance"),
107+
[string[]]$ExclusionList = ("GetAzureStackInfraRoleInstance", "DeleteSubscriptionResourceGroup"),
108108
[parameter(HelpMessage="Lists the available usecases in Canary")]
109109
[Parameter(ParameterSetName="listavl", Mandatory=$true)]
110110
[ValidateNotNullOrEmpty()]
@@ -567,7 +567,7 @@ while ($runCount -le $NumberOfIterations)
567567

568568
Invoke-Usecase -Name 'RegisterResourceProviders' -Description "Register resource providers" -UsecaseBlock `
569569
{
570-
Get-AzureRmResourceProvider -ListAvailable | Register-AzureRmResourceProvider -Force
570+
("Microsoft.Storage", "Microsoft.Compute", "Microsoft.Network", "Microsoft.KeyVault") | ForEach-Object {Get-AzureRmResourceProvider -ProviderNamespace $_} | Register-AzureRmResourceProvider -Force
571571
$sleepTime = 0
572572
while($true)
573573
{
@@ -803,7 +803,7 @@ while ($runCount -le $NumberOfIterations)
803803
Invoke-Usecase -Name 'RetrieveResourceDeploymentTimes' -Description "Retrieves the resources deployment times from the ARM template deployment" -UsecaseBlock `
804804
{
805805
$templateDeploymentName = "CanaryVMDeployment"
806-
(Get-AzureRmResourceGroupDeploymentOperation -Deploymentname $templateDeploymentName -ResourceGroupName $CanaryVMRG).Properties | Select-Object ProvisioningOperation,@{Name="ResourceType";Expression={$_.TargetResource.ResourceType}},@{Name="ResourceName";Expression={$_.TargetResource.ResourceName}},Duration,ProvisioningState,StatusCode | Format-Table -AutoSize
806+
(Get-AzureRmResourceGroupDeploymentOperation -Deploymentname $templateDeploymentName -ResourceGroupName $CanaryVMRG).Properties | Select-Object @{Name="ResourceName";Expression={$_.TargetResource.ResourceName}},Duration,ProvisioningState,@{Name="ResourceType";Expression={$_.TargetResource.ResourceType}},ProvisioningOperation,StatusCode | Format-Table -AutoSize
807807
}
808808

809809
$canaryWindowsVMList = @()
@@ -892,6 +892,41 @@ while ($runCount -le $NumberOfIterations)
892892
}
893893
}
894894

895+
Invoke-Usecase -Name 'TransmitMTUSizedPacketsBetweenTenantVMs' -Description "Check if the tenant VMs can transmit MTU sized packets between themselves" -UsecaseBlock `
896+
{
897+
$vmUser = ".\$VMAdminUserName"
898+
$vmCreds = New-Object System.Management.Automation.PSCredential $vmUser, (ConvertTo-SecureString $VMAdminUserPass -AsPlainText -Force)
899+
if (($pubVMObject = Get-AzureRmVM -ResourceGroupName $CanaryVMRG -Name $publicVMName -ErrorAction Stop) -and ($pvtVMObject = Get-AzureRmVM -ResourceGroupName $CanaryVMRG -Name $privateVMName -ErrorAction Stop))
900+
{
901+
Set-item wsman:\localhost\Client\TrustedHosts -Value $publicVMIP -Force -Confirm:$false
902+
$sw = [system.diagnostics.stopwatch]::startNew()
903+
while (-not($publicVMSession = New-PSSession -ComputerName $publicVMIP -Credential $vmCreds -ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000) -and (-not($publicVMSession))){$sw.Stop(); throw [System.Exception]"Unable to establish a remote session to the tenant VM using public IP: $publicVMIP"}; Start-Sleep -Seconds 15}
904+
if ($publicVMSession)
905+
{
906+
$remoteExecError = $null
907+
Invoke-Command -Session $publicVMSession -Script{param ($privateIP) Set-item wsman:\localhost\Client\TrustedHosts -Value $privateIP -Force -Confirm:$false} -ArgumentList $privateVMIP | Out-Null
908+
Invoke-Command -Session $publicVMSession -Script{Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False} | Out-Null
909+
$publicVMHost = Invoke-Command -Session $publicVMSession -Script{(Get-ItemProperty "HKLM:\Software\Microsoft\Virtual Machine\Guest\Parameters" ).PhysicalHostName}
910+
$privateVMHost = Invoke-Command -Session $publicVMSession -Script{param ($privateIP, $vmCreds) $sw = [system.diagnostics.stopwatch]::startNew(); while (-not($privateSess = New-PSSession -ComputerName $privateIP -Credential $vmCreds -ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000) -and (-not($privateSess))){$sw.Stop(); throw [System.Exception]"Unable to establish a remote session to the tenant VM using private IP: $privateIP"}; Start-Sleep -Seconds 15}; Invoke-Command -Session $privateSess -Script{Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False | Out-Null; (Get-ItemProperty "HKLM:\Software\Microsoft\Virtual Machine\Guest\Parameters" ).PhysicalHostName} } -ArgumentList $privateVMIP, $vmCreds -ErrorVariable remoteExecError 2>$null
911+
Invoke-Command -Session $publicVMSession -Script{param ($privateIP, $vmCreds) $sw = [system.diagnostics.stopwatch]::startNew(); while (-not($privateSess = New-PSSession -ComputerName $privateIP -Credential $vmCreds -ErrorAction SilentlyContinue)){if (($sw.ElapsedMilliseconds -gt 240000) -and (-not($privateSess))){$sw.Stop(); throw [System.Exception]"Unable to establish a remote session to the tenant VM using private IP: $privateIP"}; Start-Sleep -Seconds 15}; Invoke-Command -Session $privateSess -Script{Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False | Out-Null} } -ArgumentList $privateVMIP, $vmCreds -ErrorVariable remoteExecError 2>$null
912+
$privateVMResponseFromRemoteSession = Invoke-Command -Session $publicVMSession -Script{param($targetIP) $targetName = $targetIP; $pingOptions = New-Object Net.NetworkInformation.PingOptions(64, $true); [int]$PingDataSize = 1472; [int]$TimeoutMilliseconds = 1000; $pingData = New-Object byte[]($PingDataSize); $ping = New-Object Net.NetworkInformation.Ping; $task = $ping.SendPingAsync($targetName, $TimeoutMilliseconds, $pingData, $pingOptions); [Threading.Tasks.Task]::WaitAll($task); if ($task.Result.Status -ne "Success") {throw "Ping request returned error $($task.Result.Status)"} else {return "Success"} } -ArgumentList $privateVMIP -ErrorVariable remoteExecError 2>$null
913+
$publicVMSession | Remove-PSSession -Confirm:$false
914+
if ($remoteExecError)
915+
{
916+
throw [System.Exception]"$remoteExecError"
917+
}
918+
if ($privateVMResponseFromRemoteSession)
919+
{
920+
"MTU sized packet transfer between tenant VM1 on host $publicVMHost and tenant VM2 on host $privateVMHost succeeded"
921+
}
922+
else
923+
{
924+
throw [System.Exception]"Failed to transmit MTU sized packets between the tenant VMs"
925+
}
926+
}
927+
}
928+
}
929+
895930
Invoke-Usecase -Name 'AddDatadiskToVMWithPrivateIP' -Description "Add a data disk from utilities resource group to the VM with private IP" -UsecaseBlock `
896931
{
897932
Invoke-Usecase -Name 'StopDeallocateVMWithPrivateIPBeforeAddingDatadisk' -Description "Stop/Deallocate the VM with private IP before adding the data disk" -UsecaseBlock `
@@ -1109,6 +1144,13 @@ while ($runCount -le $NumberOfIterations)
11091144
{
11101145
Remove-AzureRmTenantSubscription -TargetSubscriptionId $subs.SubscriptionId -ErrorAction Stop
11111146
}
1147+
$sw = [system.diagnostics.stopwatch]::startNew()
1148+
while ((Get-AzureRmTenantSubscription -ErrorAction Stop | Where-Object DisplayName -eq $tenantSubscriptionName) -or (Get-AzureRmTenantSubscription -ErrorAction Stop | Where-Object DisplayName -eq $canaryDefaultTenantSubscription))
1149+
{
1150+
if ($sw.Elapsed.Seconds -gt 600) {break}
1151+
Start-Sleep -Seconds 30
1152+
}
1153+
$sw.Stop()
11121154
}
11131155

11141156
Invoke-Usecase -Name 'LoginToAzureStackEnvAsSvcAdminForCleanup' -Description "Login to $SvcAdminEnvironmentName as service administrator to remove the subscription resource group" -UsecaseBlock `

0 commit comments

Comments
 (0)