mirror of
https://github.com/microsoft/mcp.git
synced 2026-11-04 12:01:31 +00:00
Live to recorded tests virtual desktop (#1361)
* Fix resource deployment script * Add test-resources-post.ps1 * Migrate VirtualDesktop LiveTests to Recorded Tests * Format C# code
This commit is contained in:
1 parent
ee9174d199
commit
c8e7e258ef
6 files changed
+119
-51
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Azure.Mcp.Core.Areas.Server.Commands.Discovery;
|
||||
|
||||
+13
-2
@@ -4,12 +4,23 @@
|
||||
using System.Text.Json;
|
||||
using Azure.Mcp.Tests;
|
||||
using Azure.Mcp.Tests.Client;
|
||||
using Azure.Mcp.Tests.Client.Helpers;
|
||||
using Azure.Mcp.Tests.Generated.Models;
|
||||
using Xunit;
|
||||
|
||||
namespace Azure.Mcp.Tools.VirtualDesktop.LiveTests;
|
||||
|
||||
public class VirtualDesktopCommandTests(ITestOutputHelper output) : CommandTestsBase(output)
|
||||
public class VirtualDesktopCommandTests(ITestOutputHelper output, TestProxyFixture fixture) : RecordedCommandTestsBase(output, fixture)
|
||||
{
|
||||
public override List<BodyRegexSanitizer> BodyRegexSanitizers => new()
|
||||
{
|
||||
new BodyRegexSanitizer(new BodyRegexSanitizerBody()
|
||||
{
|
||||
Regex = "\"displayName\"\\s*:\\s*\"[^\"]+\"",
|
||||
Value = "\"displayName\": \"Sanitized\""
|
||||
})
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public async Task Should_ListHostpools_WithSubscriptionId()
|
||||
{
|
||||
@@ -146,7 +157,7 @@ public class VirtualDesktopCommandTests(ITestOutputHelper output) : CommandTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Test is failed due to missing resource.Perhaps this should be removed")]
|
||||
public async Task Should_ListHostpools_WithNonExistentResourceGroup()
|
||||
{
|
||||
// Test with a non-existent resource group name
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"AssetsRepo": "Azure/azure-sdk-assets",
|
||||
"AssetsRepoPrefixPath": "",
|
||||
"TagPrefix": "Azure.Mcp.Tools.VirtualDesktop.LiveTests",
|
||||
"Tag": "Azure.Mcp.Tools.VirtualDesktop.LiveTests_e351ac41b0"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
param(
|
||||
[string] $TenantId,
|
||||
[string] $TestApplicationId,
|
||||
[string] $ResourceGroupName,
|
||||
[string] $BaseName,
|
||||
[hashtable] $DeploymentOutputs
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
. "$PSScriptRoot/../../../eng/common/scripts/common.ps1"
|
||||
. "$PSScriptRoot/../../../eng/scripts/helpers/TestResourcesHelpers.ps1"
|
||||
|
||||
$testSettings = New-TestSettings @PSBoundParameters -OutputPath $PSScriptRoot
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
@description('The location where resources will be deployed')
|
||||
param location string = resourceGroup().location
|
||||
|
||||
@description('The base name for resource naming')
|
||||
param baseName string = resourceGroup().name
|
||||
|
||||
@description('The tenant ID to which the application and resources belong.')
|
||||
param tenantId string = '72f988bf-86f1-41af-91ab-2d7cd011db47'
|
||||
|
||||
@description('The client OID to grant access to test resources.')
|
||||
param testApplicationOid string
|
||||
|
||||
// Host Pool for Azure Virtual Desktop
|
||||
resource hostPool 'Microsoft.DesktopVirtualization/hostPools@2023-09-05' = {
|
||||
name: 'hp-${baseName}'
|
||||
location: location
|
||||
properties: {
|
||||
hostPoolType: 'Pooled'
|
||||
loadBalancerType: 'BreadthFirst'
|
||||
maxSessionLimit: 5
|
||||
preferredAppGroupType: 'Desktop'
|
||||
startVMOnConnect: false
|
||||
validationEnvironment: false
|
||||
}
|
||||
}
|
||||
|
||||
// Application Group for the Host Pool
|
||||
resource appGroup 'Microsoft.DesktopVirtualization/applicationGroups@2023-09-05' = {
|
||||
name: 'ag-${baseName}'
|
||||
location: location
|
||||
properties: {
|
||||
applicationGroupType: 'Desktop'
|
||||
hostPoolArmPath: hostPool.id
|
||||
}
|
||||
}
|
||||
|
||||
// Workspace to contain the Application Group
|
||||
resource workspace 'Microsoft.DesktopVirtualization/workspaces@2023-09-05' = {
|
||||
name: 'ws-${baseName}'
|
||||
location: location
|
||||
properties: {
|
||||
applicationGroupReferences: [
|
||||
appGroup.id
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Reference to Desktop Virtualization User role definition
|
||||
resource desktopVirtualizationUserRole 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
|
||||
scope: subscription()
|
||||
name: '1d18fff3-a72a-46b5-b4a9-0b38a3cd7e63' // Desktop Virtualization User
|
||||
}
|
||||
|
||||
// Desktop Virtualization User role assignment for the test application
|
||||
resource desktopUserRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
|
||||
name: guid(desktopVirtualizationUserRole.id, testApplicationOid, resourceGroup().id)
|
||||
properties: {
|
||||
principalId: testApplicationOid
|
||||
roleDefinitionId: desktopVirtualizationUserRole.id
|
||||
}
|
||||
}
|
||||
|
||||
// Reference to Reader role definition
|
||||
resource readerRoleDefinition 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
|
||||
scope: subscription()
|
||||
name: 'acdd72a7-3385-48ef-bd42-f606fba81ae7' // Reader
|
||||
}
|
||||
|
||||
// Reader role assignment on the resource group
|
||||
resource readerRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
|
||||
name: guid(readerRoleDefinition.id, testApplicationOid, resourceGroup().id)
|
||||
properties: {
|
||||
principalId: testApplicationOid
|
||||
roleDefinitionId: readerRoleDefinition.id
|
||||
}
|
||||
}
|
||||
|
||||
// Output the created resources for testing
|
||||
output hostPoolName string = hostPool.name
|
||||
output hostPoolId string = hostPool.id
|
||||
output applicationGroupName string = appGroup.name
|
||||
output workspaceName string = workspace.name
|
||||
@@ -1,49 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
@description('The location where resources will be deployed')
|
||||
param location string = resourceGroup().location
|
||||
|
||||
@description('The base name for resource naming')
|
||||
param baseName string = resourceGroup().name
|
||||
|
||||
// Host Pool for Azure Virtual Desktop
|
||||
resource hostPool 'Microsoft.DesktopVirtualization/hostPools@2023-09-05' = {
|
||||
name: 'hp-${baseName}'
|
||||
location: location
|
||||
properties: {
|
||||
hostPoolType: 'Pooled'
|
||||
loadBalancerType: 'BreadthFirst'
|
||||
maxSessionLimit: 5
|
||||
preferredAppGroupType: 'Desktop'
|
||||
startVMOnConnect: false
|
||||
validationEnvironment: false
|
||||
}
|
||||
}
|
||||
|
||||
// Application Group for the Host Pool
|
||||
resource appGroup 'Microsoft.DesktopVirtualization/applicationGroups@2023-09-05' = {
|
||||
name: 'ag-${baseName}'
|
||||
location: location
|
||||
properties: {
|
||||
applicationGroupType: 'Desktop'
|
||||
hostPoolArmPath: hostPool.id
|
||||
}
|
||||
}
|
||||
|
||||
// Workspace to contain the Application Group
|
||||
resource workspace 'Microsoft.DesktopVirtualization/workspaces@2023-09-05' = {
|
||||
name: 'ws-${baseName}'
|
||||
location: location
|
||||
properties: {
|
||||
applicationGroupReferences: [
|
||||
appGroup.id
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// Output the created resources for testing
|
||||
output hostPoolName string = hostPool.name
|
||||
output hostPoolId string = hostPool.id
|
||||
output applicationGroupName string = appGroup.name
|
||||
output workspaceName string = workspace.name
|
||||
Reference in new issue
Block a user