2018-12-12 11:38:09 +00:00
|
|
|
#!/bin/bash
|
2019-06-17 12:35:31 +00:00
|
|
|
# Note: execute this file from the project root directory
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
set -eu
|
|
|
|
|
2019-11-06 12:22:39 +00:00
|
|
|
. $(dirname $0)/cli/lib/lib.sh
|
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
export BEAKERLIB_DIR=$(mktemp -d /tmp/composer-test.XXXXXX)
|
|
|
|
CLI="${CLI:-}"
|
2018-12-12 11:38:09 +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-10-30 18:39:16 +00:00
|
|
|
|
|
|
|
# Make the live-iso boot more quickly (isolinux.cfg)
|
|
|
|
for cfg in "$share_dir"/live/config_files/*/isolinux.cfg; do
|
|
|
|
sed -i.orig 's/^timeout.*/timeout 20/' "$cfg"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make the live-iso boot more quickly (grub.cfg)
|
|
|
|
for cfg in "$share_dir"/live/config_files/*/grub.conf; do
|
|
|
|
sed -i.orig 's/^timeout.*/timeout 2/' "$cfg"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make the live-iso boot more quickly (grub2-efi.cfg)
|
|
|
|
for cfg in "$share_dir"/live/config_files/*/grub2-efi.cfg; do
|
|
|
|
sed -i.orig 's/^set timeout.*/set timeout=2/' "$cfg"
|
|
|
|
done
|
|
|
|
|
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'; we need a little hack to do inplace
|
|
|
|
# substitution as awk on RHEL-7 doesn't provide '-i inplace' option
|
|
|
|
echo "$(awk "
|
|
|
|
/%post/ && FLAG != 2 {FLAG=1}
|
|
|
|
/%end/ && FLAG == 1 {print \"sed -i 's/.*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' /etc/ssh/sshd_config\"; FLAG=2}
|
2019-06-02 17:47:02 +00:00
|
|
|
{print}" $share_dir/composer/live-iso.ks)" > $share_dir/composer/live-iso.ks
|
2019-04-08 09:00:41 +00:00
|
|
|
|
2019-06-05 13:16:19 +00:00
|
|
|
# do a backup of the original blueprints directory and get rid of the git
|
|
|
|
# directory (otherwise all of the initial changes in blueprints would have
|
|
|
|
# to be done using blueprints push)
|
|
|
|
cp -r $blueprints_dir ${blueprints_dir}.orig
|
|
|
|
rm -rf $blueprints_dir/git
|
|
|
|
|
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-12-12 11:38:09 +00:00
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
function teardown_tests {
|
2019-06-05 13:16:19 +00:00
|
|
|
local share_dir=$1
|
|
|
|
local blueprints_dir=$2
|
|
|
|
|
|
|
|
mv $share_dir/composer/live-iso.ks.orig $share_dir/composer/live-iso.ks
|
2019-10-30 18:39:16 +00:00
|
|
|
|
|
|
|
# Restore all the configuration files
|
|
|
|
for cfg in "$share_dir"/live/config_files/*/*.orig; do
|
|
|
|
mv "$cfg" "${cfg%%.orig}"
|
|
|
|
done
|
|
|
|
|
2019-06-05 13:16:19 +00:00
|
|
|
rm -rf $blueprints_dir
|
|
|
|
mv ${blueprints_dir}.orig $blueprints_dir
|
2019-03-08 10:29:11 +00:00
|
|
|
}
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-06-17 12:35: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
|
|
|
|
|
2019-11-06 12:22:39 +00:00
|
|
|
export BLUEPRINTS_DIR=`mktemp -d '/tmp/composer-blueprints.XXXXX'`
|
2019-03-08 10:29:11 +00:00
|
|
|
cp ./tests/pylorax/blueprints/*.toml $BLUEPRINTS_DIR
|
|
|
|
|
2019-11-06 12:22:39 +00:00
|
|
|
export SHARE_DIR=`mktemp -d '/tmp/composer-share.XXXXX'`
|
2019-03-08 10:29:11 +00:00
|
|
|
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-06-17 12:35:31 +00:00
|
|
|
# start the lorax-composer daemon
|
2019-11-06 12:22:39 +00:00
|
|
|
composer_start
|
2019-03-08 10:29:11 +00:00
|
|
|
else
|
2019-06-02 17:47:02 +00:00
|
|
|
export PACKAGE="composer-cli"
|
2019-08-20 08:52:50 +00:00
|
|
|
export BLUEPRINTS_DIR="/var/lib/lorax/composer/blueprints"
|
2019-11-06 12:22:39 +00:00
|
|
|
composer_stop
|
2019-06-02 17:47:02 +00:00
|
|
|
setup_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
|
2019-11-06 12:22:39 +00:00
|
|
|
composer_start
|
2019-03-08 10:29:11 +00:00
|
|
|
fi
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
# Clean out the test-results directory
|
|
|
|
if [ -e "/var/tmp/test-results" ]; then
|
|
|
|
rm -rf "/var/tmp/test-results"
|
|
|
|
fi
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-01-23 14:32:32 +00:00
|
|
|
export BEAKERLIB_JOURNAL=0
|
2019-01-23 22:09:45 +00:00
|
|
|
export PATH="/usr/local/bin:$PATH"
|
2018-12-12 11:38:09 +00:00
|
|
|
if [ -z "$*" ]; then
|
2019-06-17 12:35:31 +00:00
|
|
|
# invoke cli/ tests which can be executed without special preparation
|
2018-12-12 11:38:09 +00:00
|
|
|
./tests/cli/test_blueprints_sanity.sh
|
|
|
|
./tests/cli/test_compose_sanity.sh
|
|
|
|
else
|
2019-06-17 12:35:31 +00:00
|
|
|
# execute other cli tests which need more adjustments in the calling environment
|
2018-12-12 11:38:09 +00:00
|
|
|
# or can't be executed inside Travis CI
|
2019-01-25 17:47:38 +00:00
|
|
|
for TEST in "$@"; do
|
2019-06-17 12:35:31 +00:00
|
|
|
$TEST
|
2018-12-12 11:38:09 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
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
|
2019-11-06 12:22:39 +00:00
|
|
|
composer_stop
|
2019-06-05 13:16:19 +00:00
|
|
|
teardown_tests $SHARE_DIR $BLUEPRINTS_DIR
|
2019-03-08 10:29:11 +00:00
|
|
|
else
|
2019-11-06 12:22:39 +00:00
|
|
|
composer_stop
|
2019-06-05 13:16:19 +00:00
|
|
|
teardown_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
|
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
|
2019-11-06 12:22:39 +00:00
|
|
|
composer_start
|
2019-03-08 10:29:11 +00:00
|
|
|
fi
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
. $BEAKERLIB_DIR/TestResults
|
|
|
|
|
|
|
|
if [ $TESTRESULT_RESULT_ECODE != 0 ]; then
|
|
|
|
echo "Test failed. Leaving log in $BEAKERLIB_DIR"
|
|
|
|
exit $TESTRESULT_RESULT_ECODE
|
|
|
|
fi
|
2018-12-12 11:38:09 +00:00
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
rm -rf $BEAKERLIB_DIR
|