Skip to content

Commit c879834

Browse files
ROX-11715: Error better when deployment fails (stackrox#2477)
1 parent 2c2cbb4 commit c879834

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

.openshift-ci/post_tests.py

+10
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ def run(self, test_output_dirs=None):
290290
self.fixup_artifacts_content_type()
291291
self.make_artifacts_help()
292292
self.handle_run_failure()
293+
self.handle_e2e_progress_failures()
293294

294295
def fixup_artifacts_content_type(self):
295296
self.run_with_best_effort(
@@ -302,3 +303,12 @@ def make_artifacts_help(self):
302303
["scripts/ci/store-artifacts.sh", "make_artifacts_help"],
303304
timeout=PostTestsConstants.FIXUP_TIMEOUT,
304305
)
306+
307+
def handle_e2e_progress_failures(self):
308+
self.run_with_best_effort(
309+
[
310+
"tests/e2e/lib.sh",
311+
"handle_e2e_progress_failures",
312+
],
313+
timeout=PostTestsConstants.CHECK_TIMEOUT,
314+
)

qa-tests-backend/scripts/run-part-2.sh

+6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44

55
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)"
66
source "$ROOT/scripts/ci/lib.sh"
7+
source "$ROOT/tests/e2e/lib.sh"
78

89
set -euo pipefail
910

1011
run_tests_part_2() {
1112
info "QA Automation Platform Part 2"
1213

14+
if [[ ! -f "${STATE_DEPLOYED}" ]]; then
15+
info "Skipping part 2 tests due to earlier failure"
16+
exit 0
17+
fi
18+
1319
export CLUSTER="${ORCHESTRATOR_FLAVOR^^}"
1420

1521
rm -f FAIL

scripts/ci/lib.sh

+23
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,29 @@ send_slack_notice_for_failures_on_merge() {
12191219
curl -XPOST -d @- -H 'Content-Type: application/json' "$webhook_url"
12201220
}
12211221

1222+
save_junit_failure() {
1223+
if [[ "$#" -ne 3 ]]; then
1224+
die "missing args. usage: save_junit_failure <class> <description> <details>"
1225+
fi
1226+
1227+
if [[ -z "${ARTIFACT_DIR}" ]]; then
1228+
info "Warning: save_junit_failure() requires an ARTIFACT_DIR"
1229+
return
1230+
fi
1231+
1232+
local class="$1"
1233+
local description="$2"
1234+
local details="$3"
1235+
1236+
cat << EOF > "${ARTIFACT_DIR}/junit-${class}.xml"
1237+
<testsuite name="${class}" tests="1" skipped="0" failures="1" errors="0">
1238+
<testcase name="${description}" classname="${class}">
1239+
<failure>${details}</failure>
1240+
</testcase>
1241+
</testsuite>
1242+
EOF
1243+
}
1244+
12221245
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
12231246
if [[ "$#" -lt 1 ]]; then
12241247
die "When invoked at the command line a method is required."

tests/e2e/lib.sh

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ set -euo pipefail
77

88
TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd)"
99

10+
# State
11+
STATE_DEPLOYED="/tmp/state_deployed"
12+
1013
source "$TEST_ROOT/scripts/lib.sh"
1114
source "$TEST_ROOT/scripts/ci/lib.sh"
1215

@@ -24,6 +27,8 @@ deploy_stackrox() {
2427
kubectl -n stackrox delete pod -l app=collector --grace-period=0
2528

2629
sensor_wait
30+
31+
touch "${STATE_DEPLOYED}"
2732
}
2833

2934
# export_test_environment() - Persist environment variables for the remainder of
@@ -400,6 +405,14 @@ db_backup_and_restore_test() {
400405
[[ ! -f DB_TEST_FAIL ]] || die "The DB test failed"
401406
}
402407

408+
handle_e2e_progress_failures() {
409+
info "Checking for deployment failure"
410+
411+
if [[ ! -f "${STATE_DEPLOYED}" ]]; then
412+
save_junit_failure "Stackrox_Deployment" "Could not deploy StackRox" "Check the build log" || true
413+
fi
414+
}
415+
403416
if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
404417
if [[ "$#" -lt 1 ]]; then
405418
usage

0 commit comments

Comments
 (0)