Skip to content

Commit 2a6aa5b

Browse files
danieljurekroot
authored and
root
committed
Smoke Tests: enable using other clouds (#10200)
* fix async tests and install async requirements * fix Identity for KV to support AZURE_AUTHORITY_HOST with a hostname (requires hostname without protocol wrapping) * add AZURE_AUTHORITY_HOST to tests.yml (this one uses a python-specific value because python uses just the host and doesn't use the URL like other languages) * update naming for authority host variable * add ability to use gov cloud * public -> gov for gov cloud instances, tweaks to async event hubs
1 parent 3159871 commit 2a6aa5b

9 files changed

+80
-24
lines changed

common/smoketest/event_hubs_async.py

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ async def send_and_receive_events(self, partition_id):
5454
# on_event will close the consumer_client which resumes execution
5555
on_event=self.on_event,
5656
on_error=self.on_error,
57-
timeout=RECEIVE_TIMEOUT,
5857
starting_position=STARTING_POSITION
5958
)
6059

common/smoketest/key_vault_certificates.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self):
1414
# * AZURE_CLIENT_ID
1515
# * AZURE_CLIENT_SECRET
1616
# * AZURE_TENANT_ID
17-
credential = DefaultAzureCredential()
17+
authority_host = os.environ.get('AZURE_AUTHORITY_HOST') or KnownAuthorities.AZURE_PUBLIC_CLOUD
18+
credential = DefaultAzureCredential(authority=authority_host)
1819
self.certificate_client = CertificateClient(
1920
vault_url=os.environ["AZURE_PROJECT_URL"], credential=credential
2021
)

common/smoketest/key_vault_certificates_async.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self):
1414
# * AZURE_CLIENT_ID
1515
# * AZURE_CLIENT_SECRET
1616
# * AZURE_TENANT_ID
17-
credential = DefaultAzureCredential()
17+
authority_host = os.environ.get('AZURE_AUTHORITY_HOST') or KnownAuthorities.AZURE_PUBLIC_CLOUD
18+
credential = DefaultAzureCredential(authority=authority_host)
1819
self.certificate_client = CertificateClient(
1920
vault_url=os.environ["AZURE_PROJECT_URL"], credential=credential
2021
)

common/smoketest/key_vault_keys.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self):
1414
# * AZURE_CLIENT_ID
1515
# * AZURE_CLIENT_SECRET
1616
# * AZURE_TENANT_ID
17-
credential = DefaultAzureCredential()
17+
authority_host = os.environ.get('AZURE_AUTHORITY_HOST') or KnownAuthorities.AZURE_PUBLIC_CLOUD
18+
credential = DefaultAzureCredential(authority=authority_host)
1819
self.key_client = KeyClient(
1920
vault_url=os.environ["AZURE_PROJECT_URL"], credential=credential
2021
)

common/smoketest/key_vault_keys_async.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self):
1414
# * AZURE_CLIENT_ID
1515
# * AZURE_CLIENT_SECRET
1616
# * AZURE_TENANT_ID
17-
credential = DefaultAzureCredential()
17+
authority_host = os.environ.get('AZURE_AUTHORITY_HOST') or KnownAuthorities.AZURE_PUBLIC_CLOUD
18+
credential = DefaultAzureCredential(authority=authority_host)
1819
self.key_client = KeyClient(
1920
vault_url=os.environ["AZURE_PROJECT_URL"], credential=credential
2021
)

common/smoketest/key_vault_secrets.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self):
1414
# * AZURE_CLIENT_ID
1515
# * AZURE_CLIENT_SECRET
1616
# * AZURE_TENANT_ID
17-
credential = DefaultAzureCredential()
17+
authority_host = os.environ.get('AZURE_AUTHORITY_HOST') or KnownAuthorities.AZURE_PUBLIC_CLOUD
18+
credential = DefaultAzureCredential(authority=authority_host)
1819
self.secret_client = SecretClient(
1920
vault_url=os.environ["AZURE_PROJECT_URL"], credential=credential
2021
)

common/smoketest/key_vault_secrets_async.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def __init__(self):
1414
# * AZURE_CLIENT_ID
1515
# * AZURE_CLIENT_SECRET
1616
# * AZURE_TENANT_ID
17-
credential = DefaultAzureCredential()
17+
authority_host = os.environ.get('AZURE_AUTHORITY_HOST') or KnownAuthorities.AZURE_PUBLIC_CLOUD
18+
credential = DefaultAzureCredential(authority=authority_host)
1819
self.secret_client = SecretClient(
1920
vault_url=os.environ["AZURE_PROJECT_URL"], credential=credential
2021
)

common/smoketest/smoke_test_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from storage_blob_async import StorageBlobAsync
1111

1212

13-
def execute_async_smoke_tests:
13+
def execute_async_smoke_tests():
1414
print("")
1515
print("==========================================")
1616
print(" AZURE TRACK 2 SDKs SMOKE TEST ASYNC")

eng/pipelines/smoke-test.yml

+67-16
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,43 @@ jobs:
55
- job:
66
strategy:
77
matrix:
8-
Python_27_Linux:
8+
Python_27_Linux (Public):
99
PythonVersion: '2.7'
1010
InstallAsyncRequirements: false
1111
OSVmImage: ubuntu-18.04
12-
Python_37_Linux:
12+
CloudType: public
13+
Python_37_Linux (Public):
1314
PythonVersion: '3.7'
1415
OSVmImage: ubuntu-18.04
15-
Python_38_Linux:
16+
CloudType: public
17+
Python_38_Linux (Public):
1618
PythonVersion: '3.8'
1719
OSVmImage: ubuntu-18.04
18-
Python_37_Windows:
20+
CloudType: public
21+
Python_37_Windows (Public):
1922
PythonVersion: '3.7'
2023
OSVmImage: windows-2019
21-
Python_38_Windows:
24+
CloudType: public
25+
Python_38_Windows (Public):
2226
PythonVersion: '3.8'
2327
OSVmImage: windows-2019
24-
Python_37_Mac:
28+
CloudType: public
29+
Python_37_Mac (Public):
2530
PythonVersion: '3.7'
2631
OSVmImage: macOS-10.15
27-
Python_38_Mac:
32+
CloudType: public
33+
Python_38_Mac (Public):
2834
PythonVersion: '3.8'
2935
OSVmImage: macOS-10.15
36+
CloudType: public
37+
Python_38_Linux (Gov):
38+
PythonVersion: '3.8'
39+
OSVmImage: ubuntu-18.04
40+
CloudType: gov
41+
Python_37_Windows (Gov):
42+
PythonVersion: '3.7'
43+
OSVmImage: windows-2019
44+
CloudType: gov
3045

3146
pool:
3247
vmImage: $(OSVmImage)
@@ -46,17 +61,53 @@ jobs:
4661
- script: pip install -r ./common/smoketest/requirements.txt
4762
displayName: "Install requirements.txt"
4863

64+
- script: pip install -r ./common/smoketest/requirements_async.txt
65+
displayName: "Install requirements_async.txt"
66+
condition: and(succeeded(), eq(variables['InstallAsyncRequirements'], 'true'))
67+
4968
- script: python ./eng/tox/install_dev_build_dependency.py -r ./common/smoketest/requirements.txt
5069
displayName: "Install dev dependencies from feed"
5170

71+
# Set secret environment variables for different clouds
72+
- pwsh: |
73+
$variables = @{
74+
AZURE_CLIENT_ID='$(aad-azure-sdk-test-client-id)'
75+
AZURE_CLIENT_SECRET='$(aad-azure-sdk-test-client-secret)'
76+
AZURE_TENANT_ID='$(aad-azure-sdk-test-tenant-id)'
77+
AZURE_AUTHORITY_HOST='$(aad-azure-sdk-test-authority-host)'
78+
AZURE_PROJECT_URL='$(smoke-tests-key-vault-project-url)'
79+
EVENT_HUBS_CONNECTION_STRING='$(smoke-tests-event-hubs-connection-string)'
80+
COSMOS_ENDPOINT='$(smoke-tests-cosmos-endpoint)'
81+
COSMOS_KEY='$(smoke-tests-cosmos-key)'
82+
STORAGE_CONNECTION_STRING='$(smoke-tests-storage-connection-string)'
83+
};
84+
foreach ($key in $variables.Keys) {
85+
Write-Host "Setting variable '$key'"
86+
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($variables[$key])"
87+
Write-Host "##vso[task.setvariable variable=$key;]$($variables[$key])"
88+
}
89+
displayName: Set secrets for public cloud
90+
condition: and(succeeded(), eq(variables['CloudType'], 'public'))
91+
92+
- pwsh: |
93+
$variables = @{
94+
AZURE_CLIENT_ID='$(aad-azure-sdk-test-client-id-gov)'
95+
AZURE_CLIENT_SECRET='$(aad-azure-sdk-test-client-secret-gov)'
96+
AZURE_TENANT_ID='$(aad-azure-sdk-test-tenant-id-gov)'
97+
AZURE_AUTHORITY_HOST='$(aad-azure-sdk-test-authority-host-gov)'
98+
AZURE_PROJECT_URL='$(smoke-tests-key-vault-project-url-gov)'
99+
EVENT_HUBS_CONNECTION_STRING='$(smoke-tests-event-hubs-connection-string-gov)'
100+
COSMOS_ENDPOINT='$(smoke-tests-cosmos-endpoint-gov)'
101+
COSMOS_KEY='$(smoke-tests-cosmos-key-gov)'
102+
STORAGE_CONNECTION_STRING='$(smoke-tests-storage-connection-string-gov)'
103+
};
104+
foreach ($key in $variables.Keys) {
105+
Write-Host "Setting variable '$key'"
106+
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($variables[$key])"
107+
Write-Host "##vso[task.setvariable variable=$key;]$($variables[$key])"
108+
}
109+
displayName: Set secrets for public cloud
110+
condition: and(succeeded(), eq(variables['CloudType'], 'gov'))
111+
52112
- script: python ./common/smoketest/program.py
53113
displayName: "Run Smoke Test"
54-
env:
55-
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
56-
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
57-
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
58-
AZURE_PROJECT_URL: $(smoke-tests-key-vault-project-url)
59-
EVENT_HUBS_CONNECTION_STRING: $(smoke-tests-event-hubs-connection-string)
60-
COSMOS_ENDPOINT: $(smoke-tests-cosmos-endpoint)
61-
COSMOS_KEY: $(smoke-tests-cosmos-key)
62-
STORAGE_CONNECTION_STRING: $(smoke-tests-storage-connection-string)

0 commit comments

Comments
 (0)