-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparseStageInfo.groovy
executable file
·408 lines (382 loc) · 15.6 KB
/
parseStageInfo.groovy
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
404
405
406
407
408
/* groovylint-disable DuplicateStringLiteral, NestedBlockDepth, VariableName */
// vars/parseStageInfo.groovy
/**
* Method to get a MAP of values based on environment variables that
* are known to the stage.
*
* The map may have following members if there is a default value for them.
*
* result['compiler'] Known compilers are 'gcc', 'icc', clang, and 'covc'.
* Default is 'gcc'
*
* result['target'] Known targets are 'centos7','centos8','el8', 'leap15',
* 'ubuntu18.04', 'ubuntu20.04'. Default is 'centos7'
*
* result['target_prefix'] Target prefix to use for the build if present.
* Default is not present unless the word
* TARGET_PREFIX is present in env.STAGE_NAME,
* and then it will default to 'install/opt'
*
* This is to simplify the addition of stages to the Jenkinsfile so
* that in many cases, only the Stage Name text needs to be updated.
*
* If matrix builds are implemented, this will need to be adjusted to
* use the environment variables for the axes.
*
* If these config values are supplied, they must match what is documented
* for the result described above.
*
* config['compiler']
* config['target']
* config['target_prefix']
* @param config Map of parameters passed
*
* config['test_tag'] Avocado tag to test.
* Default determined by this function below.
*/
String get_build_params_tags() {
// Get the tags defined by the build parameter entry for this stage
if (params.TestTag && params.TestTag != '') {
return params.TestTag
}
return ''
}
String get_commit_pragma_tags(String pragma_suffix) {
// Get the test tags defined in the commit message
String pragma_tag
// Use the tags defined by the stage-specific 'Test-tag-<stage>:' commit message pragma. If those
// are not specified use the tags defined by the general 'Test-tag:' commit message pragma.
pragma_tag = commitPragma('Test-tag' + pragma_suffix, commitPragma('Test-tag', null))
if (pragma_tag) {
return pragma_tag
}
// If neither of the 'Test-tag*:' commit message pragmas are specified, use the 'Features:'
// commit message pragma to define the tags to use.
String features = commitPragma('Features', null)
if (features) {
// Features extend the standard pr testing tags to include tests run in daily or weekly builds
// that test the specified feature.
pragma_tag = 'pr'
for (feature in features.split(' ')) {
pragma_tag += ' daily_regression,' + feature
pragma_tag += ' full_regression,' + feature
}
}
return pragma_tag
}
String get_default_nvme() {
// Get the default test nvme setting
if (env.BRANCH_NAME.startsWith('feature/vos_on_blob')) {
if (startedByTimer()) {
return 'auto_md_on_ssd'
}
return 'auto'
}
return 'auto:-3DNAND'
}
/* groovylint-disable-next-line MethodSize */
Map call(Map config = [:]) {
Map result = [:]
String stage_name = ''
if (env.STAGE_NAME) {
stage_name = env.STAGE_NAME
}
String new_ci_target = ''
if (config['target']) {
result['target'] = config['target']
} else if (env.TARGET) {
result['target'] = env.TARGET
result['distro_version'] = '7'
} else {
if (env.STAGE_NAME.contains('Hardware')) {
res = hwDistroTarget2()
result['target'] = res[0] + res[1]
result['distro_version'] = res[1]
} else if (stage_name.contains('CentOS 8.3.2011')) {
result['target'] = 'centos8.3'
result['distro_version'] = cachedCommitPragma('EL8.3-version', '8.3')
new_ci_target = cachedCommitPragma('EL8.3-target', result['target'])
} else if (stage_name.contains('EL 8.4')) {
result['target'] = 'el8.4'
result['distro_version'] = cachedCommitPragma('EL8.4-version', '8.4')
new_ci_target = cachedCommitPragma('EL8.4-target', result['target'])
} else if (stage_name.contains('CentOS 8')) {
result['target'] = 'centos8'
result['distro_version'] = cachedCommitPragma('EL8-version', '8')
new_ci_target = cachedCommitPragma('EL8-target', result['target'])
} else if (stage_name.contains('EL 8')) {
result['target'] = 'el8'
result['distro_version'] = cachedCommitPragma('EL8-version',
distroVersion(result['target']))
new_ci_target = cachedCommitPragma('EL8-target', result['target'])
} else if (stage_name.contains('Leap 15.3')) {
result['target'] = 'leap15'
result['distro_version'] = cachedCommitPragma('LEAP15-version', '15.3')
new_ci_target = cachedCommitPragma('LEAP15-target', result['target'])
} else if (stage_name.contains('Leap 15.4')) {
result['target'] = 'leap15'
result['distro_version'] = cachedCommitPragma('LEAP15-version', '15.4')
new_ci_target = cachedCommitPragma('LEAP15-target', result['target'])
} else if (stage_name.contains('Leap 15')) {
result['target'] = 'leap15'
result['distro_version'] = cachedCommitPragma('LEAP15-version',
distroVersion(result['target']))
new_ci_target = cachedCommitPragma('LEAP15-target', result['target'])
} else if (stage_name.contains('Ubuntu 18')) {
result['target'] = 'ubuntu18.04'
result['distro_version'] = cachedCommitPragma('UBUNTU18-version', '18.04')
new_ci_target = cachedCommitPragma('UBUNTU18-target', result['target'])
} else if (stage_name.contains('Ubuntu 20.04')) {
result['target'] = 'ubuntu20.04'
result['distro_version'] = cachedCommitPragma('UBUNTU20-version', '20.04')
new_ci_target = cachedCommitPragma('UBUNTU20-target', result['target'])
} else if (stage_name.contains('Ubuntu 20')) {
// TODO: below needs to change to ubuntu20 at some point in the future when
// all other pipelines are ready for it
result['target'] = 'ubuntu20.04'
result['distro_version'] = cachedCommitPragma('UBUNTU20-version',
distroVersion(result['target']))
new_ci_target = cachedCommitPragma('UBUNTU20-target', result['target'])
} else {
// also for: if (stage_name.contains('CentOS 7')) {
echo "Could not determine target in ${stage_name}, defaulting to EL7"
result['target'] = 'centos7'
result['distro_version'] = cachedCommitPragma('EL7-version', '7')
new_ci_target = cachedCommitPragma('EL7-target', result['target'])
}
}
new_ci_target = paramsValue('CI_' +
result['target'].toString().toUpperCase() +
'_TARGET', new_ci_target)
if (new_ci_target) {
result['ci_target'] = new_ci_target
} else {
result['ci_target'] = result['target']
}
if (result['ci_target'].startsWith('el') ||
result['ci_target'].startsWith('centos') ||
result['ci_target'].startsWith('rocky') ||
result['ci_target'].startsWith('rhel') ||
result['ci_target'].startsWith('almalinux')) {
result['java_pkg'] = 'java-1.8.0-openjdk'
} else if (result['ci_target'].startsWith('ubuntu')) {
result['java_pkg'] = 'openjdk-8-jdk'
} else if (result['ci_target'].startsWith('leap')) {
result['java_pkg'] = 'java-1_8_0-openjdk'
} else {
error 'Java package not known for ' + result['ci_target']
}
result['compiler'] = 'gcc'
if (config['COMPILER']) {
result['compiler'] = config['COMPILER']
} else if (env.COMPILER) {
result['compiler'] = env.COMPILER
} else if (stage_name.contains('Clang')) {
result['compiler'] = 'clang'
} else if (stage_name.contains('Intel-C')) {
result['compiler'] = 'icc'
} else if (stage_name.contains('Bullseye')) {
result['compiler'] = 'covc'
}
if (config['build_type']) {
result['build_type'] = config['build_type']
} else if (config['BUILD_TYPE']) {
result['build_type'] = config['BUILD_TYPE']
} else if (stage_name.contains('release')) {
result['build_type'] = 'release'
} else if (stage_name.contains('debug')) {
result['build_type'] = 'debug'
}
if (config['target_prefix']) {
result['target_prefix'] == config['target_prefix']
} else if (stage_name.contains('TARGET_PREFIX')) {
result['target_prefix'] = 'install/opt'
}
if (stage_name.contains('Coverity')) {
result['test'] = 'coverity'
}
if (config['log_to_file']) {
result['log_to_file'] = config['log_to_file']
} else {
result['log_to_file'] = result['target'] + '-' +
result['compiler']
if (result['build_type']) {
result['log_to_file'] += '-' + result['build_type']
}
result['log_to_file'] += '-build.log'
}
// Unless otherwise specified, all tests will only use one node.
result['node_count'] = 1
String cluster_size = ''
String ftest_arg_nvme = ''
String ftest_arg_repeat = ''
String ftest_arg_provider = ''
if (stage_name.contains('Functional')) {
result['test'] = 'Functional'
result['node_count'] = 9
cluster_size = '-hw'
result['pragma_suffix'] = '-vm'
result['always_script'] = config.get('always_script',
'ci/functional/job_cleanup.sh')
if (stage_name.contains('Hardware')) {
cluster_size = 'hw,large'
result['pragma_suffix'] = '-hw-large'
ftest_arg_nvme = get_default_nvme()
if (stage_name.contains('Small')) {
result['node_count'] = 3
cluster_size = 'hw,small'
result['pragma_suffix'] = '-hw-small'
} else if (stage_name.contains('Medium')) {
result['node_count'] = 5
cluster_size = 'hw,medium,-provider'
result['pragma_suffix'] = '-hw-medium'
if (stage_name.contains('Provider')) {
cluster_size = 'hw,medium,provider'
if (stage_name.contains('Verbs')) {
result['pragma_suffix'] += '-verbs-provider'
ftest_arg_provider = 'ofi+verbs'
}
else if (stage_name.contains('UCX')) {
result['pragma_suffix'] += '-ucx-provider'
ftest_arg_provider = 'ucx+dc_x'
}
else if (stage_name.contains('TCP')) {
result['pragma_suffix'] += '-tcp-provider'
ftest_arg_provider = 'ofi+tcp'
}
}
} else if (stage_name.contains('Hardware 24')) {
result['node_count'] = 24
cluster_size = 'hw,24'
result['pragma_suffix'] = '-hw-24'
}
}
if (stage_name.contains('with Valgrind')) {
result['pragma_suffix'] = '-valgrind'
result['with_valgrind'] = 'memcheck'
config['test_tag'] = 'memcheck'
}
// Determine which tests tags to use
// config Build Param Commit Pragma
// Started by 'test_tag' (TestTag) (Test-tag) Default Use
// -------------- ---------- ---------- ------------- ---------- ----------
// PR | Upstream None None None defaul_tag defaul_tag
// PR | Upstream None None commit_tag defaul_tag commit_tag
// PR | Upstream None param_tag None defaul_tag param_tag
// PR | Upstream None param_tag commit_tag defaul_tag commit_tag
// Manual | Timer None None <any> defaul_tag defaul_tag
// Manual | Timer None param_tag <any> defaul_tag param_tag
// <any> config_tag <any> <any> <any> config_tag
//
String tag = config['test_tag']
if (!tag) {
if (startedByUser() || startedByTimer()) {
// Get tags from the build parameters
tag = get_build_params_tags()
if (!tag) {
// Default to the pr tag for any other build stage
tag = 'pr'
}
}
else {
// Get tags from the commit pragmas
tag = get_commit_pragma_tags(result['pragma_suffix'])
if (!tag) {
// Get tags from the build parameters
tag = get_build_params_tags()
if (!tag) {
if (startedByUpstream()) {
// Default to run simple tests for dowstream builds
tag = 'always_passes'
}
else {
// Default to the pr tag for any other build stage
tag = 'pr'
}
}
}
}
}
if (tag) {
tag = tag.trim()
}
// Get the ftest --nvme argument from either the build parameters or commit pragmas
ftest_arg_nvme = params.TestNvme ?: cachedCommitPragma(
'Test-nvme' + result['pragma_suffix'], cachedCommitPragma('Test-nvme', ftest_arg_nvme))
// Get the ftest --repeat argument from either the build parameters or commit pragmas
ftest_arg_repeat = params.TestRepeat ?: cachedCommitPragma(
'Test-repeat' + result['pragma_suffix'], cachedCommitPragma('Test-repeat', null))
// Get the ftest --provider argument from either the build parameters or commit pragmas if not
// already defined by the stage
if (!ftest_arg_provider) {
ftest_arg_provider = params.TestProvider ?: cachedCommitPragma(
'Test-provider' + result['pragma_suffix'], cachedCommitPragma('Test-provider', null))
}
// Assemble the ftest args
result['ftest_arg'] = ''
if (ftest_arg_nvme) {
result['ftest_arg'] += ' --nvme=' + ftest_arg_nvme
}
if (ftest_arg_repeat) {
result['ftest_arg'] += ' --repeat=' + ftest_arg_repeat
}
if (ftest_arg_provider) {
result['ftest_arg'] += ' --provider=' + ftest_arg_provider
}
if (result['ftest_tag']) {
result['ftest_tag'] = result['ftest_tag'].trim()
}
// Assemble the stage test tags - add the cluster size to each tag group
result['test_tag'] = ''
for (group in tag.split(' ')) {
result['test_tag'] += group + ',' + cluster_size + ' '
}
result['test_tag'] = result['test_tag'].trim()
// Determine any additional rpms needed for this stage
result['stage_rpms'] = ''
if (ftest_arg_provider && ftest_arg_provider.contains('ucx')) {
result['stage_rpms'] = 'mercury-ucx'
}
// if (stage_name.contains('Functional'))
} else if (stage_name.contains('Storage')) {
if (env.NODELIST) {
List node_list = env.NODELIST.split(',')
result['node_count'] = node_list.size()
}
} // else if (stage_name.contains('Storage'))
if (config['test']) {
result['test'] = config['test']
}
if (config['node_count']) {
result['node_count'] = config['node_count']
}
if (config['pragma_suffix']) {
result['pragma_suffix'] = config['pragma_suffix']
}
if (config['ftest_arg']) {
result['ftest_arg'] = config['ftest_arg']
}
if (stage_name.contains('NLT')) {
result['NLT'] = true
result['valgrind_pattern'] = config.get('valgrind_pattern',
'*memcheck.xml')
result['always_script'] = config.get('always_script',
'ci/unit/test_nlt_post.sh')
result['testResults'] = config.get('testResults', 'nlt-junit.xml')
result['with_valgrind'] = 'memcheck'
} else {
result['NLT'] = false
if (config['valgrind_pattern']) {
result['valgrind_pattern'] = config['valgrind_pattern']
}
}
if (stage_name.contains('Unit Test')) {
result['testResults'] = config.get('testResults', 'test_results/*.xml')
result['always_script'] = config.get('always_script',
'ci/unit/test_post_always.sh')
if (stage_name.contains('memcheck')) {
result['with_valgrind'] = 'memcheck'
}
}
return result
}