Skip to content

Commit 999b9e1

Browse files
authored
Merge pull request #529 from WASdev/523-clusterRetainE2EFail
523: only retain ocp cluster when e2e test fail
2 parents ac5300f + 83e0cfa commit 999b9e1

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

scripts/acceptance-test.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,24 @@ done
103103
echo "****** Test results"
104104
exit_code=0
105105
for test in "${!E2E_TESTS[@]}"; do
106+
if [[ "${test}" == "kind-e2e-run" ]]; then
107+
TEST_ID=$KIND_E2E_TEST;
108+
elif [[ "${test}" == "ocp-e2e-run-X" ]]; then
109+
TEST_ID=$OCP_E2E_X_TEST;
110+
elif [[ "${test}" == "ocp-e2e-run-P" ]]; then
111+
TEST_ID=$OCP_E2E_P_TEST;
112+
elif [[ "${test}" == "ocp-e2e-run-Z" ]]; then
113+
TEST_ID=$OCP_E2E_Z_TEST;
114+
else
115+
TEST_ID=$UNKNOWN_E2E_TEST
116+
fi
117+
106118
status="$(docker ps --all --no-trunc --filter name="^/${test}$" --format='{{.Status}}')"
107119
if echo "${status}" | grep -q "Exited (0)"; then
108120
echo "[PASSED] ${test}"
109121
else
110122
echo "[FAILED] ${test}: ${status}"
111-
exit_code=1
123+
exit_code=$((exit_code + $TEST_ID))
112124
fi
113125
done
114126
exit ${exit_code}

scripts/pipeline/runTest.sh

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export FYRE_KEY=$(get_env fyre-key)
4848
export FYRE_PASS=$(get_env fyre-pass)
4949
export FYRE_PRODUCT_GROUP_ID=$(get_env fyre-product-group-id)
5050

51+
# acceptance-test.sh return values
52+
export KIND_E2E_TEST=1
53+
export OCP_E2E_X_TEST=2
54+
export OCP_E2E_P_TEST=4
55+
export OCP_E2E_Z_TEST=8
56+
export UNKNOWN_E2E_TEST=256
57+
5158
echo "${PIPELINE_PASSWORD}" | docker login "${PIPELINE_REGISTRY}" -u "${PIPELINE_USERNAME}" --password-stdin
5259
if [[ ! -z "$RELEASE_ACCEPTANCE_TEST" && "$RELEASE_ACCEPTANCE_TEST" != "false" && "$RELEASE_ACCEPTANCE_TEST" != "no" ]]; then
5360
RELEASE_TARGET=$(curl --silent "https://api.github.com/repos/WASdev/websphere-liberty-operator/releases/latest" | jq -r .tag_name)
@@ -71,11 +78,32 @@ pwd
7178

7279
scripts/acceptance-test.sh
7380
rc=$?
81+
keep_cluster=0
82+
83+
if (( (rc & OCP_E2E_X_TEST) >0 )) ||
84+
(( (rc & OCP_E2E_P_TEST) >0 )) ||
85+
(( (rc & OCP_E2E_Z_TEST) >0 )) ||
86+
(( (rc & UNKNOWN_E2E_TEST) >0 )); then
87+
keep_cluster=1
88+
fi
7489

7590
echo "switching back to ebc-gateway-http directory"
7691
cd scripts/pipeline/ebc-gateway-http
7792

78-
if [[ "$rc" == 0 ]]; then
93+
if [[ "$keep_cluster" == 0 ]]; then
94+
if (( (rc & KIND_E2E_TEST) >0 )); then
95+
slack_users=$(get_env slack_users)
96+
echo "slack_users=$slack_users"
97+
eval "arr=($slack_users)"
98+
for user in "${arr[@]}"; do
99+
echo "user=$user"
100+
curl -X POST -H 'Content-type: application/json' --data '{"text":"<'$user'> kind accceptance test failure see below "}' $(get_env slack_web_hook_url)
101+
echo " "
102+
done
103+
pipeline_url="https://cloud.ibm.com/devops/pipelines/tekton/${PIPELINE_ID}/runs/${PIPELINE_RUN_ID}?env_id=ibm:yp:us-south"
104+
curl -X POST -H 'Content-type: application/json' --data '{"text":"Your kind acceptance test failed."}' $(get_env slack_web_hook_url) </dev/null
105+
curl -X POST -H 'Content-type: application/json' --data '{"text":"Failing pipeline: '$pipeline_url'"}' $(get_env slack_web_hook_url) </dev/null
106+
fi
79107
./ebc_complete.sh
80108
else
81109
hours=$(get_env ebc_autocomplete_hours "6")
@@ -88,9 +116,9 @@ else
88116
echo "slack_users=$slack_users"
89117
eval "arr=($slack_users)"
90118
for user in "${arr[@]}"; do
91-
echo "user=$user"
92-
curl -X POST -H 'Content-type: application/json' --data '{"text":"<'$user'> accceptance test failure see below "}' $(get_env slack_web_hook_url)
93-
echo " "
119+
echo "user=$user"
120+
curl -X POST -H 'Content-type: application/json' --data '{"text":"<'$user'> accceptance test failure see below "}' $(get_env slack_web_hook_url)
121+
echo " "
94122
done
95123
pipeline_url="https://cloud.ibm.com/devops/pipelines/tekton/${PIPELINE_ID}/runs/${PIPELINE_RUN_ID}?env_id=ibm:yp:us-south"
96124
curl -X POST -H 'Content-type: application/json' --data '{"text":"Your acceptance test failed."}' $(get_env slack_web_hook_url) </dev/null

0 commit comments

Comments
 (0)