2018-09-19 12:00:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Note: execute this file from the project root directory
|
|
|
|
|
2019-06-02 13:20:42 +00:00
|
|
|
set -eu
|
|
|
|
|
2019-06-02 13:05:17 +00:00
|
|
|
export BEAKERLIB_DIR=$(mktemp -d /tmp/composer-test.XXXXXX)
|
2018-09-19 12:00:25 +00:00
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
function setup_tests {
|
2019-06-02 17:47:02 +00:00
|
|
|
local share_dir=$1
|
|
|
|
local blueprints_dir=$2
|
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
# explicitly enable sshd for live-iso b/c it is disabled by default
|
|
|
|
# due to security concerns (no root password required)
|
2019-06-02 17:47:02 +00:00
|
|
|
sed -i.orig 's/^services.*/services --disabled="network" --enabled="NetworkManager,sshd"/' $share_dir/composer/live-iso.ks
|
2019-02-28 15:31:05 +00:00
|
|
|
# explicitly enable logging in with empty passwords via ssh, because
|
|
|
|
# the default sshd setting for PermitEmptyPasswords is 'no'
|
|
|
|
awk -i inplace "
|
|
|
|
/%post/ && FLAG != 2 {FLAG=1}
|
|
|
|
/%end/ && FLAG == 1 {print \"sed -i 's/.*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' /etc/ssh/sshd_config\"; FLAG=2}
|
|
|
|
{print}" \
|
2019-06-02 17:47:02 +00:00
|
|
|
$share_dir/composer/live-iso.ks
|
2019-04-08 09:00:41 +00:00
|
|
|
|
|
|
|
# append a section with additional option on kernel command line to example-http-server blueprint
|
|
|
|
# which is used for building of most of the images
|
2019-06-02 17:47:02 +00:00
|
|
|
cat >> $blueprints_dir/example-http-server.toml << __EOF__
|
2019-04-08 09:00:41 +00:00
|
|
|
|
|
|
|
[customizations.kernel]
|
|
|
|
append = "custom_cmdline_arg"
|
|
|
|
__EOF__
|
2019-03-08 10:29:11 +00:00
|
|
|
}
|
2018-11-22 13:40:27 +00:00
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
function teardown_tests {
|
|
|
|
mv $1/composer/live-iso.ks.orig $1/composer/live-iso.ks
|
|
|
|
}
|
2018-11-27 13:33:35 +00:00
|
|
|
|
2019-05-28 11:06:31 +00:00
|
|
|
# cloud credentials
|
|
|
|
if [ -f "~/.config/lorax-test-env" ]; then
|
|
|
|
. ~/.config/lorax-test-env
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "/var/tmp/lorax-test-env" ]; then
|
|
|
|
. /var/tmp/lorax-test-env
|
|
|
|
fi
|
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
if [ -z "$CLI" ]; then
|
|
|
|
export top_srcdir=`pwd`
|
|
|
|
. ./tests/testenv.sh
|
|
|
|
|
|
|
|
BLUEPRINTS_DIR=`mktemp -d '/tmp/composer-blueprints.XXXXX'`
|
|
|
|
cp ./tests/pylorax/blueprints/*.toml $BLUEPRINTS_DIR
|
|
|
|
|
|
|
|
SHARE_DIR=`mktemp -d '/tmp/composer-share.XXXXX'`
|
|
|
|
cp -R ./share/* $SHARE_DIR
|
|
|
|
chmod a+rx -R $SHARE_DIR
|
|
|
|
|
2019-06-02 17:47:02 +00:00
|
|
|
setup_tests $SHARE_DIR $BLUEPRINTS_DIR
|
2019-03-08 10:29:11 +00:00
|
|
|
# start the lorax-composer daemon
|
|
|
|
./src/sbin/lorax-composer --sharedir $SHARE_DIR $BLUEPRINTS_DIR &
|
|
|
|
else
|
2019-05-28 11:17:25 +00:00
|
|
|
export PACKAGE="composer-cli"
|
2019-06-02 17:47:02 +00:00
|
|
|
setup_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
|
2019-03-08 10:29:11 +00:00
|
|
|
systemctl restart lorax-composer
|
|
|
|
fi
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2018-09-19 12:00:25 +00:00
|
|
|
|
|
|
|
# wait for the backend to become ready
|
2018-10-10 18:27:10 +00:00
|
|
|
tries=0
|
|
|
|
until curl -m 15 --unix-socket /run/weldr/api.socket http://localhost:4000/api/status | grep 'db_supported.*true'; do
|
|
|
|
tries=$((tries + 1))
|
|
|
|
if [ $tries -gt 20 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-09-19 12:00:25 +00:00
|
|
|
sleep 2
|
|
|
|
echo "DEBUG: Waiting for backend API to become ready before testing ..."
|
|
|
|
done;
|
|
|
|
|
2018-11-21 13:09:01 +00:00
|
|
|
|
|
|
|
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
|
2019-01-25 17:47:38 +00:00
|
|
|
for TEST in "$@"; do
|
2019-04-12 18:17:28 +00:00
|
|
|
$TEST
|
2018-11-21 13:09:01 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2018-09-19 12:00:25 +00:00
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
if [ -z "$CLI" ]; then
|
|
|
|
# stop lorax-composer and remove /run/weldr/api.socket
|
|
|
|
# only if running against source
|
|
|
|
pkill -9 lorax-composer
|
|
|
|
rm -f /run/weldr/api.socket
|
|
|
|
teardown_tests $SHARE_DIR
|
|
|
|
else
|
|
|
|
systemctl stop lorax-composer
|
2019-06-02 17:47:02 +00:00
|
|
|
teardown_tests /usr/share/lorax
|
2019-03-08 10:29:11 +00:00
|
|
|
# start lorax-composer again so we can continue with manual or other kinds
|
|
|
|
# of testing on the same system
|
|
|
|
systemctl start lorax-composer
|
|
|
|
fi
|
2018-10-02 23:23:42 +00:00
|
|
|
|
2019-06-02 13:05:17 +00:00
|
|
|
. $BEAKERLIB_DIR/TestResults
|
2018-09-19 12:00:25 +00:00
|
|
|
|
2019-06-02 13:05:17 +00:00
|
|
|
if [ $TESTRESULT_RESULT_ECODE != 0 ]; then
|
|
|
|
echo "Test failed. Leaving log in $BEAKERLIB_DIR"
|
|
|
|
exit $TESTRESULT_RESULT_ECODE
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf $BEAKERLIB_DIR
|