Skip to content

Commit efbd410

Browse files
authored
DAOS-17537 test: Fix functional hw param behavior (#466)
Fix using pipeline parameters when determining if a Functional Hardware stage should be run. Signed-off-by: Phil Henderson <phillip.henderson@hpe.com>
1 parent df95fda commit efbd410

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

vars/getFunctionalTestStage.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ Map call(Map kwargs = [:]) {
5858
'run_if_pr': run_if_pr,
5959
'run_if_landing': run_if_landing]
6060
if (skipFunctionalTestStage(skip_kwargs)) {
61-
echo "[${name}] Stage skipped by skipFunctionalTestStage()"
61+
println("[${name}] Stage skipped by skipFunctionalTestStage()")
6262
Utils.markStageSkippedForConditional("${name}")
6363
} else {
6464
node(cachedCommitPragma("Test-label${pragma_suffix}", label)) {
6565
// Ensure access to any branch provisioning scripts exist
66-
echo "[${name}] Check out '${base_branch}' from version control"
66+
println("[${name}] Check out '${base_branch}' from version control")
6767
if (base_branch) {
6868
checkoutScm(
6969
url: 'https://github.com/daos-stack/daos.git',
@@ -75,7 +75,7 @@ Map call(Map kwargs = [:]) {
7575
}
7676

7777
try {
78-
echo "[${name}] Running functionalTest() on ${label} with tags=${tags}"
78+
println("[${name}] Running functionalTest() on ${label} with tags=${tags}")
7979
jobStatusUpdate(
8080
job_status,
8181
name,
@@ -91,13 +91,13 @@ Map call(Map kwargs = [:]) {
9191
provider: provider)['ftest_arg'],
9292
test_function: 'runTestFunctionalV2'))
9393
} finally {
94-
echo "[${name}] Running functionalTestPostV2()"
94+
println("[${name}] Running functionalTestPostV2()")
9595
functionalTestPostV2()
9696
jobStatusUpdate(job_status, name)
9797
}
9898
}
9999
}
100-
echo "[${name}] Finished with ${job_status}"
100+
println("[${name}] Finished with ${job_status}")
101101
}
102102
}
103103
}

vars/skipFunctionalTestStage.groovy

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,64 +25,63 @@ Map call(Map kwargs = [:]) {
2525
Boolean run_if_pr = kwargs['run_if_pr'] ?: false
2626
String target_branch = env.CHANGE_TARGET ? env.CHANGE_TARGET : env.BRANCH_NAME
2727

28-
echo "[${env.STAGE_NAME}] Running skipFunctionalTestStage: " +
29-
"tags=${tags}, pragma_suffix=${pragma_suffix}, size=${size}, distro=${distro}, " +
30-
"build_param=${build_param}, build_param_value=${build_param_value}, " +
31-
"run_if_landing=${run_if_landing}, run_if_pr=${run_if_pr}, " +
32-
"changeRequest()=${changeRequest()}, startedByUser()=${startedByUser()}, " +
33-
"startedByTimer()=${startedByTimer()}, " +
34-
"startedByUpstream()=${startedByUpstream()}, target_branch=${target_branch}"
28+
println("[${env.STAGE_NAME}] Running skipFunctionalTestStage: " +
29+
"tags=${tags}, pragma_suffix=${pragma_suffix}, size=${size}, distro=${distro}, " +
30+
"build_param=${build_param}, build_param_value=${build_param_value}, " +
31+
"run_if_landing=${run_if_landing}, run_if_pr=${run_if_pr}, " +
32+
"startedByUser()=${startedByUser()}, startedByTimer()=${startedByTimer()}, " +
33+
"startedByUpstream()=${startedByUpstream()}, target_branch=${target_branch}")
3534

3635
// Regardless of how the stage has been started always skip a stage that has either already
3736
// passed or does not contain any tests match the tags.
3837
if (stageAlreadyPassed()) {
39-
echo "[${env.STAGE_NAME}] Skipping the stage due to all tests passing in the previous build"
38+
println("[${env.STAGE_NAME}] Skipping the stage due to all tests passing in the previous build")
4039
return true
4140
}
4241
if (!testsInStage(tags)) {
43-
echo "[${env.STAGE_NAME}] Skipping the stage due to detecting no tests matching the '${tags}' tags"
42+
println("[${env.STAGE_NAME}] Skipping the stage due to detecting no tests matching the '${tags}' tags")
4443
return true
4544
}
4645

4746
// If the stage has been started by the user, e.g. Build with Parameters, or a timer, or an
4847
// upstream build then use the stage's build parameter (check box) to determine if the stage
4948
// should be run or skipped.
50-
if (!changeRequest() && (build_param_value == 'false')) {
51-
echo "[${env.STAGE_NAME}] Skipping the stage in user started build due to ${build_param} param"
52-
return true
53-
}
54-
if (!changeRequest() && (build_param_value == 'true')) {
55-
echo "[${env.STAGE_NAME}] Running the stage in user started build due to ${build_param} param"
56-
return false
57-
}
5849
if (startedByTimer() && (build_param_value == 'false')) {
59-
echo "[${env.STAGE_NAME}] Skipping the stage in timer started build due to ${build_param} param"
50+
println("[${env.STAGE_NAME}] Skipping the stage in timer started build due to ${build_param} param")
6051
return true
6152
}
6253
if (startedByTimer() && (build_param_value == 'true')) {
63-
echo "[${env.STAGE_NAME}] Running the stage in timer started build due to ${build_param} param"
54+
println("[${env.STAGE_NAME}] Running the stage in timer started build due to ${build_param} param")
6455
return false
6556
}
6657
if (startedByUpstream() && (build_param_value == 'false')) {
67-
echo "[${env.STAGE_NAME}] Skipping the stage in an upstream build due to ${build_param} param"
58+
println("[${env.STAGE_NAME}] Skipping the stage in an upstream build due to ${build_param} param")
6859
return true
6960
}
7061
if (startedByUpstream() && (build_param_value == 'true')) {
71-
echo "[${env.STAGE_NAME}] Running the stage in an upstream build due to ${build_param} param"
62+
println("[${env.STAGE_NAME}] Running the stage in an upstream build due to ${build_param} param")
63+
return false
64+
}
65+
if (startedByUser() && (build_param_value == 'false')) {
66+
println("[${env.STAGE_NAME}] Skipping the stage in user started build due to ${build_param} param")
67+
return true
68+
}
69+
if (startedByUser() && (build_param_value == 'true')) {
70+
println("[${env.STAGE_NAME}] Running the stage in user started build due to ${build_param} param")
7271
return false
7372
}
7473

7574
if (env.UNIT_TEST && env.UNIT_TEST == 'true') {
76-
echo "[${env.STAGE_NAME}] Ignoring the landing build check due to Unit Testing"
75+
println("[${env.STAGE_NAME}] Ignoring the landing build check due to Unit Testing")
7776
} else {
7877
// If the stage is being run in a landing build use the 'run_if_landing' input to determine
7978
// whether the stage should be run or skipped.
8079
if (startedByLanding() && !run_if_landing) {
81-
echo "[${env.STAGE_NAME}] Skipping the stage in a landing build on master/release branch"
80+
println("[${env.STAGE_NAME}] Skipping the stage in a landing build on master/release branch")
8281
return true
8382
}
8483
if (startedByLanding() && run_if_landing) {
85-
echo "[${env.STAGE_NAME}] Running the stage in a landing build on master/release branch"
84+
println("[${env.STAGE_NAME}] Running the stage in a landing build on master/release branch")
8685
return false
8786
}
8887
}
@@ -106,10 +105,10 @@ Map call(Map kwargs = [:]) {
106105
for (commit_pragma in commit_pragmas + skip_pragmas) {
107106
String value = (commit_pragma.startsWith('Skip-') || (commit_pragma == 'Run-GHA')) ? 'true' : 'false'
108107
if (env.UNIT_TEST && env.UNIT_TEST == 'true') {
109-
echo "[${env.STAGE_NAME}] Checking if stage should be skipped with ${commit_pragma} == ${value}"
108+
println("[${env.STAGE_NAME}] Checking if stage should be skipped with ${commit_pragma} == ${value}")
110109
}
111110
if (cachedCommitPragma(commit_pragma, '').toLowerCase() == value) {
112-
echo "[${env.STAGE_NAME}] Skipping the stage in commit build due to '${commit_pragma}: ${value}' commit pragma"
111+
println("[${env.STAGE_NAME}] Skipping the stage in commit build due to '${commit_pragma}: ${value}' commit pragma")
113112
return true
114113
}
115114
}
@@ -119,44 +118,44 @@ Map call(Map kwargs = [:]) {
119118
for (commit_pragma in commit_pragmas) {
120119
String value = commit_pragma.startsWith('Run-') ? 'true' : 'false'
121120
if (env.UNIT_TEST && env.UNIT_TEST == 'true') {
122-
echo "[${env.STAGE_NAME}] Checking if stage should be run with ${commit_pragma} == ${value}"
121+
println("[${env.STAGE_NAME}] Checking if stage should be run with ${commit_pragma} == ${value}")
123122
}
124123
if (cachedCommitPragma(commit_pragma, '').toLowerCase() == value) {
125-
echo "[${env.STAGE_NAME}] Running the stage in commit build due to '${commit_pragma}: ${value}' commit pragma"
124+
println("[${env.STAGE_NAME}] Running the stage in commit build due to '${commit_pragma}: ${value}' commit pragma")
126125
return false
127126
}
128127
}
129128

130129
// If the stage is being run in a build started by a commit with only documentation changes,
131130
// skip the stage.
132131
if (docOnlyChange(target_branch) && prRepos(distro) == '') {
133-
echo "[${env.STAGE_NAME}] Skipping the stage in commit build due to document only file changes"
132+
println("[${env.STAGE_NAME}] Skipping the stage in commit build due to document only file changes")
134133
return true
135134
}
136135

137136
// If the stage is being run in a build started by a commit, skip the build if
138137
// DAOS_STACK_CI_HARDWARE_SKIP is set.
139138
if (env.DAOS_STACK_CI_HARDWARE_SKIP == 'true' ) {
140-
echo "[${env.STAGE_NAME}] Skipping the stage in commit build due to DAOS_STACK_CI_HARDWARE_SKIP parameter"
139+
println("[${env.STAGE_NAME}] Skipping the stage in commit build due to DAOS_STACK_CI_HARDWARE_SKIP parameter")
141140
return true
142141
}
143142

144143
// If the stage is being run in a PR build started by a commit, skip the stage if 'run_if_pr' is
145144
// not set.
146145
/* groovylint-disable-next-line UnnecessaryGetter */
147146
if (isPr() && !run_if_pr) {
148-
echo "[${env.STAGE_NAME}] Skipping the stage in commit PR build (override with '${commit_pragmas[0]}: false')"
147+
println("[${env.STAGE_NAME}] Skipping the stage in commit PR build (override with '${commit_pragmas[0]}: false')")
149148
return true
150149
}
151150

152151
// If the stage is being run in a build started by a commit skip, finally use the stage's
153152
// build parameter to determine if the stage should be skipped.
154153
if (build_param_value == 'false') {
155-
echo "[${env.STAGE_NAME}] Skipping the stage in commit build due to ${build_param} param"
154+
println("[${env.STAGE_NAME}] Skipping the stage in commit build due to ${build_param} param")
156155
return true
157156
}
158157

159158
// Otherwise run the stage
160-
echo "[${env.STAGE_NAME}] Running the stage in a commit build"
159+
println("[${env.STAGE_NAME}] Running the stage in a commit build")
161160
return false
162161
}

0 commit comments

Comments
 (0)