diff --git a/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh b/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh index 6146dab871e..3a18d4df286 100644 --- a/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh +++ b/hadoop-ozone/dist/src/main/compose/ozone-mr/test.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -15,29 +16,22 @@ # limitations under the License. SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd ) ALL_RESULT_DIR="$SCRIPT_DIR/result" +mkdir -p "$ALL_RESULT_DIR" +rm "$ALL_RESULT_DIR/*" || true source "$SCRIPT_DIR/../testlib.sh" tests=$(find_tests) +cd "$SCRIPT_DIR" RESULT=0 # shellcheck disable=SC2044 for t in ${tests}; do d="$(dirname "${t}")" - echo "Executing test in ${d}" - #required to read the .env file from the right location - cd "${d}" || continue - ./test.sh - ret=$? - if [[ $ret -ne 0 ]]; then - RESULT=1 - echo "ERROR: Test execution of ${d} is FAILED!!!!" + if ! run_test_script "${d}"; then + RESULT=1 fi - cd "$SCRIPT_DIR" - RESULT_DIR="${d}/result" - TEST_DIR_NAME=$(basename ${d}) - rebot -N $TEST_DIR_NAME -o "$ALL_RESULT_DIR"/$TEST_DIR_NAME.xml "$RESULT_DIR"/"*.xml" - cp "$RESULT_DIR"/docker-*.log "$ALL_RESULT_DIR"/ - cp "$RESULT_DIR"/*.out* "$ALL_RESULT_DIR"/ || true + + copy_results "${d}" "${ALL_RESULT_DIR}" done diff --git a/hadoop-ozone/dist/src/main/compose/test-all.sh b/hadoop-ozone/dist/src/main/compose/test-all.sh index 1fdc0ffcbb8..45a3c52d52f 100755 --- a/hadoop-ozone/dist/src/main/compose/test-all.sh +++ b/hadoop-ozone/dist/src/main/compose/test-all.sh @@ -34,29 +34,18 @@ if [ "$OZONE_WITH_COVERAGE" ]; then fi tests=$(find_tests) +cd "$SCRIPT_DIR" RESULT=0 # shellcheck disable=SC2044 for t in ${tests}; do d="$(dirname "${t}")" - echo "Executing test in ${d}" - #required to read the .env file from the right location - cd "${d}" || continue - set +e - ./test.sh - ret=$? - set -e - if [[ $ret -ne 0 ]]; then - RESULT=1 - echo "ERROR: Test execution of ${d} is FAILED!!!!" + if ! run_test_script "${d}"; then + RESULT=1 fi - cd "$SCRIPT_DIR" - RESULT_DIR="${d}/result" - TEST_DIR_NAME=$(basename ${d}) - rebot --nostatusrc -N $TEST_DIR_NAME -o "$ALL_RESULT_DIR"/$TEST_DIR_NAME.xml "$RESULT_DIR"/"*.xml" - cp "$RESULT_DIR"/docker-*.log "$ALL_RESULT_DIR"/ - cp "$RESULT_DIR"/*.out* "$ALL_RESULT_DIR"/ || true + + copy_results "${d}" "${ALL_RESULT_DIR}" done rebot --nostatusrc -N acceptance -d "$ALL_RESULT_DIR" "$ALL_RESULT_DIR"/*.xml diff --git a/hadoop-ozone/dist/src/main/compose/testlib.sh b/hadoop-ozone/dist/src/main/compose/testlib.sh index 228572fe2c7..db449b90ad9 100755 --- a/hadoop-ozone/dist/src/main/compose/testlib.sh +++ b/hadoop-ozone/dist/src/main/compose/testlib.sh @@ -247,3 +247,39 @@ generate_report(){ exit 1 fi } + +## @description Copy results of a single test environment to the "all tests" dir. +copy_results() { + local test_dir="$1" + local all_result_dir="$2" + + local result_dir="${test_dir}/result" + local test_dir_name=$(basename ${test_dir}) + if [[ -n "$(find "${result_dir}" -name "*.xml")" ]]; then + rebot --nostatusrc -N "${test_dir_name}" -o "${all_result_dir}/${test_dir_name}.xml" "${result_dir}/*.xml" + fi + + cp "${result_dir}"/docker-*.log "${all_result_dir}"/ + if [[ -n "$(find "${result_dir}" -name "*.out")" ]]; then + cp "${result_dir}"/*.out* "${all_result_dir}"/ + fi +} + +run_test_script() { + local d="$1" + + echo "Executing test in ${d}" + + #required to read the .env file from the right location + cd "${d}" || return + + ret=0 + if ! ./test.sh; then + ret=1 + echo "ERROR: Test execution of ${d} is FAILED!!!!" + fi + + cd - > /dev/null + + return ${ret} +}