diff --git a/installability_runner.sh b/installability_runner.sh index d8a30b5..6c98bba 100644 --- a/installability_runner.sh +++ b/installability_runner.sh @@ -10,21 +10,35 @@ get_result () { echo "$result" } -highrc=0 +TESTRUN_ID="$(date +%H%M%S)" +mkdir -p "${LOGS_DIR:=mtps-logs}" + . /var/tmp/mini-tps/env -for method in "install" "update" "downgrade" "remove"; do - mtps-run-tests "$@" --test="$method"; - thisrc=$? - thisres="$(get_result $thisrc)" - echo "$method result: $thisres (status code: $thisrc)" - if [ "$thisrc" -gt "$highrc" ]; then - highrc="$thisrc" - fi -done -tmtresult="$(get_result $highrc)" + +if [[ -f SKIP_TEST ]]; then + # The SKIP_TEST file contains a reason why the prepare.sh ended unexpectedly. + # Copy it to a log file which can be parsed by generate-result-json + # (to show the reason in viewer.html) + cat SKIP_TEST + cp SKIP_TEST "${LOGS_DIR}/SKIP-${TESTRUN_ID}-install-package.log" + tmtresult="skip" +else + highrc=0 + for method in "install" "update" "downgrade" "remove"; do + mtps-run-tests "$@" --test="$method"; + thisrc=$? + thisres="$(get_result $thisrc)" + echo "$method result: $thisres (status code: $thisrc)" + if [ "$thisrc" -gt "$highrc" ]; then + highrc="$thisrc" + fi + done + tmtresult="$(get_result $highrc)" +fi + if [ -n "$TMT_TEST_DATA" ]; then # generate the result JSON - /usr/libexec/mini-tps/viewer/generate-result-json ./mtps-logs > "$TMT_TEST_DATA/result.json" + /usr/libexec/mini-tps/viewer/generate-result-json "$LOGS_DIR" > "$TMT_TEST_DATA/result.json" # copy the viewer HTML cp /usr/share/mini-tps/viewer/viewer.html "$TMT_TEST_DATA/viewer.html" diff --git a/prepare.sh b/prepare.sh index 068e4a6..24114f5 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,5 +1,9 @@ #!/usr/bin/bash +RET_NO_RPMS_IN_BREW=7 +RET_NO_RPMS_IN_REPOS=8 +RET_EMPTY_REPOQUERY=11 + set -e # sanity checks [ -z "$TASK_ID" ] && { echo "TASK_ID missing in the environment"; exit 1; } @@ -23,9 +27,20 @@ chmod +x /usr/local/libexec/mini-tps/installability_runner.sh . /var/tmp/mini-tps/env +# from now on, not all non-zero return codes are real errors +set +e + # prepare the system for testing mtps-prepare-system -p "${PROFILE_NAME}" --fixrepo --enablebuildroot mtps-get-task --createrepo --installrepofile --recursive --task="$TASK_ID" --download=/var/lib/brew-repo +rc="$?" +if [[ "$rc" -ne 0 ]]; then + if [[ "$rc" -eq $RET_NO_RPMS_IN_BREW || "$rc" -eq $RET_NO_RPMS_IN_REPOS || "$rc" -eq $RET_EMPTY_REPOQUERY ]]; then + echo "Skipped. See 'download build' (or /prepare) logs for info." > SKIP_TEST + else # unknown error + exit "$rc" + fi +fi if [ -n "$ADDITIONAL_TASK_IDS" ]; then for additional_task_id in ${ADDITIONAL_TASK_IDS}; do