Skip to content

Commit 1db222e

Browse files
halliprheaths
andauthored
Add live tests template (Azure#2330)
* add live tests template * add automatic System.Debug->RUST_LOG=debug * use correct credential for live, recorded tests * exclude release stage from all refs/pull branch runs * subscribe to traces for live tests Co-authored-by: Heath Stewart <[email protected]>
1 parent 84a91d5 commit 1db222e

File tree

11 files changed

+341
-123
lines changed

11 files changed

+341
-123
lines changed

eng/pipelines/pullrequest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ extends:
1212
template: /eng/pipelines/templates/stages/archetype-sdk-client.yml
1313
parameters:
1414
ServiceDirectory: auto
15+
IncludeRelease: false
16+
RunLiveTests: false

eng/pipelines/templates/jobs/ci.tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
parameters:
2+
# required matrix parameters
23
- name: UsePlatformContainer
34
type: boolean
45
- name: OSName
@@ -9,13 +10,15 @@ parameters:
910
type: string
1011
- name: CloudConfig
1112
type: object
13+
# custom parameters
1214
- name: ServiceDirectory
1315
type: string
1416
- name: TimeoutInMinutes
1517
type: number
1618
- name: TestProxy
1719
type: boolean
1820

21+
1922
jobs:
2023
- job:
2124
displayName: "Test"
@@ -68,3 +71,10 @@ jobs:
6871
arguments: >
6972
-PackageInfoDirectory '$(Build.ArtifactStagingDirectory)/PackageInfo'
7073
-Toolchain '$(Toolchain)'
74+
75+
- ${{ if eq(parameters.TestProxy, true) }}:
76+
- pwsh: |
77+
# $(Build.SourcesDirectory)/test-proxy.log is the hardcoded output log location for the test-proxy-tool.yml
78+
cat $(Build.SourcesDirectory)/test-proxy.log
79+
displayName: 'Dump Test Proxy logs'
80+
condition: and(succeededOrFailed(), eq(variables['System.Debug'], 'true'))
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
parameters:
2+
# required matrix parameters
3+
- name: UsePlatformContainer
4+
type: boolean
5+
- name: OSName
6+
type: string
7+
- name: Matrix
8+
type: object
9+
- name: DependsOn
10+
type: string
11+
- name: CloudConfig
12+
type: object
13+
# custom parameters
14+
- name: ServiceDirectory
15+
type: string
16+
- name: TimeoutInMinutes
17+
type: number
18+
# live test parameters
19+
- name: EnvVars
20+
type: object
21+
- name: PreSteps
22+
type: object
23+
- name: PostSteps
24+
type: object
25+
- name: Location
26+
type: string
27+
- name: UseFederatedAuth
28+
type: boolean
29+
- name: PersistOidcToken
30+
type: boolean
31+
32+
jobs:
33+
- job:
34+
displayName: "Test"
35+
condition: and(succeeded(), ne(variables['Skip.Tests'],'true'), ne(${{ parameters.Matrix }}, '{}'))
36+
timeoutInMinutes: ${{ parameters.TimeoutInMinutes }}
37+
dependsOn: ${{ parameters.DependsOn }}
38+
39+
strategy:
40+
matrix: $[ ${{ parameters.Matrix }} ]
41+
42+
pool:
43+
name: $(Pool)
44+
# 1es pipeline templates converts `image` to demands: ImageOverride under the hood
45+
# which is incompatible with image selection in the default non-1es hosted pools
46+
${{ if eq(parameters.OSName, 'macOS') }}:
47+
vmImage: $(OSVmImage)
48+
${{ else }}:
49+
image: $(OSVmImage)
50+
os: ${{ parameters.OSName }}
51+
52+
variables:
53+
ArmTemplateParameters: '@{}'
54+
55+
steps:
56+
- template: /eng/common/pipelines/templates/steps/sparse-checkout.yml
57+
parameters:
58+
paths:
59+
- "/*"
60+
61+
- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml
62+
parameters:
63+
AgentImage: $(OSVmImage)
64+
65+
- template: /eng/pipelines/templates/steps/use-rust.yml@self
66+
parameters:
67+
Toolchain: $(RustToolchainName)
68+
69+
- ${{ parameters.PreSteps }}
70+
71+
- template: /eng/common/TestResources/build-test-resource-config.yml
72+
parameters:
73+
SubscriptionConfiguration: ${{ parameters.CloudConfig.SubscriptionConfiguration }}
74+
SubscriptionConfigurations: ${{ parameters.CloudConfig.SubscriptionConfigurations }}
75+
SubscriptionConfigurationFilePaths: ${{ parameters.CloudConfig.SubscriptionConfigurationFilePaths }}
76+
EnvVars:
77+
Pool: $(Pool)
78+
${{insert}}: ${{ parameters.EnvVars }}
79+
80+
- template: /eng/common/TestResources/deploy-test-resources.yml
81+
parameters:
82+
${{ if or(parameters.Location, parameters.CloudConfig.Location) }}:
83+
Location: ${{ coalesce(parameters.Location, parameters.CloudConfig.Location) }}
84+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
85+
SubscriptionConfiguration: $(SubscriptionConfiguration)
86+
ArmTemplateParameters: $(ArmTemplateParameters)
87+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
88+
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}
89+
SubscriptionConfigurationFilePaths: ${{ parameters.CloudConfig.SubscriptionConfigurationFilePaths}}
90+
PersistOidcToken: ${{ parameters.PersistOidcToken }}
91+
EnvVars:
92+
Pool: $(Pool)
93+
${{insert}}: ${{ parameters.EnvVars }}
94+
95+
# To allow tests to run in parallel to Pack, we don't reuse the PackageInfo directory
96+
# from the Pack job. We just let each test leg create its own PackageInfo directory.
97+
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml@self
98+
parameters:
99+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
100+
PackageInfoDirectory: $(Build.ArtifactStagingDirectory)/PackageInfo
101+
102+
- ${{ if parameters.UseFederatedAuth }}:
103+
- task: AzurePowerShell@5
104+
displayName: "Test Packages - Federated Auth"
105+
timeoutInMinutes: ${{ parameters.TimeoutInMinutes }}
106+
env:
107+
CIBW_BUILD_VERBOSITY: 3
108+
AZURE_TEST_MODE: 'live'
109+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
110+
${{ if parameters.PersistOidcToken }}:
111+
ARM_OIDC_TOKEN: $(ARM_OIDC_TOKEN)
112+
${{ insert }}: ${{ parameters.EnvVars }}
113+
inputs:
114+
azureSubscription: ${{ parameters.CloudConfig.ServiceConnection }}
115+
azurePowerShellVersion: LatestVersion
116+
pwsh: true
117+
scriptType: inlineScript
118+
inline: |
119+
$account = (Get-AzContext).Account;
120+
$env:AZURESUBSCRIPTION_CLIENT_ID = $account.Id;
121+
$env:AZURESUBSCRIPTION_TENANT_ID = $account.Tenants;
122+
123+
Write-Host "./eng/scripts/Test-Packages.ps1 -PackageInfoDirectory '$(Build.ArtifactStagingDirectory)/PackageInfo' -Toolchain '$(Toolchain)'"
124+
./eng/scripts/Test-Packages.ps1 -PackageInfoDirectory '$(Build.ArtifactStagingDirectory)/PackageInfo' -Toolchain '$(Toolchain)'
125+
workingDirectory: $(Build.SourcesDirectory)
126+
- ${{ else }}:
127+
- task: Powershell@2
128+
displayName: "Test Packages"
129+
timeoutInMinutes: ${{ parameters.TimeoutInMinutes }}
130+
env:
131+
CIBW_BUILD_VERBOSITY: 3
132+
AZURE_TEST_MODE: 'live'
133+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
134+
${{ insert }}: ${{ parameters.EnvVars }}
135+
inputs:
136+
pwsh: true
137+
filePath: $(Build.SourcesDirectory)/eng/scripts/Test-Packages.ps1
138+
arguments: >
139+
-PackageInfoDirectory '$(Build.ArtifactStagingDirectory)/PackageInfo'
140+
-Toolchain '$(Toolchain)'
141+
142+
- ${{ parameters.PostSteps }}
143+
144+
- template: /eng/common/TestResources/remove-test-resources.yml
145+
parameters:
146+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
147+
SubscriptionConfiguration: $(SubscriptionConfiguration)
148+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
149+
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}
150+
EnvVars: ${{ parameters.EnvVars }}

eng/pipelines/templates/jobs/pack.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ jobs:
2424
paths:
2525
- "/*"
2626

27-
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], '')) }}:
28-
- script: |
29-
echo "##vso[build.addbuildtag]$(Build.Reason)"
30-
displayName: Tag build reason
27+
- pwsh: |
28+
Write-Host "Attaching build reason string to the build for additional tag generation."
29+
@('$(Build.Reason)') | ConvertTo-Json -AsArray | Out-File -FilePath $(System.DefaultWorkingDirectory)/build-reason.json -Encoding utf8
30+
Write-Host '##vso[task.addattachment type=AdditionalTags;name=AdditionalTags;]$(System.DefaultWorkingDirectory)/build-reason.json'
31+
displayName: Tag build reason
3132
3233
- template: /eng/pipelines/templates/steps/use-rust.yml@self
3334
parameters:

eng/pipelines/templates/stages/archetype-sdk-client.yml

Lines changed: 101 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,35 @@ parameters:
44
- name: Artifacts
55
type: object
66
default: []
7+
- name: IncludeRelease
8+
type: boolean
9+
default: true
10+
- name: RunLiveTests
11+
type: boolean
12+
default: true
713
# Test Parameters
814
- name: TestTimeoutInMinutes
915
type: number
1016
default: 60
17+
- name: TestProxy
18+
type: boolean
19+
default: true
20+
- name: Clouds
21+
type: string
22+
default: 'Public'
23+
- name: SupportedClouds
24+
type: string
25+
default: 'Public'
26+
- name: UnsupportedClouds
27+
type: string
28+
default: ''
29+
- name: CloudConfig
30+
type: object
31+
default:
32+
Public:
33+
# Canary regions are currently not supported in TME so disabling for now
34+
# Canary:
35+
# Location: 'centraluseuap'
1136
- name: MatrixConfigs
1237
type: object
1338
default:
@@ -25,9 +50,24 @@ parameters:
2550
- name: MatrixReplace
2651
type: object
2752
default: []
28-
- name: TestProxy
53+
- name: UseFederatedAuth
2954
type: boolean
3055
default: true
56+
- name: PersistOidcToken
57+
type: boolean
58+
default: false
59+
- name: PreSteps
60+
type: object
61+
default: []
62+
- name: PostSteps
63+
type: object
64+
default: []
65+
- name: Location
66+
type: string
67+
default: ''
68+
- name: EnvVars
69+
type: object
70+
default: {}
3171

3272
extends:
3373
template: /eng/pipelines/templates/stages/1es-redirect.yml
@@ -48,17 +88,66 @@ extends:
4888
TestTimeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
4989
TestProxy: ${{ parameters.TestProxy }}
5090
MatrixConfigs:
51-
- ${{ each config in parameters.MatrixConfigs }}:
52-
- ${{ config }}
53-
- ${{ each config in parameters.AdditionalMatrixConfigs }}:
54-
- ${{ config }}
91+
- ${{ parameters.MatrixConfigs }}
92+
- ${{ parameters.AdditionalMatrixConfigs }}
5593
MatrixFilters: ${{ parameters.MatrixFilters }}
5694
MatrixReplace: ${{ parameters.MatrixReplace }}
5795

58-
- template: archetype-rust-release.yml
59-
parameters:
60-
DependsOn: "Build"
61-
ServiceDirectory: ${{ parameters.ServiceDirectory }}
62-
Artifacts: ${{ parameters.Artifacts }}
63-
TestPipeline: ${{ eq(parameters.ServiceDirectory, 'template') }}
64-
PipelineArtifactName: packages
96+
# Run live tests for internal only, not public CI builds. This can be triggered manually for via an `/azp run` comment.
97+
- ${{if eq(parameters.RunLiveTests, 'true') }}:
98+
- ${{ each cloud in parameters.CloudConfig }}:
99+
# Run all clouds by default for weekly test pipeline, except for clouds specifically unsupported by the calling pipeline
100+
- ${{ if or(contains(parameters.Clouds, cloud.key), and(contains(variables['Build.DefinitionName'], 'weekly'), contains(parameters.SupportedClouds, cloud.key))) }}:
101+
- ${{ if not(contains(parameters.UnsupportedClouds, cloud.key)) }}:
102+
- stage: ${{ cloud.key }}
103+
displayName: Live Test ${{ cloud.key }}
104+
variables:
105+
- template: /eng/pipelines/templates/variables/globals.yml
106+
- template: /eng/pipelines/templates/variables/image.yml
107+
- template: /eng/pipelines/templates/variables/rust.yml
108+
dependsOn: []
109+
jobs:
110+
- template: /eng/common/pipelines/templates/jobs/generate-job-matrix.yml
111+
parameters:
112+
JobTemplatePath: /eng/pipelines/templates/jobs/live.tests.yml
113+
AdditionalParameters:
114+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
115+
TimeoutInMinutes: ${{ parameters.TestTimeoutInMinutes }}
116+
EnvVars: ${{ parameters.EnvVars }}
117+
PreSteps: ${{ parameters.PreSteps }}
118+
PostSteps: ${{ parameters.PostSteps }}
119+
Location: ${{ parameters.Location }}
120+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
121+
PersistOidcToken: ${{ parameters.PersistOidcToken }}
122+
MatrixConfigs:
123+
# Enumerate platforms and additional platforms based on supported clouds (sparse platform<-->cloud matrix).
124+
- ${{ parameters.MatrixConfigs }}
125+
- ${{ parameters.AdditionalMatrixConfigs }}
126+
MatrixFilters:
127+
- ${{ cloud.value.MatrixFilters }}
128+
- ${{ parameters.MatrixFilters }}
129+
MatrixReplace:
130+
- ${{ cloud.value.MatrixReplace }}
131+
- ${{ parameters.MatrixReplace }}
132+
CloudConfig:
133+
Cloud: ${{ cloud.key }}
134+
Location: ${{ coalesce(cloud.value.Location, parameters.Location) }}
135+
ServiceConnection: ${{ coalesce(cloud.value.ServiceConnection, lower(format('azure-sdk-tests-{0}', cloud.key))) }}
136+
SubscriptionConfiguration: ${{ cloud.value.SubscriptionConfiguration }}
137+
SubscriptionConfigurations: ${{ cloud.value.SubscriptionConfigurations }}
138+
SubscriptionConfigurationFilePaths: ${{ cloud.value.SubscriptionConfigurationFilePaths }}
139+
140+
# The Prerelease and Release stages are conditioned on:
141+
# 1. Internal trigger, not Pull Request trigger
142+
# 2. Not weekly build
143+
# 3. Manual trigger or force IncludeRelease
144+
- ${{ if and(not(startsWith(variables['Build.SourceBranchName'], 'refs/pull/')), eq(variables['System.TeamProject'], 'internal')) }}:
145+
- ${{ if not(contains(variables['Build.DefinitionName'], 'weekly')) }}:
146+
- ${{ if or(in(variables['Build.Reason'], 'Manual', ''), eq(parameters.IncludeRelease, true)) }}:
147+
- template: archetype-rust-release.yml
148+
parameters:
149+
DependsOn: "Build"
150+
ServiceDirectory: ${{ parameters.ServiceDirectory }}
151+
Artifacts: ${{ parameters.Artifacts }}
152+
TestPipeline: ${{ eq(parameters.ServiceDirectory, 'template') }}
153+
PipelineArtifactName: packages
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
variables:
22
RUSTFLAGS: "-Dwarnings"
33
RUSTDOCFLAGS: "-Dwarnings"
4+
RUST_LOG: $[iif(eq(variables['System.Debug'], 'true'), 'debug', '')]

eng/scripts/Test-Packages.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ Write-Host @"
1515
Testing packages with
1616
Toolchain: '$Toolchain'
1717
PackageInfoDirectory: '$PackageInfoDirectory'
18-
RUSTFLAGS: '${env:RUSTFLAGS}'
19-
RUSTDOCFLAGS: '${env:RUSTDOCFLAGS}'
18+
RUSTFLAGS: '$env:RUSTFLAGS'
19+
RUSTDOCFLAGS: '$env:RUSTDOCFLAGS'
20+
RUST_LOG: '$env:RUST_LOG'
21+
AZURE_TEST_MODE: '$env:AZURE_TEST_MODE'
22+
SYSTEM_ACCESSTOKEN: $($env:SYSTEM_ACCESSTOKEN ? 'present' : 'not present')
23+
ARM_OIDC_TOKEN: $($env:ARM_OIDC_TOKEN ? 'present' : 'not present')
2024
"@
2125

2226
if ($PackageInfoDirectory) {

sdk/eventhubs/azure_messaging_eventhubs/tests/common/mod.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)