From b3c4491262533198d80096e4d2b9483b8b575ccc Mon Sep 17 00:00:00 2001 From: Eugen Cusmaunsa Date: Wed, 8 Dec 2021 19:05:58 +0000 Subject: [PATCH 1/3] Fix st2-self-check script reporting success on failed runs When the test run contains several nested workflows the script assumes it's succeeded if at least single sub-workflow was successful. Instead of that, the check should refer to the parent workflow "status: succeeded". --- st2common/bin/st2-self-check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st2common/bin/st2-self-check b/st2common/bin/st2-self-check index b7c1916bba..bbc4fba96e 100755 --- a/st2common/bin/st2-self-check +++ b/st2common/bin/st2-self-check @@ -140,7 +140,7 @@ do START_TS=$(date +%s) OUTPUT=$(st2 run ${TEST} protocol=${PROTOCOL} token=${ST2_AUTH_TOKEN}) - echo ${OUTPUT} | grep "status" | grep -q "succeeded" + echo ${OUTPUT} | grep -q "status: succeeded" EXIT_CODE=$? END_TS=$(date +%s) DURATION=$(expr ${END_TS} - ${START_TS}) @@ -159,7 +159,7 @@ if [ ${RUN_ORQUESTA_TESTS} = "true" ]; then START_TS=$(date +%s) OUTPUT=$(st2 run examples.orquesta-examples) - echo ${OUTPUT} | grep "status" | grep -q "succeeded" + echo ${OUTPUT} | grep -q "status: succeeded" EXIT_CODE=$? END_TS=$(date +%s) DURATION=$(expr ${END_TS} - ${START_TS}) From 8e09d0e02f76b827bba2489db89c2702741d4e52 Mon Sep 17 00:00:00 2001 From: Eugen Cusmaunsa Date: Wed, 8 Dec 2021 20:28:21 +0000 Subject: [PATCH 2/3] Add the changelog for #5487 --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 10f8ce9e85..5f55b0fd31 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,8 @@ Fixed Contributed by @khushboobhatia01 +* Fix ``st2-self-check`` script reporting falsey success when the nested workflows runs failed. #5487 + 3.6.0 - October 29, 2021 ------------------------ From 69ba1d4ce81029d88fb45ed1b6682fdaee000470 Mon Sep 17 00:00:00 2001 From: Eugen Cusmaunsa Date: Thu, 9 Dec 2021 21:04:37 +0000 Subject: [PATCH 3/3] Make sure the newlines are preserved in the output from the command substitution ``` echo ${OUTPUT} ``` results in entire output being on a single line, which is why it breaks the grep rule at the first place. Fixes #5487 when st2-self-check script reported success on failed runs. --- st2common/bin/st2-self-check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/st2common/bin/st2-self-check b/st2common/bin/st2-self-check index bbc4fba96e..d7d1a0b85a 100755 --- a/st2common/bin/st2-self-check +++ b/st2common/bin/st2-self-check @@ -140,7 +140,7 @@ do START_TS=$(date +%s) OUTPUT=$(st2 run ${TEST} protocol=${PROTOCOL} token=${ST2_AUTH_TOKEN}) - echo ${OUTPUT} | grep -q "status: succeeded" + echo "${OUTPUT}" | grep "status" | grep -q "succeeded" EXIT_CODE=$? END_TS=$(date +%s) DURATION=$(expr ${END_TS} - ${START_TS}) @@ -159,7 +159,7 @@ if [ ${RUN_ORQUESTA_TESTS} = "true" ]; then START_TS=$(date +%s) OUTPUT=$(st2 run examples.orquesta-examples) - echo ${OUTPUT} | grep -q "status: succeeded" + echo "${OUTPUT}" | grep "status" | grep -q "succeeded" EXIT_CODE=$? END_TS=$(date +%s) DURATION=$(expr ${END_TS} - ${START_TS})