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