DRY when setting up, running & parsing results for beakerlib tests
Cherry-picked from b197e448ff
Related: rhbz#1770193
This commit is contained in:
parent
3d3c32819c
commit
92535addc8
@ -19,6 +19,35 @@ if [ "$COMPOSER_TEST_FAIL_FAST" == "1" ]; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
setup_beakerlib_env() {
|
||||||
|
export BEAKERLIB_DIR=$(mktemp -d /tmp/composer-test.XXXXXX)
|
||||||
|
export BEAKERLIB_JOURNAL=0
|
||||||
|
}
|
||||||
|
|
||||||
|
run_beakerlib_tests() {
|
||||||
|
if [ -z "$*" ]; then
|
||||||
|
echo "run_beakerlib_tests() requires a test to execute"
|
||||||
|
else
|
||||||
|
# execute tests
|
||||||
|
for TEST in "$@"; do
|
||||||
|
$TEST
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_beakerlib_results() {
|
||||||
|
. $BEAKERLIB_DIR/TestResults
|
||||||
|
|
||||||
|
TESTRESULT_RESULT_ECODE="${TESTRESULT_RESULT_ECODE:-}"
|
||||||
|
if [ $TESTRESULT_RESULT_ECODE != 0 ]; then
|
||||||
|
echo "Test failed. Leaving log in $BEAKERLIB_DIR"
|
||||||
|
exit $TESTRESULT_RESULT_ECODE
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf $BEAKERLIB_DIR
|
||||||
|
}
|
||||||
|
|
||||||
export QEMU_BIN="/usr/libexec/qemu-kvm"
|
export QEMU_BIN="/usr/libexec/qemu-kvm"
|
||||||
export QEMU="$QEMU_BIN -machine accel=kvm:tcg"
|
export QEMU="$QEMU_BIN -machine accel=kvm:tcg"
|
||||||
export SSH_PORT=2222
|
export SSH_PORT=2222
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Note: execute this file from the project root directory
|
# Note: execute this file from the project root directory
|
||||||
|
# Note: Use test/check-cli && test/check-cloud if you want to
|
||||||
|
# execute test scenarios by hand!
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
. $(dirname $0)/cli/lib/lib.sh
|
. $(dirname $0)/cli/lib/lib.sh
|
||||||
|
|
||||||
export BEAKERLIB_DIR=$(mktemp -d /tmp/composer-test.XXXXXX)
|
|
||||||
CLI="${CLI:-}"
|
CLI="${CLI:-}"
|
||||||
|
|
||||||
function setup_tests {
|
function setup_tests {
|
||||||
@ -105,20 +106,9 @@ if [ -e "/var/tmp/test-results" ]; then
|
|||||||
rm -rf "/var/tmp/test-results"
|
rm -rf "/var/tmp/test-results"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export BEAKERLIB_JOURNAL=0
|
setup_beakerlib_env
|
||||||
export PATH="/usr/local/bin:$PATH"
|
|
||||||
if [ -z "$*" ]; then
|
|
||||||
# invoke cli/ tests which can be executed without special preparation
|
|
||||||
./tests/cli/test_blueprints_sanity.sh
|
|
||||||
./tests/cli/test_compose_sanity.sh
|
|
||||||
else
|
|
||||||
# execute other cli tests which need more adjustments in the calling environment
|
|
||||||
# or can't be executed inside Travis CI
|
|
||||||
for TEST in "$@"; do
|
|
||||||
$TEST
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
run_beakerlib_tests "$@"
|
||||||
|
|
||||||
if [ -z "$CLI" ]; then
|
if [ -z "$CLI" ]; then
|
||||||
# stop lorax-composer and remove /run/weldr/api.socket
|
# stop lorax-composer and remove /run/weldr/api.socket
|
||||||
@ -133,11 +123,4 @@ else
|
|||||||
composer_start
|
composer_start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. $BEAKERLIB_DIR/TestResults
|
parse_beakerlib_results
|
||||||
|
|
||||||
if [ $TESTRESULT_RESULT_ECODE != 0 ]; then
|
|
||||||
echo "Test failed. Leaving log in $BEAKERLIB_DIR"
|
|
||||||
exit $TESTRESULT_RESULT_ECODE
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf $BEAKERLIB_DIR
|
|
||||||
|
@ -1,26 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Note: execute this file from the project root directory
|
# Note: execute this file from the project root directory
|
||||||
|
# Used for running a beakerlib test script inside a running VM
|
||||||
|
# without setting up composer first!
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
. $(dirname $0)/cli/lib/lib.sh
|
. $(dirname $0)/cli/lib/lib.sh
|
||||||
|
|
||||||
export BEAKERLIB_DIR=$(mktemp -d /tmp/composer-test.XXXXXX)
|
setup_beakerlib_env
|
||||||
export BEAKERLIB_JOURNAL=0
|
|
||||||
if [ -z "$*" ]; then
|
|
||||||
echo "test_image.sh requires a test to execute"
|
|
||||||
else
|
|
||||||
# execute tests
|
|
||||||
for TEST in "$@"; do
|
|
||||||
$TEST
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
. $BEAKERLIB_DIR/TestResults
|
run_beakerlib_tests "$@"
|
||||||
|
|
||||||
if [ $TESTRESULT_RESULT_ECODE != 0 ]; then
|
parse_beakerlib_results
|
||||||
echo "Test failed. Leaving log in $BEAKERLIB_DIR"
|
|
||||||
exit $TESTRESULT_RESULT_ECODE
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf $BEAKERLIB_DIR
|
|
||||||
|
Loading…
Reference in New Issue
Block a user