Skip to content

Commit

Permalink
Merge pull request #30 from jpopelka/new-mtps-run-tests-return-codes
Browse files Browse the repository at this point in the history
Update for new mtps-run-tests return codes
  • Loading branch information
jpopelka authored Feb 20, 2024
2 parents 4dcb872 + cb77cd2 commit 973022d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
38 changes: 26 additions & 12 deletions installability_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
15 changes: 15 additions & 0 deletions prepare.sh
Original file line number Diff line number Diff line change
@@ -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; }
Expand All @@ -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
Expand Down

0 comments on commit 973022d

Please sign in to comment.