Skip to content

Commit 955e5aa

Browse files
authored
Federated auth for live tests (Azure#23018)
* Wire up federated auth and migrate test jobs * exit $LASTEXITCODE * Activate federated auth for azappconfig * Authenticate perf tests, too * expression * Correct params * Remove reference to secret, better naming in build-test.yml * ./ * InlineScript * Testing comment * Review feedback * Review feedback: plumb EnvVars * List * Revert test ci.yml changes * s * Map SYSTEM_ACCESSTOKEN in environment for processes that need auth
1 parent e11cc49 commit 955e5aa

File tree

4 files changed

+92
-26
lines changed

4 files changed

+92
-26
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,30 @@ parameters:
4040
default:
4141
Public:
4242
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
43+
ServiceConnection: azure-sdk-tests
44+
SubscriptionConfigurationFilePaths:
45+
- eng/common/TestResources/sub-config/AzurePublicMsft.json
4346
Preview:
4447
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview)
48+
ServiceConnection: azure-sdk-tests
49+
# TODO:
50+
SubscriptionConfigurationFilePaths:
4551
Canary:
4652
SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources)
53+
ServiceConnection: azure-sdk-tests
54+
# TODO:
55+
SubscriptionConfigurationFilePaths:
4756
Location: 'centraluseuap'
4857
UsGov:
4958
SubscriptionConfiguration: $(sub-config-gov-test-resources)
59+
ServiceConnection: usgov_azure-sdk-tests
60+
# TODO:
61+
SubscriptionConfigurationFilePaths:
5062
China:
5163
SubscriptionConfiguration: $(sub-config-cn-test-resources)
64+
ServiceConnection: china_azure-sdk-tests
65+
# TODO:
66+
SubscriptionConfigurationFilePaths:
5267
- name: MatrixConfigs
5368
type: object
5469
default:
@@ -86,6 +101,9 @@ parameters:
86101
- name: EnableRaceDetector
87102
type: boolean
88103
default: false
104+
- name: UseFederatedAuth
105+
type: boolean
106+
default: false
89107

90108
extends:
91109
template: /eng/pipelines/templates/stages/1es-redirect.yml
@@ -180,6 +198,7 @@ extends:
180198
- ${{ parameters.PreSteps }}
181199
PostSteps:
182200
- ${{ parameters.PostSteps }}
201+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
183202
MatrixConfigs:
184203
# Enumerate platforms and additional platforms based on supported clouds (sparse platform<-->cloud matrix).
185204
- ${{ each config in parameters.MatrixConfigs }}:
@@ -199,6 +218,8 @@ extends:
199218
SubscriptionConfigurations: ${{ cloud.value.SubscriptionConfigurations }}
200219
Location: ${{ coalesce(parameters.Location, cloud.value.Location) }}
201220
Cloud: ${{ cloud.key }}
221+
ServiceConnection: ${{ cloud.value.ServiceConnection }}
222+
SubscriptionConfigurationFilePaths: ${{ cloud.value.SubscriptionConfigurationFilePaths }}
202223

203224
# The Prerelease and Release stages are conditioned on:
204225
# 1. Internal trigger, not Pull Request trigger

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ parameters:
3333
default: '600s'
3434
- name: OSName
3535
type: string
36+
- name: UseFederatedAuth
37+
type: boolean
38+
default: false
3639

3740
jobs:
3841
- job:
@@ -83,6 +86,10 @@ jobs:
8386
ServiceDirectory: ${{ parameters.ServiceDirectory }}
8487
SubscriptionConfiguration: $(SubscriptionConfiguration)
8588
ArmTemplateParameters: $(ArmTemplateParameters)
89+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
90+
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}
91+
SubscriptionConfigurationFilePaths: ${{ parameters.CloudConfig.SubscriptionConfigurationFilePaths}}
92+
EnvVars: ${{ parameters.EnvVars }}
8693

8794
- task: GoTool@0
8895
inputs:
@@ -97,6 +104,8 @@ jobs:
97104
Image: $(OSVmImage)
98105
GoVersion: $(GoVersion)
99106
TestRunTime: ${{ parameters.TestRunTime }}
107+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
108+
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}
100109
EnvVars:
101110
AZURE_RECORD_MODE: 'live'
102111
${{ insert }}: ${{ parameters.EnvVars }}
@@ -107,3 +116,6 @@ jobs:
107116
parameters:
108117
ServiceDirectory: ${{ parameters.ServiceDirectory }}
109118
SubscriptionConfiguration: $(SubscriptionConfiguration)
119+
UseFederatedAuth: ${{ parameters.UseFederatedAuth }}
120+
ServiceConnection: ${{ parameters.CloudConfig.ServiceConnection }}
121+
EnvVars: ${{ parameters.EnvVars }}

eng/pipelines/templates/steps/build-test.yml

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ parameters:
2020
- name: EnableRaceDetector
2121
type: boolean
2222
default: false
23+
- name: UseFederatedAuth
24+
type: boolean
25+
default: false
26+
- name: ServiceConnection
27+
type: string
28+
default: ''
2329

2430
steps:
2531
- task: Powershell@2
@@ -68,27 +74,60 @@ steps:
6874
- ${{ if eq(parameters.TestProxy, true) }}:
6975
- template: /eng/common/testproxy/test-proxy-tool.yml
7076

71-
- task: PowerShell@2
72-
displayName: 'Run Tests'
73-
inputs:
74-
targetType: 'filePath'
75-
filePath: ./eng/scripts/run_tests.ps1
76-
arguments: '${{ parameters.ServiceDirectory }} ${{ parameters.TestRunTime }} $${{ parameters.EnableRaceDetector }}'
77-
pwsh: true
78-
env:
79-
GO111MODULE: 'on'
80-
PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
81-
${{ insert }}: ${{ parameters.EnvVars }}
82-
GOTRACEBACK: all
83-
AZURE_SDK_GO_LOGGING: all
77+
- ${{ if parameters.UseFederatedAuth }}:
78+
- task: AzurePowerShell@5
79+
displayName: Run Tests (Federated Auth)
80+
inputs:
81+
azureSubscription: ${{ parameters.ServiceConnection }}
82+
azurePowerShellVersion: LatestVersion
83+
ScriptType: InlineScript
84+
Inline: |
85+
./eng/scripts/run_tests.ps1 ${{ parameters.ServiceDirectory }} ${{ parameters.TestRunTime }} $${{ parameters.EnableRaceDetector }}
86+
exit $LASTEXITCODE
87+
pwsh: true
88+
env:
89+
GO111MODULE: 'on'
90+
PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
91+
${{ insert }}: ${{ parameters.EnvVars }}
92+
GOTRACEBACK: all
93+
AZURE_SDK_GO_LOGGING: all
94+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
8495

85-
- task: PowerShell@2
86-
displayName: 'Build Performance Tests'
87-
inputs:
88-
targetType: 'filePath'
89-
filePath: ./eng/scripts/Build_Perf.ps1
90-
arguments: '${{ parameters.ServiceDirectory }} $$(UseAzcoreFromMain)'
91-
pwsh: true
96+
- task: AzurePowerShell@5
97+
displayName: Build Performance Tests (Federated Auth)
98+
inputs:
99+
azureSubscription: ${{ parameters.ServiceConnection }}
100+
azurePowerShellVersion: LatestVersion
101+
ScriptType: InlineScript
102+
Inline: |
103+
eng/scripts/Build_Perf.ps1 ${{ parameters.ServiceDirectory }} $$(UseAzcoreFromMain)
104+
exit $LASTEXITCODE
105+
pwsh: true
106+
env:
107+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
108+
109+
- ${{ else }}:
110+
- task: PowerShell@2
111+
displayName: 'Run Tests'
112+
inputs:
113+
targetType: 'filePath'
114+
filePath: ./eng/scripts/run_tests.ps1
115+
arguments: '${{ parameters.ServiceDirectory }} ${{ parameters.TestRunTime }} $${{ parameters.EnableRaceDetector }}'
116+
pwsh: true
117+
env:
118+
GO111MODULE: 'on'
119+
PROXY_CERT: $(Build.SourcesDirectory)/eng/common/testproxy/dotnet-devcert.crt
120+
${{ insert }}: ${{ parameters.EnvVars }}
121+
GOTRACEBACK: all
122+
AZURE_SDK_GO_LOGGING: all
123+
124+
- task: PowerShell@2
125+
displayName: 'Build Performance Tests'
126+
inputs:
127+
targetType: 'filePath'
128+
filePath: ./eng/scripts/Build_Perf.ps1
129+
arguments: '${{ parameters.ServiceDirectory }} $$(UseAzcoreFromMain)'
130+
pwsh: true
92131

93132
- ${{ if eq(parameters.TestProxy, true) }}:
94133
- pwsh: |

sdk/data/azappconfig/test-resources.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
"description": "The application client ID used to run tests."
2222
}
2323
},
24-
"testApplicationSecret": {
25-
"type": "string",
26-
"metadata": {
27-
"description": "The application client secret used to run tests."
28-
}
29-
},
3024
"testApplicationOid": {
3125
"type": "string",
3226
"metadata": {

0 commit comments

Comments
 (0)