mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
Execute the test cases in parallel.
This commit is contained in:
@@ -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] <START> Logs for test case \"${testCase}\"."
|
||||
cat "${TEST_CASE_ROOT}/log.txt"
|
||||
echo "[INFO] <END> 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
|
||||
|
||||
Reference in New Issue
Block a user