tests: Add tmt tests based on RHEL tests

Also turn on building of weldr-client-tests, it is needed by the tmt tests.
This commit is contained in:
Brian C. Lane 2022-12-14 15:55:07 -08:00
parent 71582c2bba
commit 676b933470
5 changed files with 88 additions and 3 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

7
gating.yaml Normal file
View File

@ -0,0 +1,7 @@
--- !Policy
product_versions:
- fedora-*
decision_contexts: [bodhi_update_push_stable]
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

View File

@ -0,0 +1,10 @@
summary: Run integration tests
prepare:
how: install
package:
- osbuild-composer
- weldr-client
- weldr-client-tests
- createrepo_c
execute:
script: ./tests/scripts/run_tests.sh ./tests/

67
tests/scripts/run_tests.sh Executable file
View File

@ -0,0 +1,67 @@
#!/bin/bash
set -eux
FAILANY=0
function fail {
echo -e "\n\n#### ERROR: $1\n"
FAIL=1
FAILANY=1
}
function status {
if [ "$FAIL" -eq 0 ]; then
echo -e "\n\n#### PASS: $1\n"
else
echo -e "\n\n#### FAIL: $1\n"
fi
}
function running {
FAIL=0
echo -e "\n\n#### RUN: $1\n"
}
backend_start() {
export BACKEND="osbuild-composer"
systemctl start osbuild-composer.socket
RET=$?
if [ "$RET" -eq 0 ]; then
# wait for the backend to become ready
tries=0
until curl -m 15 --unix-socket /run/weldr/api.socket http://localhost:4000/api/status | grep 'db_supported.*true'; do
echo "#### INFO: Waiting for backend to become ready. Try $tries ..."
tries=$((tries + 1))
if [ $tries -gt 50 ]; then
fail "Backend taking too long to become ready"
# Log why starting osbuild-composer failed
journalctl -u osbuild-composer
exit 1
fi
sleep 10
done
else
fail "Unable to start composer backend (exit code $RET)"
# Log why starting osbuild-composer failed
journalctl -u osbuild-composer
exit $RET
fi
}
: ${1?"Usage: $0 TOPDIR"}
TOPDIR=$1
# What versions of things do we have installed?
rpm -q weldr-client osbuild osbuild-composer
composer-cli version || fail "Getting composer-cli version"
# Start osbuild-composer
backend_start
composer-cli status show || fail "Getting osbuild-composer status"
/usr/libexec/tests/composer-cli/composer-cli-tests -test.v || fail "Running integration tests"
exit $FAILANY

View File

@ -1,5 +1,5 @@
# Pass --with tests to rpmbuild to build composer-cli-tests
%bcond_with tests
# Pass --without tests to skip building composer-cli-tests
%bcond_without tests
# Pass --without signed to skip gpg signed tar.gz (DO NOT DO THAT IN PRODUCTION)
%bcond_without signed