tests: Use BACKEND env variable instead of hard-coded values
- default BACKEND to lorax-composer
- pass BACKEND everywhere we need to
Cherry-picked from 14a3c8d5a7
Related: rhbz#1825190
This commit is contained in:
parent
a6aab2242a
commit
9193384bb8
7
Makefile
7
Makefile
@ -1,6 +1,7 @@
|
||||
PYTHON ?= /usr/bin/python3
|
||||
DESTDIR ?= /
|
||||
DOCKER ?= docker
|
||||
BACKEND ?= lorax-composer
|
||||
|
||||
PKGNAME = lorax
|
||||
VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
|
||||
@ -144,10 +145,10 @@ vm-local-repos: vm
|
||||
$(TEST_OS)
|
||||
bots/image-customize -v \
|
||||
--upload $(REPOS_DIR):/etc/yum.repos.d \
|
||||
--run-command "yum -y remove composer-cli lorax-composer" \
|
||||
--run-command "yum -y remove composer-cli $(BACKEND)" \
|
||||
--run-command "yum -y update" \
|
||||
--run-command "yum -y install composer-cli lorax-composer" \
|
||||
--run-command "systemctl enable lorax-composer" \
|
||||
--run-command "yum -y install composer-cli $(BACKEND)" \
|
||||
--run-command "systemctl enable $(BACKEND).socket" \
|
||||
$(TEST_OS)
|
||||
|
||||
vm-reset:
|
||||
|
@ -85,7 +85,7 @@ class ComposerTestCase(VirtMachineTestCase):
|
||||
# Upload the contents of the ./tests/ directory to the machine (it must have beakerlib already installed)
|
||||
self.machine.upload(["../tests"], "/")
|
||||
|
||||
print("Waiting for lorax-composer to become ready...")
|
||||
print("Waiting for backend to become ready...")
|
||||
curl_command = ["curl", "--max-time", "360",
|
||||
"--silent",
|
||||
"--unix-socket", "/run/weldr/api.socket",
|
||||
@ -107,7 +107,7 @@ class ComposerTestCase(VirtMachineTestCase):
|
||||
return local_dir
|
||||
|
||||
def runCliTest(self, script):
|
||||
extra_env = []
|
||||
extra_env = ["BACKEND=%s" % os.getenv('BACKEND', 'lorax-composer')]
|
||||
if self.sit:
|
||||
extra_env.append("COMPOSER_TEST_FAIL_FAST=1")
|
||||
|
||||
|
2
test/run
2
test/run
@ -2,6 +2,8 @@
|
||||
# This is the expected entry point for Cockpit CI; will be called without
|
||||
# arguments but with an appropriate $TEST_OS, and optionally $TEST_SCENARIO
|
||||
|
||||
export BACKEND="${BACKEND:-lorax-composer}"
|
||||
|
||||
make vm
|
||||
|
||||
if [ -n "$TEST_SCENARIO" ]; then
|
||||
|
@ -1,10 +1,11 @@
|
||||
#!/bin/sh -eux
|
||||
|
||||
BACKEND="${BACKEND:-lorax-composer}"
|
||||
SRPM="$1"
|
||||
|
||||
# always remove older versions of these RPMs if they exist
|
||||
# to ensure newly built packages have been installed
|
||||
yum -y remove lorax lorax-composer composer-cli
|
||||
yum -y remove lorax $BACKEND composer-cli
|
||||
|
||||
if ! rpm -q beakerlib; then
|
||||
if [ $(. /etc/os-release && echo $ID) = "rhel" ]; then
|
||||
@ -37,9 +38,12 @@ rm -rf build-results
|
||||
su builder -c "/usr/bin/mock --no-clean --resultdir build-results --rebuild $SRPM"
|
||||
|
||||
packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm')
|
||||
yum install -y $packages
|
||||
if [ "$BACKEND" == "osbuild-composer" ]; then
|
||||
packages=$(find build-results -name '*.rpm' -not -name '*.src.rpm' -not -name '*lorax-composer*')
|
||||
fi
|
||||
yum install -y $packages $BACKEND
|
||||
|
||||
systemctl enable lorax-composer.socket
|
||||
systemctl enable $BACKEND.socket
|
||||
|
||||
if [ -f /usr/bin/docker ]; then
|
||||
yum remove -y $(rpm -qf /usr/bin/docker)
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
. /usr/share/beakerlib/beakerlib.sh
|
||||
|
||||
BACKEND="${BACKEND:-lorax-composer}"
|
||||
export BACKEND
|
||||
|
||||
# Monkey-patch beakerlib to exit on first failure if COMPOSER_TEST_FAIL_FAST is
|
||||
# set. https://github.com/beakerlib/beakerlib/issues/42
|
||||
COMPOSER_TEST_FAIL_FAST=${COMPOSER_TEST_FAIL_FAST:-0}
|
||||
@ -97,8 +100,8 @@ composer_start() {
|
||||
else
|
||||
# socket stop/start seems to be necessary for a proper service restart
|
||||
# after a previous direct manual run for it to work properly
|
||||
systemctl start lorax-composer.socket
|
||||
systemctl start lorax-composer
|
||||
systemctl start $BACKEND.socket
|
||||
systemctl start $BACKEND
|
||||
fi
|
||||
rc=$?
|
||||
|
||||
@ -106,7 +109,7 @@ composer_start() {
|
||||
if [ "$rc" -eq 0 ]; then
|
||||
wait_for_composer
|
||||
else
|
||||
rlLogFail "Unable to start lorax-composer (exit code $rc)"
|
||||
rlLogFail "Unable to start $BACKEND (exit code $rc)"
|
||||
fi
|
||||
return $rc
|
||||
}
|
||||
@ -115,15 +118,15 @@ composer_stop() {
|
||||
MANUAL=${MANUAL:-0}
|
||||
# socket stop/start seems to be necessary for a proper service restart
|
||||
# after a previous direct manual run for it to work properly
|
||||
if systemctl list-units | grep -q lorax-composer.socket; then
|
||||
systemctl stop lorax-composer.socket
|
||||
if systemctl list-units | grep -q $BACKEND.socket; then
|
||||
systemctl stop $BACKEND.socket
|
||||
fi
|
||||
|
||||
if [[ -z "$CLI" || "$CLI" == "./src/bin/composer-cli" || "$MANUAL" == "1" ]]; then
|
||||
pkill -9 lorax-composer
|
||||
rm -f /run/weldr/api.socket
|
||||
else
|
||||
systemctl stop lorax-composer
|
||||
systemctl stop $BACKEND
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ set -eu
|
||||
CLI="${CLI:-}"
|
||||
|
||||
function setup_tests {
|
||||
[ "$BACKEND" == "osbuild-composer" ] && return 0
|
||||
|
||||
local share_dir=$1
|
||||
local blueprints_dir=$2
|
||||
|
||||
@ -56,6 +58,8 @@ __EOF__
|
||||
}
|
||||
|
||||
function teardown_tests {
|
||||
[ "$BACKEND" == "osbuild-composer" ] && return 0
|
||||
|
||||
local share_dir=$1
|
||||
local blueprints_dir=$2
|
||||
|
||||
@ -91,7 +95,7 @@ if [ -z "$CLI" ]; then
|
||||
chmod a+rx -R $SHARE_DIR
|
||||
|
||||
setup_tests $SHARE_DIR $BLUEPRINTS_DIR
|
||||
# start the lorax-composer daemon
|
||||
# start the backend daemon
|
||||
composer_start
|
||||
else
|
||||
export PACKAGE="composer-cli"
|
||||
@ -111,14 +115,14 @@ setup_beakerlib_env
|
||||
run_beakerlib_tests "$@"
|
||||
|
||||
if [ -z "$CLI" ]; then
|
||||
# stop lorax-composer and remove /run/weldr/api.socket
|
||||
# stop backend and remove /run/weldr/api.socket
|
||||
# only if running against source
|
||||
composer_stop
|
||||
teardown_tests $SHARE_DIR $BLUEPRINTS_DIR
|
||||
else
|
||||
composer_stop
|
||||
teardown_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
|
||||
# start lorax-composer again so we can continue with manual or other kinds
|
||||
# start backend again so we can continue with manual or other kinds
|
||||
# of testing on the same system
|
||||
composer_start
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user