From 03ace7a5bc6decea74b644b3bad1eacedf6e6de9 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Fri, 13 Oct 2017 12:52:58 +0100 Subject: [PATCH] Only build ARA report when test fails In order to reduce the quantity of unnecessary log content being kept in OpenStack-Infra we only generate the ARA report when the test result is a failure. The ARA sqlite database is still available for self generation if desired for successful tests. Change-Id: Ic0415ab79a1d0574d5b61a552bc20fc1f9c4e9d3 --- scripts/scripts-library.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 96d37cbee4..fb6f27933e 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -123,6 +123,11 @@ function exit_fail { } function gate_job_exit_tasks { + # This environment variable captures the exit code + # which was present when the trap was initiated. + # This would be the success/failure of the test. + export TEST_EXIT_CODE=$? + # If this is a gate node from OpenStack-Infra Store all logs into the # execution directory after gate run. if [ "$GATE_EXIT_LOG_COPY" == true ]; then @@ -137,7 +142,17 @@ function gate_job_exit_tasks { # Generate the ARA report if enabled if [ "$GATE_EXIT_RUN_ARA" == true ]; then - /opt/ansible-runtime/bin/ara generate html "${GATE_LOG_DIR}/ara" || true + # In order to reduce the quantity of unnecessary log content + # being kept in OpenStack-Infra we only generate the ARA report + # when the test result is a failure. + if [[ "${TEST_EXIT_CODE}" != "0" ]]; then + echo "Generating ARA report due to non-zero exit code (${TEST_EXIT_CODE})." + /opt/ansible-runtime/bin/ara generate html "${GATE_LOG_DIR}/ara" || true + else + echo "Not generating ARA report due to test pass." + fi + # We still want the subunit report though, as that reflects + # success/failure in OpenStack Health /opt/ansible-runtime/bin/ara generate subunit "${GATE_LOG_DIR}/ara/testrepository.subunit" || true fi # Compress the files gathered so that they do not take up too much space.