diff --git a/src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 b/src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 new file mode 100644 index 000000000000..eaaf6bd6527c --- /dev/null +++ b/src/DesktopVirtualization/LiveTests/TestLiveScenarios.ps1 @@ -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 +} diff --git a/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 b/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 index 1f3d9b303a1a..bad46c146a2b 100644 --- a/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 +++ b/tools/TestFx/Live/DebugLocalLiveTestScenarios.ps1 @@ -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 diff --git a/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 b/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 index aa2dd0bbe4d9..b7b749e47eef 100644 --- a/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 +++ b/tools/TestFx/Live/InvokeLiveTestScenarios.ps1 @@ -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 diff --git a/tools/TestFx/Live/LiveTestUtility.psm1 b/tools/TestFx/Live/LiveTestUtility.psm1 index 9a56726678fc..779c77ce2935 100644 --- a/tools/TestFx/Live/LiveTestUtility.psm1 +++ b/tools/TestFx/Live/LiveTestUtility.psm1 @@ -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 {