From 197e9263f1f41724198893e924a5bfe9f3f00239 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Tue, 26 Feb 2019 16:10:13 +0100 Subject: [PATCH] Execute the test cases in parallel. --- consumer-test/integrationTestController.sh | 54 ++++++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/consumer-test/integrationTestController.sh b/consumer-test/integrationTestController.sh index 82b25addb..6b2415640 100755 --- a/consumer-test/integrationTestController.sh +++ b/consumer-test/integrationTestController.sh @@ -3,13 +3,61 @@ WORKSPACES_ROOT=workspaces [ -e "${WORKSPACES_ROOT}" ] && rm -rf ${WORKSPACES_ROOT} -for f in `find . -type f -depth 2 -name '*.yml'` +TEST_CASES=`find . -type f -depth 2 -name '*.yml'` + +i=0 +for f in ${TEST_CASES} do testCase=`basename ${f%.*}` area=`dirname ${f#*/}` + echo "[INFO] Running test case \"${testCase}\" in area \"${area}\"." TEST_CASE_ROOT="${WORKSPACES_ROOT}/${area}/${testCase}" [ -e "${TEST_CASE_ROOT}" ] && rm -rf "${TEST_CASE_ROOT}" mkdir -p "${TEST_CASE_ROOT}" - source runTest.sh "${area}" "${testCase}" "${TEST_CASE_ROOT}" &> "${TEST_CASE_ROOT}/log.txt" - + source runTest.sh "${area}" "${testCase}" "${TEST_CASE_ROOT}" &> "${TEST_CASE_ROOT}/log.txt" & + pid=$! + processes[$i]="${testCase}:${pid}" + echo "[INFO] Test case \"${testCase}\" in area \"${area}\" launched. (PID: \"${pid}\")." + let i=i+1 done + +# +# wait for the test cases and cat the log +for p in "${processes[@]}" +do + testCase=${p%:*} + processId=${p#*:} + echo "[INFO] Waiting for test case \"${testCase}\" (PID: \"${processId}\")." + wait ${processId} + echo "[INFO] Test case \"${testCase}\" finished (PID: \"${processId}\")." + echo "[INFO] Logs for test case \"${testCase}\"." + cat "${TEST_CASE_ROOT}/log.txt" + echo "[INFO] Logs for test case \"${testCase}\"." +done + +# +# list test case status +echo "[INFO] Build status:" +failure="false" +for p in "${processes[@]}" +do + status="UNDEFINED" + testCase=${p%:*} + if [ -f "${TEST_CASE_ROOT}/SUCCESS" ] + then + status="SUCCESS" + else + status="FAILURE" + failure="true" + fi + printf "[INFO] %-30s: %s\n" "${testCase}" ${status} +done + +if [ "${failure}" == "true" ] +then + echo "[WARNING] There are test failures. Check earlier log for details." + exit 1 +fi + +echo "[INFO] Integration tests succeeded." +exit 0