From 676b93347066c0ad13dc54172e4bf0e27306278b Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 14 Dec 2022 15:55:07 -0800 Subject: [PATCH] tests: Add tmt tests based on RHEL tests Also turn on building of weldr-client-tests, it is needed by the tmt tests. --- .fmf/version | 1 + gating.yaml | 7 ++++ plans/integration-tests.fmf | 10 ++++++ tests/scripts/run_tests.sh | 67 +++++++++++++++++++++++++++++++++++++ weldr-client.spec | 6 ++-- 5 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 plans/integration-tests.fmf create mode 100755 tests/scripts/run_tests.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..0c1cc35 --- /dev/null +++ b/gating.yaml @@ -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} diff --git a/plans/integration-tests.fmf b/plans/integration-tests.fmf new file mode 100644 index 0000000..f1de00b --- /dev/null +++ b/plans/integration-tests.fmf @@ -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/ diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh new file mode 100755 index 0000000..6437f65 --- /dev/null +++ b/tests/scripts/run_tests.sh @@ -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 diff --git a/weldr-client.spec b/weldr-client.spec index 43c946f..d04e6c6 100644 --- a/weldr-client.spec +++ b/weldr-client.spec @@ -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 @@ -144,4 +144,4 @@ composer-cli package. - ci: add tags to AWS instances (tlavocat) - build(deps): bump github.com/BurntSushi/toml from 1.2.0 to 1.2.1 (49699333+dependabot[bot]) - build(deps): bump github.com/stretchr/testify from 1.8.0 to 1.8.1 (49699333+dependabot[bot]) -- build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.1 (49699333+dependabot[bot]) \ No newline at end of file +- build(deps): bump github.com/spf13/cobra from 1.5.0 to 1.6.1 (49699333+dependabot[bot])