-
Notifications
You must be signed in to change notification settings - Fork 329
Expand file tree
/
Copy pathci-run-tests-job.yml
More file actions
403 lines (354 loc) · 17.7 KB
/
ci-run-tests-job.yml
File metadata and controls
403 lines (354 loc) · 17.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#################################################################################
# Licensed to the .NET Foundation under one or more agreements. #
# The .NET Foundation licenses this file to you under the MIT license. #
# See the LICENSE file in the project root for more information. #
#################################################################################
parameters:
# The name of the Abstractions pipeline artifact to download when referenceType is 'Package'.
- name: abstractionsArtifactsName
type: string
# The version of the Abstractions package to depend on when referenceType is 'Package'.
- name: abstractionsPackageVersion
type: string
# The name of the Logging pipeline artifact to download when referenceType is 'Package'.
- name: loggingArtifactsName
type: string
default: Logging.Artifacts
# The version of the Logging package to depend on when referenceType is 'Package'.
- name: loggingPackageVersion
type: string
# The configuration properties to set in the config file.
#
# GOTCHA: The following keys are used in template expressions and must be
# specified as boolean strings 'true' or 'false'. They cannot be specified as
# runtime variables like $(SomeBooleanVar), since those are expanded after
# template compilation and will literally be "$(SomeBooleanVar)" during
# template expansion.
#
# EnclaveEnabled
# IsDNSCachingSupportedCR
# IsDNSCachingSupportedTR
# ManagedIdentitySupported
# SupportsIntegratedSecurity
# TracingEnabled
#
- name: configProperties
type: object
default: {} # - key: 'value'
# The type of SQL Server to configure.
- name: configSqlFor
type: string
values:
- azure
- enclave
- local
default: local
# True to emit debug information and steps.
- name: debug
type: boolean
default: false
# True to enable testing for the x64 architecture.
- name: enableX64Test
type: boolean
default: true
# True to enable testing for the x86 architecture.
- name: enableX86Test
type: boolean
default: false
# True if this job will run in a generic Azure Pipelines hosted pool; false to run in a custom 1ES
# pool.
- name: hostedPool
type: boolean
default: false
# The VM image to use, which must exist in the specified pool.
- name: image
type: string
# The display name for this job.
- name: jobDisplayName
type: string
# The name of the SqlClient pipeline artifacts to download.
- name: mdsArtifactsName
type: string
# The version of the SqlClient package to depend on when referenceType is 'Package'.
- name: mdsPackageVersion
type: string
# The name of the SqlServer pipeline artifact to download when referenceType is 'Package'.
- name: sqlServerArtifactsName
type: string
default: SqlServer.Artifacts
# The version of the SqlServer package to depend on when referenceType is 'Package'.
- name: sqlServerPackageVersion
type: string
default: $(sqlServerPackageVersion)
# TODO: What is this for?
- name: netcoreVersionTestUtils
type: string
# The OS to build and run the tests for.
- name: operatingSystem
type: string
values:
- Linux
- Mac
- Windows
default: Windows
# The C# build configuration to build (e.g. Debug or Release).
- name: buildConfiguration
type: string
values:
- Debug
- Release
# The name of the Azure Pipelines pool to use.
- name: poolName
type: string
# Steps to run before each build, if any.
- name: prebuildSteps
type: stepList
default: []
# The C# project reference type to use when building and packing the packages.
- name: referenceType
type: string
values:
# Reference sibling packages as NuGet packages.
- Package
# Reference sibling packages as C# projects.
- Project
# The target framework to build and run tests for.
- name: targetFramework
type: string
# The test set to run.
- name: testSet
type: string
# The timeout, in minutes, for this job.
- name: timeout
type: number
# True if this is an ARM64 job.
- name: isArm64
type: boolean
default: false
# True to use managed SNI, where applicable.
- name: usemanagedSNI
type: boolean
default: false
# The SA password to set when configuring SQL Server.
- name: saPassword
type: string
jobs:
- job: ${{ format('{0}', coalesce(parameters.jobDisplayName, parameters.image, 'unknown_image')) }}
# Some of our tests take longer than the default 60 minutes to run on some
# OSes and configurations.
timeoutInMinutes: ${{ parameters.timeout }}
pool:
name: '${{ parameters.poolName }}'
${{ if eq(parameters.hostedPool, true) }}:
vmImage: ${{ parameters.image }}
${{ else }}:
demands:
- imageOverride -equals ${{ parameters.image }}
variables:
- name: dotnetx86RootPath
value: '$(dotnetx86Path)'
steps:
# If we're testing in Package mode, download the Abstractions and MDS package
# artifacts and put them in the packages/ directory in the repo root.
- ${{ if eq(parameters.referenceType, 'Package') }}:
- task: DownloadPipelineArtifact@2
displayName: Download Abstractions Package Artifacts
inputs:
artifactName: ${{ parameters.abstractionsArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
- task: DownloadPipelineArtifact@2
displayName: Download Logging Package Artifacts
inputs:
artifactName: ${{ parameters.loggingArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
- task: DownloadPipelineArtifact@2
displayName: Download MDS Package Artifacts
inputs:
artifactName: ${{ parameters.mdsArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
- task: DownloadPipelineArtifact@2
displayName: Download SqlServer Package Artifacts
inputs:
artifactName: ${{ parameters.sqlServerArtifactsName }}
targetPath: $(Build.SourcesDirectory)/packages
# Install the .NET SDK and Runtimes.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
debug: ${{ parameters.debug }}
${{ if parameters.isArm64 }}:
architecture: arm64
# ARM64 needs to specify slightly different runtime version formats.
# See the install-dotnet template docs for more info.
runtimes: ['8.0', '9.0']
${{ else }}:
runtimes: [8.x, 9.x]
# Restore dotnet CLI tools (e.g. pwsh, apicompat) before building.
- template: /eng/pipelines/steps/restore-dotnet-tools.yml@self
- ${{ if ne(parameters.prebuildSteps, '') }}:
- ${{ parameters.prebuildSteps }} # extra steps to run before the build like downloading sni and the required configuration
- ${{ if eq(parameters.referenceType, 'Project') }}:
- template: ../steps/ci-project-build-step.yml@self
parameters:
build: allNoDocs
buildConfiguration: ${{ parameters.buildConfiguration }}
referenceType: Project
- ${{ if ne(parameters.configProperties, '{}') }}:
- template: /eng/pipelines/common/templates/steps/update-config-file-step.yml@self # update config.jsonc file
parameters:
debug: ${{ parameters.debug }}
saPassword: ${{ parameters.saPassword }}
UseManagedSNIOnWindows: ${{ parameters.usemanagedSNI }}
${{ if parameters.configProperties.TCPConnectionString }}:
TCPConnectionString: ${{ parameters.configProperties.TCPConnectionString }}
${{ if parameters.configProperties.NPConnectionString }}:
NPConnectionString: ${{ parameters.configProperties.NPConnectionString }}
${{ if parameters.configProperties.AADAuthorityURL }}:
AADAuthorityURL: ${{ parameters.configProperties.AADAuthorityURL }}
${{ if parameters.configProperties.TCPConnectionStringHGSVBS }}:
TCPConnectionStringHGSVBS: ${{ parameters.configProperties.TCPConnectionStringHGSVBS }}
${{ if parameters.configProperties.TCPConnectionStringNoneVBS }}:
TCPConnectionStringNoneVBS: ${{ parameters.configProperties.TCPConnectionStringNoneVBS }}
${{ if parameters.configProperties.TCPConnectionStringAASSGX }}:
TCPConnectionStringAASSGX: ${{ parameters.configProperties.TCPConnectionStringAASSGX }}
${{ if parameters.configProperties.EnclaveEnabled }}:
EnclaveEnabled: ${{ eq(parameters.configProperties.EnclaveEnabled, 'true') }}
${{ if parameters.configProperties.TracingEnabled }}:
TracingEnabled: ${{ eq(parameters.configProperties.TracingEnabled, 'true') }}
${{ if parameters.configProperties.AADPasswordConnectionString }}:
AADPasswordConnectionString: ${{ parameters.configProperties.AADPasswordConnectionString }}
${{ if parameters.configProperties.AADServicePrincipalId }}:
AADServicePrincipalId: ${{ parameters.configProperties.AADServicePrincipalId }}
${{ if parameters.configProperties.AADServicePrincipalSecret }}:
AADServicePrincipalSecret: ${{ parameters.configProperties.AADServicePrincipalSecret }}
${{ if parameters.configProperties.AzureKeyVaultUrl }}:
AzureKeyVaultUrl: ${{ parameters.configProperties.AzureKeyVaultUrl }}
${{ if parameters.configProperties.AzureKeyVaultTenantId }}:
AzureKeyVaultTenantId: ${{ parameters.configProperties.AzureKeyVaultTenantId }}
${{ if parameters.configProperties.UserManagedIdentityClientId }}:
UserManagedIdentityClientId: ${{ parameters.configProperties.UserManagedIdentityClientId }}
${{ if parameters.configProperties.FileStreamDirectory }}:
FileStreamDirectory: ${{ parameters.configProperties.FileStreamDirectory }}
${{ if parameters.configProperties.LocalDbAppName }}:
LocalDbAppName: ${{ parameters.configProperties.LocalDbAppName }}
${{ if parameters.configProperties.LocalDbSharedInstanceName }}:
LocalDbSharedInstanceName: ${{ parameters.configProperties.LocalDbSharedInstanceName }}
${{ if parameters.configProperties.AliasName }}:
AliasName: ${{ parameters.configProperties.AliasName }}
${{ if parameters.configProperties.SupportsIntegratedSecurity }}:
SupportsIntegratedSecurity: ${{ eq(parameters.configProperties.SupportsIntegratedSecurity, 'true') }}
${{ if parameters.configProperties.DNSCachingConnString }}:
DNSCachingConnString: ${{ parameters.configProperties.DNSCachingConnString }}
${{ if parameters.configProperties.DNSCachingServerCR }}:
DNSCachingServerCR: ${{ parameters.configProperties.DNSCachingServerCR }}
${{ if parameters.configProperties.DNSCachingServerTR }}:
DNSCachingServerTR: ${{ parameters.configProperties.DNSCachingServerTR }}
${{ if parameters.configProperties.EnclaveAzureDatabaseConnString }}:
EnclaveAzureDatabaseConnString: ${{ parameters.configProperties.EnclaveAzureDatabaseConnString }}
${{ if parameters.configProperties.IsDNSCachingSupportedCR }}:
IsDNSCachingSupportedCR: ${{ eq(parameters.configProperties.IsDNSCachingSupportedCR, 'true') }}
${{ if parameters.configProperties.IsDNSCachingSupportedTR }}:
IsDNSCachingSupportedTR: ${{ eq(parameters.configProperties.IsDNSCachingSupportedTR, 'true') }}
${{ if parameters.configProperties.ManagedIdentitySupported }}:
ManagedIdentitySupported: ${{ eq(parameters.configProperties.ManagedIdentitySupported, 'true') }}
- ${{ if and(eq(parameters.configSqlFor, 'azure'), eq(parameters.operatingSystem, 'Windows')) }}:
- powershell: |
# Try to start the SQL Browser service, if it exists
$svc_name = "SQLBrowser"
if ((Get-Service -Name "$svc_name" -ErrorAction SilentlyContinue) -ne $null) {
Get-Service $svc_name | Select-Object -Property Name, StartType, Status
Set-Service -StartupType Automatic $svc_name
net start $svc_name
Get-Service $svc_name | Select-Object -Property Name, StartType, Status
}
displayName: 'Start Sql Browser'
condition: eq(variables['Agent.OS'], 'Windows_NT')
- ${{ elseif eq(parameters.configSqlFor, 'local') }}:
- template: /eng/pipelines/common/templates/steps/configure-sql-server-step.yml@self # configure SQL Server
parameters:
operatingSystem: ${{ parameters.operatingSystem }}
netcoreVersionTestUtils: ${{ parameters.netcoreVersionTestUtils }}
saPassword: ${{ parameters.saPassword }}
${{ if parameters.configProperties.instanceName }}:
instanceName: ${{ parameters.configProperties.instanceName }}
${{ if parameters.configProperties.user }}:
user: ${{ parameters.configProperties.user }}
${{ if parameters.configProperties.saUser }}:
saUser: ${{ parameters.configProperties.saUser }}
${{ if parameters.configProperties.SQLRootPath }}:
SQLRootPath: ${{ parameters.configProperties.SQLRootPath }}
${{ if parameters.configProperties.x64AliasRegistryPath }}:
x64AliasRegistryPath: ${{ parameters.configProperties.x64AliasRegistryPath }}
${{ if parameters.configProperties.x86AliasRegistryPath }}:
x86AliasRegistryPath: ${{ parameters.configProperties.x86AliasRegistryPath }}
${{ if parameters.configProperties.SQLAliasName }}:
SQLAliasName: ${{ parameters.configProperties.SQLAliasName }}
${{ if parameters.configProperties.SQLAliasPort }}:
SQLAliasPort: ${{ parameters.configProperties.SQLAliasPort }}
${{ if parameters.configProperties.databaseName }}:
databaseName: ${{ parameters.configProperties.databaseName }}
${{ if parameters.configProperties.enableLocalDB }}:
enableLocalDB: ${{ parameters.configProperties.enableLocalDB }}
${{ if parameters.configProperties.localDbAppName }}:
LocalDbAppName: ${{ parameters.configProperties.localDbAppName }}
${{ if parameters.configProperties.localDbSharedInstanceName }}:
LocalDbSharedInstanceName: ${{ parameters.configProperties.localDbSharedInstanceName }}
${{ if parameters.configProperties.FileStreamDirectory }}:
fileStreamDirectory: ${{ parameters.configProperties.FileStreamDirectory }}
# Set up for x86 tests by manually installing dotnet for x86 to an alternative location. This
# is only used to execute the test runtime (framework to test is specified in build params), so
# it should be acceptable to just install a specific version in all cases.
# @TODO: This setup is very confusing. Ideally we should just be utilizing the dotnet installation
# earlier in the job. There has to be a cleaner way of doing this.
- ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}:
- ${{ if ne(variables['dotnetx86RootPath'], '') }}:
# Install the .NET SDK and Runtimes for x86.
- template: /eng/pipelines/steps/install-dotnet.yml@self
parameters:
architecture: x86
debug: ${{ parameters.debug }}
installDir: $(dotnetx86RootPath)
runtimes: [8.x, 9.x]
# Ensure TestResults directory exists so that publish steps don't fail when
# tests are skipped due to a setup failure.
- pwsh: New-Item -ItemType Directory -Path TestResults -Force | Out-Null
displayName: 'Create TestResults Directory'
# Gate: record that all setup steps (SDK install, build, SQL config, x86 SDK
# install, etc.) completed successfully. Test steps condition on this variable
# so they are skipped when setup fails, yet remain independent of each
# other's results.
- pwsh: Write-Host '##vso[task.setvariable variable=setupSucceeded]true'
displayName: 'Gate: Mark Setup Succeeded'
- ${{ if eq(parameters.enableX64Test, true) }}: # run native tests
- template: /eng/pipelines/common/templates/steps/run-all-tests-step.yml@self # run tests
parameters:
debug: ${{ parameters.debug }}
targetFramework: ${{ parameters.targetFramework }}
buildConfiguration: ${{ parameters.buildConfiguration }}
referenceType: ${{ parameters.referenceType }}
testSet: ${{ parameters.testSet }}
operatingSystem: ${{ parameters.operatingSystem }}
abstractionsPackageVersion: ${{ parameters.abstractionsPackageVersion }}
loggingPackageVersion: ${{ parameters.loggingPackageVersion }}
mdsPackageVersion: ${{ parameters.mdsPackageVersion }}
sqlServerPackageVersion: ${{ parameters.sqlServerPackageVersion }}
- ${{ if and(eq(parameters.enableX86Test, true), eq(parameters.operatingSystem, 'Windows')) }}:
- template: /eng/pipelines/common/templates/steps/run-all-tests-step.yml@self
parameters:
debug: ${{ parameters.debug }}
targetFramework: ${{ parameters.targetFramework }}
buildConfiguration: ${{ parameters.buildConfiguration }}
referenceType: ${{ parameters.referenceType }}
testSet: ${{ parameters.testSet }}
msbuildArchitecture: x86
dotnetx86RootPath: $(dotnetx86RootPath)
operatingSystem: ${{ parameters.operatingSystem }}
abstractionsPackageVersion: ${{ parameters.abstractionsPackageVersion }}
loggingPackageVersion: ${{ parameters.loggingPackageVersion }}
mdsPackageVersion: ${{ parameters.mdsPackageVersion }}
sqlServerPackageVersion: ${{ parameters.sqlServerPackageVersion }}
- template: /eng/pipelines/common/templates/steps/publish-test-results-step.yml@self
parameters:
debug: ${{ parameters.debug }}
targetFramework: ${{ parameters.targetFramework }}
operatingSystem: ${{ parameters.operatingSystem }}
buildConfiguration: ${{ parameters.buildConfiguration }}