Skip to content

Commit

Permalink
Merge pull request #38 from jpopelka/mtps-get-module
Browse files Browse the repository at this point in the history
mtps-get-module improvements
  • Loading branch information
jpopelka authored Jan 26, 2024
2 parents eabec34 + 464b715 commit 3a2f720
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ jobs:
trigger: pull_request
targets:
- fedora-all
- epel-7
- epel-8
- epel-9
- epel-7-x86_64
- epel-7-aarch64
- epel-8-x86_64
- epel-8-aarch64
- epel-9-x86_64
- epel-9-aarch64
# - job: copr_build
# trigger: commit
# branch: main
Expand Down
5 changes: 4 additions & 1 deletion mini-tps.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: mini-tps
Version: 0.1
Release: 166%{?dist}
Release: 167%{?dist}
Summary: Mini TPS - Test Package Sanity

License: GPLv2
Expand Down Expand Up @@ -64,6 +64,9 @@ install -pD -m 0755 profiles/fedora/prepare-system %{buildroot}%{_libexecdir}/mi


%changelog
* Thu Jan 25 2024 Jiri Popelka <[email protected]> - 0.1-167
- mtps-get-module improvements

* Fri Jan 19 2024 Jiri Popelka <[email protected]> - 0.1-166
- Skip update if old package can't be installed
- Separate exit code for skipped tests
Expand Down
52 changes: 50 additions & 2 deletions mtps-get-module
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if [ -z "${YUMDNFCMD:-}" ]; then source "$(dirname "${BASH_SOURCE[0]}")/mtps-set

RET_NO_RPMS_IN_BREW=7
RET_NO_RPMS_IN_REPOS=8
RET_NO_MODULE_ARCH=9

builds_from_answer() {
local xml="$1" && shift
Expand Down Expand Up @@ -174,6 +175,17 @@ mk_url_mmd() {
echo "$url"
}

url_exists() {
local url="$1" && shift
response=$(curl --silent --head "$url" | grep HTTP)
if [[ $response != *" 404 "* && $response != *" 403 "* ]]; then
return 0
else
echo "$url does not exist"
return 1
fi
}

download_artifact() {
local url="$1" && shift
local dstdir="$1" && shift
Expand Down Expand Up @@ -373,11 +385,43 @@ while [[ $# -gt 0 ]]; do
done

mkdir -p "${LOGS_DIR:=mtps-logs}"
TESTRUN_ID="$(date +%H%M%S)"
logfname="${LOGS_DIR%%/}/${TESTRUN_ID}-mtps-get-module.log"
LOGS_DIR="$(realpath "$LOGS_DIR")"
while true; do
TESTRUN_ID="$(date +%H%M%S)"
logfname="${LOGS_DIR%%/}/${TESTRUN_ID}-${MBSID}-mtps-get-module.log"
logfname_skip="$(dirname "$logfname")/SKIP-$(basename "$logfname")"
logfname_pass="$(dirname "$logfname")/PASS-$(basename "$logfname")"
logfname_fail="$(dirname "$logfname")/FAIL-$(basename "$logfname")"
if [[ -e "$logfname" || -e "$logfname_pass" || -e "$logfname_fail" ]]; then
sleep 1
continue
fi
break
done
exec &> >(tee -a "$logfname")
exec 2>&1

do_clean_exit() {
rc=$?
trap - SIGINT SIGTERM SIGABRT EXIT # clear the trap
new_logfname="$logfname_fail"
if [[ "$rc" -eq 0 ]]; then
new_logfname="$logfname_pass"
elif [[ "$rc" -eq $RET_NO_RPMS_IN_BREW || "$rc" -eq $RET_NO_RPMS_IN_REPOS || "$rc" -eq $RET_NO_MODULE_ARCH ]]; then
new_logfname="$logfname_skip"
fi
# Close tee pipes
for pid in $(ps -o pid --no-headers --ppid $$); do
if [ -n "$(ps -p $pid -o pid=)" ]; then
kill -s HUP $pid
fi
done
mv -f "$logfname" "$new_logfname"
exit $rc
}

trap do_clean_exit SIGINT SIGTERM SIGABRT EXIT

debug "Brew build: $BUILD"
debug "Brew tag: $TAG"
debug "MBS build id: $MBSID"
Expand Down Expand Up @@ -453,6 +497,10 @@ if [[ -z "$builds_in_m" ]]; then
fi

mmd_url="$(mk_url_mmd "$m_nvr" "$ARCH")"
if ! url_exists "$mmd_url"; then
echo "$m_nvr has probably not been built for $ARCH"
exit $RET_NO_MODULE_ARCH
fi
mmd_file="$(basename "$mmd_url")"
mmd_dir="$(mktemp --directory)"
download_artifact "$mmd_url" "$mmd_dir"
Expand Down
4 changes: 4 additions & 0 deletions viewer/generate-result-json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ for log in mtps_log_dir.iterdir():
test_name = "download build"
test_object = None

if test_object == "mtps-get-module":
test_name = "module info"
test_object = None

results[test_name].append(
{
"result": RESULTS_MAPPING[result],
Expand Down

0 comments on commit 3a2f720

Please sign in to comment.