diff --git a/eng/common/TestResources/New-TestResources.ps1 b/eng/common/TestResources/New-TestResources.ps1 index b7785df9ddf..da01e8375a2 100644 --- a/eng/common/TestResources/New-TestResources.ps1 +++ b/eng/common/TestResources/New-TestResources.ps1 @@ -63,6 +63,10 @@ param ( [ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud', 'Dogfood')] [string] $Environment = 'AzureCloud', + [Parameter()] + [ValidateSet('test', 'perf')] + [string] $ResourceType = 'test', + [Parameter()] [hashtable] $ArmTemplateParameters, @@ -223,7 +227,7 @@ function BuildBicepFile([System.IO.FileSystemInfo] $file) } $tmp = $env:TEMP ? $env:TEMP : [System.IO.Path]::GetTempPath() - $templateFilePath = Join-Path $tmp "test-resources.$(New-Guid).compiled.json" + $templateFilePath = Join-Path $tmp "$ResourceType-resources.$(New-Guid).compiled.json" # Az can deploy bicep files natively, but by compiling here it becomes easier to parse the # outputted json for mismatched parameter declarations. @@ -349,7 +353,7 @@ try { $root = [System.IO.Path]::Combine($repositoryRoot, "sdk", $ServiceDirectory) | Resolve-Path $templateFiles = @() - 'test-resources.json', 'test-resources.bicep' | ForEach-Object { + "$ResourceType-resources.json", "$ResourceType-resources.bicep" | ForEach-Object { Write-Verbose "Checking for '$_' files under '$root'" Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object { Write-Verbose "Found template '$($_.FullName)'" @@ -586,9 +590,9 @@ try { # Service principals in the Microsoft AAD tenant must end with an @microsoft.com domain; those in other tenants # are not permitted to do so. Format the non-MS name so there's an assocation with the Azure SDK. if ($TenantId -eq '72f988bf-86f1-41af-91ab-2d7cd011db47') { - $displayName = "test-resources-$($baseName)$suffix.microsoft.com" + $displayName = "$ResourceType-resources-$($baseName)$suffix.microsoft.com" } else { - $displayName = "$($baseName)$suffix.test-resources.azure.sdk" + $displayName = "$($baseName)$suffix.$ResourceType-resources.azure.sdk" } $servicePrincipalWrapper = NewServicePrincipalWrapper -subscription $SubscriptionId -resourceGroup $ResourceGroupName -displayName $DisplayName @@ -705,7 +709,7 @@ try { } } - $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-pre.ps1' + $preDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath "$ResourceType-resources-pre.ps1" if (Test-Path $preDeploymentScript) { Log "Invoking pre-deployment script '$preDeploymentScript'" &$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters @@ -745,7 +749,7 @@ try { $deploymentOutputs = SetDeploymentOutputs $serviceName $context $deployment $templateFile - $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1' + $postDeploymentScript = $templateFile.originalFilePath | Split-Path | Join-Path -ChildPath "$ResourceType-resources-post.ps1" if (Test-Path $postDeploymentScript) { Log "Invoking post-deployment script '$postDeploymentScript'" &$postDeploymentScript -ResourceGroupName $ResourceGroupName -DeploymentOutputs $deploymentOutputs @PSBoundParameters diff --git a/eng/common/TestResources/Remove-TestResources.ps1 b/eng/common/TestResources/Remove-TestResources.ps1 index 788dae63e6e..069f2bf8a63 100644 --- a/eng/common/TestResources/Remove-TestResources.ps1 +++ b/eng/common/TestResources/Remove-TestResources.ps1 @@ -52,6 +52,10 @@ param ( [Parameter(ParameterSetName = 'ResourceGroup+Provisioner')] [switch] $CI, + [Parameter()] + [ValidateSet('test', 'perf')] + [string] $ResourceType = 'test', + [Parameter()] [switch] $Force, @@ -198,7 +202,7 @@ Log "Selected subscription '$subscriptionName'" if ($ServiceDirectory) { $root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path - $preRemovalScript = Join-Path -Path $root -ChildPath 'remove-test-resources-pre.ps1' + $preRemovalScript = Join-Path -Path $root -ChildPath "remove-$ResourceType-resources-pre.ps1" if (Test-Path $preRemovalScript) { Log "Invoking pre resource removal script '$preRemovalScript'" @@ -210,7 +214,7 @@ if ($ServiceDirectory) { } # Make sure environment files from New-TestResources -OutFile are removed. - Get-ChildItem -Path $root -Filter test-resources.json.env -Recurse | Remove-Item -Force:$Force + Get-ChildItem -Path $root -Filter "$ResourceType-resources.json.env" -Recurse | Remove-Item -Force:$Force } $verifyDeleteScript = { diff --git a/eng/common/TestResources/deploy-test-resources.yml b/eng/common/TestResources/deploy-test-resources.yml index 25c0823ac55..a0c68f33a3c 100644 --- a/eng/common/TestResources/deploy-test-resources.yml +++ b/eng/common/TestResources/deploy-test-resources.yml @@ -4,6 +4,7 @@ parameters: DeleteAfterHours: 8 Location: '' SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) + ResourceType: test # SubscriptionConfiguration will be splatted into the parameters of the test # resources script. It should be JSON in the form: @@ -48,6 +49,7 @@ steps: # pass those in via the ArmTemplateParameters flag, and handle any # additional parameters from the pipelines via AdditionalParameters eng/common/TestResources/New-TestResources.ps1 ` + -ResourceType '${{ parameters.ResourceType }}' ` -ServiceDirectory '${{ parameters.ServiceDirectory }}' ` -Location '${{ parameters.Location }}' ` -DeleteAfterHours '${{ parameters.DeleteAfterHours }}' ` diff --git a/eng/common/TestResources/remove-test-resources.yml b/eng/common/TestResources/remove-test-resources.yml index cf5c0c5ac45..9675f58e06e 100644 --- a/eng/common/TestResources/remove-test-resources.yml +++ b/eng/common/TestResources/remove-test-resources.yml @@ -4,6 +4,7 @@ parameters: ServiceDirectory: '' SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) + ResourceType: test # SubscriptionConfiguration will be splat into the parameters of the test # resources script. It should be JSON in the form: @@ -29,6 +30,7 @@ steps: eng/common/TestResources/Remove-TestResources.ps1 ` @subscriptionConfiguration ` + -ResourceType '${{ parameters.ResourceType }}' ` -ServiceDirectory "${{ parameters.ServiceDirectory }}" ` -CI ` -Force `