Skip to content
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

Added live test for desktop virtualization #21074

Merged
merged 3 commits into from
Feb 28, 2023
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
75 changes: 75 additions & 0 deletions src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Invoke-LiveTestScenario -Name "Create a Windows virtual desktop" -Description "Test creating a Windows virtual desktop" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$location = "westus"
$poolName = New-LiveTestResourceName
$poolFriName = New-LiveTestRandomName -Option AllLetters
$groupName = New-LiveTestResourceName
$groupFriName = New-LiveTestRandomName -Option AllLetters
$appName = New-LiveTestResourceName
$appFriName = New-LiveTestRandomName -Option AllLetters

$pool = New-AzWvdHostPool -ResourceGroupName $rgName -Name $poolName -Location $location -FriendlyName $poolFriName -HostPoolType 'Pooled' -LoadBalancerType 'DepthFirst' -PreferredAppGroupType 'RailApplications' -ExpirationTime (Get-Date).ToUniversalTime().AddDays(1) -MaxSessionLimit 5
New-AzWvdApplicationGroup -ResourceGroupName $rgName -Name $groupName -Location $location -FriendlyName $groupFriName -HostPoolArmPath $pool.Id -ApplicationGroupType 'RemoteApp'
New-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName -FriendlyName $appFriName -FilePath "C:\Windows\System32\mspaint.exe" -IconIndex 0 -IconPath "C:\Windows\System32\mspaint.exe" -CommandLineSetting Allow -ShowInPortal:$true

$actual = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName
Assert-NotNull $actual
Assert-AreEqual "$groupName/$appName" $actual.Name
Assert-AreEqual $appFriName $actual.FriendlyName
Assert-True { $actual.FilePath -like "*mspaint*" }
}

Invoke-LiveTestScenario -Name "Update a Windows virtual desktop" -Description "Test updating an existing Windows virtual desktop" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$location = "westus"
$poolName = New-LiveTestResourceName
$poolFriName = New-LiveTestRandomName -Option AllLetters
$groupName = New-LiveTestResourceName
$groupFriName = New-LiveTestRandomName -Option AllLetters
$appName = New-LiveTestResourceName
$appFriName = New-LiveTestRandomName -Option AllLetters
$appFriNameNew = New-LiveTestRandomName -Option AllLetters -MaxLength 9

$pool = New-AzWvdHostPool -ResourceGroupName $rgName -Name $poolName -Location $location -FriendlyName $poolFriName -HostPoolType 'Pooled' -LoadBalancerType 'DepthFirst' -PreferredAppGroupType 'RailApplications' -ExpirationTime (Get-Date).ToUniversalTime().AddDays(1) -MaxSessionLimit 5
New-AzWvdApplicationGroup -ResourceGroupName $rgName -Name $groupName -Location $location -FriendlyName $groupFriName -HostPoolArmPath $pool.Id -ApplicationGroupType 'RemoteApp'
New-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName -FriendlyName $appFriName -FilePath "C:\Windows\System32\mspaint.exe" -IconIndex 0 -IconPath "C:\Windows\System32\mspaint.exe" -CommandLineSetting Allow -ShowInPortal:$true

$app = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName
$app | Update-AzWvdApplication -FilePath 'C:\Windows\System32\WindowsPowerShell\v1. 0\powershell.exe'

Update-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName -FriendlyName $appFriNameNew

$actual = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName
Assert-NotNull $actual
Assert-AreEqual "$groupName/$appName" $actual.Name
Assert-AreEqual $appFriNameNew $actual.FriendlyName
Assert-True { $actual.FilePath -like "*powershell*" }
}

Invoke-LiveTestScenario -Name "Delete a Windows virtual desktop" -Description "Test deleting a Windows virtual desktop" -ScenarioScript `
{
param ($rg)

$rgName = $rg.ResourceGroupName
$location = "westus"
$poolName = New-LiveTestResourceName
$poolFriName = New-LiveTestRandomName -Option AllLetters
$groupName = New-LiveTestResourceName
$groupFriName = New-LiveTestRandomName -Option AllLetters
$appName = New-LiveTestResourceName
$appFriName = New-LiveTestRandomName -Option AllLetters

$pool = New-AzWvdHostPool -ResourceGroupName $rgName -Name $poolName -Location $location -FriendlyName $poolFriName -HostPoolType 'Pooled' -LoadBalancerType 'DepthFirst' -PreferredAppGroupType 'RailApplications' -ExpirationTime (Get-Date).ToUniversalTime().AddDays(1) -MaxSessionLimit 5
New-AzWvdApplicationGroup -ResourceGroupName $rgName -Name $groupName -Location $location -FriendlyName $groupFriName -HostPoolArmPath $pool.Id -ApplicationGroupType 'RemoteApp'
New-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName -FriendlyName $appFriName -FilePath "C:\Windows\System32\mspaint.exe" -IconIndex 0 -IconPath "C:\Windows\System32\mspaint.exe" -CommandLineSetting Allow -ShowInPortal:$true
Remove-AzWvdApplication -ResourceGroupName $rgName -Name $appName -GroupName $groupName

$actual = Get-AzWvdApplication -Name $appName -ResourceGroupName $rgName -GroupName $groupName -ErrorAction SilentlyContinue
Assert-Null $actual
}
14 changes: 14 additions & 0 deletions tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ function InvokeLocalLiveTestScenarios {
. $_.FullName
}
}

Write-Host "##[section]Waiting for all cleanup jobs to be completed." -ForegroundColor Green
while (Get-Job -State Running) {
Write-Host "[section]Waiting for 10 seconds ..." -ForegroundColor Green
Start-Sleep -Seconds 10
}
Write-Host "##[section]All cleanup jobs are completed." -ForegroundColor Green

Write-Host "##[group]Cleanup jobs information." -ForegroundColor Green
$cleanupJobs = Get-Job
$cleanupJobs | Select-Object Name, Command, State, PSBeginTime, PSEndTime, Output
Write-Host "##[endgroup]"

$cleanupJobs | Remove-Job
}

ImportLocalAzModules
4 changes: 2 additions & 2 deletions tools/TestFx/Live/InvokeLiveTestScenarios.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ $liveScenarios | ForEach-Object {

Write-Host "##[section]Waiting for all cleanup jobs to be completed." -ForegroundColor Green
while (Get-Job -State Running) {
Write-Host "[section]Waiting for 10 seconds ..." -ForegroundColor Green
Start-Sleep -Seconds 10
Write-Host "[section]Waiting for 30 seconds ..." -ForegroundColor Green
Start-Sleep -Seconds 30
}
Write-Host "##[section]All cleanup jobs are completed." -ForegroundColor Green

Expand Down
2 changes: 1 addition & 1 deletion tools/TestFx/Live/LiveTestUtility.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function Clear-LiveTestResources {
[string] $Name
)

Invoke-LiveTestCommand -Command "Remove-AzResourceGroup -Name $Name -Force -AsJob"
Invoke-LiveTestCommand -Command "Remove-AzResourceGroup -Name $Name -Force -AsJob | Out-Null"
}

function ConvertToLiveTestJsonErrors {
Expand Down