Skip to content

Commit 01cd4e7

Browse files
authored
add resource group provisioniner and deprovisioner (#9798)
* add resource group provisioniner and deprovisioner * with tags * use condition for allocating resource group, configure storage to skip allocationg an RG, collapse KV configuration now that all can run in parallel * keep KV tests parallelized per-package * remove extra parens * correct template expression syntax * correct syntax for second conditional expression * set resource group allocation for live tests for services whose live test migration status is known * servicebus: eliminate old credentials * Event Hubs is using a static resource today * add identity configuration * always remove the resource group when it has been created successfully * remove AZURE_CLIENT_OID from service bus tests.yml
1 parent b946e74 commit 01cd4e7

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

eng/pipelines/templates/jobs/archetype-sdk-tests.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ parameters:
99
InjectedPackages: ''
1010
BuildDocs: true
1111
JobName: Test
12+
AllocateResourceGroup: 'true'
1213
Matrix:
1314
Linux_Python35:
1415
OSName: 'Linux'
@@ -47,6 +48,21 @@ jobs:
4748
vmImage: $(OSVmImage)
4849

4950
steps:
51+
- ${{ if eq(parameters['AllocateResourceGroup'], 'true') }}:
52+
- pwsh: |
53+
$BaseName = 't' + (New-Guid).ToString('n').Substring(0, 16)
54+
$RgName = "rg-${{ parameters.ServiceDirectory }}-$($BaseName)"
55+
$ResourceGroupExpiration = (Get-Date).ToUniversalTime().AddHours(24).ToString("o")
56+
Write-Host "Creating Resource Group: $($RgName)"
57+
Write-Host "##vso[task.setvariable variable=AZURE_RESOURCEGROUP_NAME]$RgName"
58+
59+
az login --service-principal -u $(provisioner-aad-id) -p $(provisioner-aad-secret) --tenant $(provisioner-aad-tenant)
60+
az account set --subscription $(provisioner-subscription)
61+
62+
az group create --location westus2 --name $RgName --tags DeleteAfter=$ResourceGroupExpiration BuildId='$(Build.BuildId)' BuildJob='$(Agent.JobName)' BuildNumber='$(Build.BuildNumber)' BuildReason='$(Build.Reason)'
63+
az group wait --created --resource-group $RgName
64+
displayName: Create resource group and environment variable for tests
65+
5066
- template: ../steps/build-test.yml
5167
parameters:
5268
BuildTargetingString: ${{ parameters.BuildTargetingString }}
@@ -63,4 +79,10 @@ jobs:
6379
TestMarkArgument: ${{ parameters.TestMarkArgument }}
6480
InjectedPackages: ${{ parameters.InjectedPackages }}
6581
BuildDocs: ${{parameters.BuildDocs}}
66-
82+
83+
- ${{ if eq(parameters['AllocateResourceGroup'], 'true') }}:
84+
- pwsh: |
85+
az group delete --resource-group $env:AZURE_RESOURCEGROUP_NAME -y --no-wait
86+
displayName: Delete resource group
87+
condition: ne(variables['AZURE_RESOURCEGROUP_NAME'], '')
88+

sdk/appconfiguration/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resources:
1010
jobs:
1111
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
1212
parameters:
13+
AllocateResourceGroup: 'false'
1314
BuildTargetingString: $(BuildTargetingString)
1415
ServiceDirectory: appconfiguration
1516
EnvVars:

sdk/cosmos/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resources:
1010
jobs:
1111
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
1212
parameters:
13+
AllocateResourceGroup: 'false'
1314
MaxParallel: 1
1415
ServiceDirectory: cosmos
1516
TestMarkArgument: not globaldb

sdk/eventhub/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resources:
1010
jobs:
1111
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
1212
parameters:
13+
AllocateResourceGroup: 'false'
1314
ServiceDirectory: eventhub
1415
Matrix:
1516
Linux_Python35:

sdk/identity/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ resources:
1010
jobs:
1111
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
1212
parameters:
13+
AllocateResourceGroup: 'false'
1314
ServiceDirectory: identity
1415
EnvVars:
1516
AZURE_CLIENT_ID: $(python-identity-client-id)

sdk/servicebus/tests.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ jobs:
1212
parameters:
1313
ServiceDirectory: servicebus
1414
EnvVars:
15-
SERVICE_BUS_HOSTNAME: $(python-sb-livetest-service-bus-hostname)
16-
SERVICE_BUS_SAS_POLICY: $(python-sb-livetest-service-sas-policy)
17-
SERVICE_BUS_SAS_KEY: $(python-sb-livetest-service-sas-key)
18-
SERVICE_BUS_CONNECTION_STR: $(python-sb-livetest-service-connection-str)
19-
SERVICE_BUS_CONNECTION_STR_RO: $(python-sb-livetest-service-connection-str-ro)
20-
SERVICE_BUS_CONNECTION_STR_WO: $(python-sb-livetest-service-connection-str-wo)
21-
SERVICE_BUS_CONNECTION_STR_ENTITY: $(python-sb-livetest-service-connection-entity)
15+
AZURE_SUBSCRIPTION_ID: $(azure-subscription-id)
16+
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
17+
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
18+
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
2219
AZURE_TEST_RUN_LIVE: 'true'
2320
Matrix:
2421
Linux_Python35:

sdk/storage/tests_invoke.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
jobs:
66
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
77
parameters:
8+
AllocateResourceGroup: 'false'
89
BuildTargetingString: azure-storage-blob
910
JobName: Test_Blob
1011
ServiceDirectory: storage
@@ -14,6 +15,7 @@ jobs:
1415

1516
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
1617
parameters:
18+
AllocateResourceGroup: 'false'
1719
BuildTargetingString: azure-storage-queue
1820
JobName: Test_Queue
1921
ServiceDirectory: storage
@@ -22,6 +24,7 @@ jobs:
2224

2325
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
2426
parameters:
27+
AllocateResourceGroup: 'false'
2528
MaxParallel: 1
2629
BuildTargetingString: azure-storage-file-datalake
2730
JobName: Test_Datalake
@@ -31,6 +34,7 @@ jobs:
3134

3235
- template: ../../eng/pipelines/templates/jobs/archetype-sdk-tests.yml
3336
parameters:
37+
AllocateResourceGroup: 'false'
3438
BuildTargetingString: azure-storage-file-share
3539
JobName: Test_FileShares
3640
ServiceDirectory: storage

0 commit comments

Comments
 (0)