From 7c0d2577a80a0f262a769a8b60eec70d1e759280 Mon Sep 17 00:00:00 2001 From: Lars Karlitski Date: Sun, 2 Jun 2019 19:47:02 +0200 Subject: [PATCH] tests: Set BLUEPRINTS_DIR in all cases `setup_tests()` expected BLUEPRINTS_DIR to be set, but it wasn't when running in automated mode (with $CLI set). Fix this and move share and blueprint dirs to function arguments. Related: rhbz#1698366 --- tests/test_cli.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/test_cli.sh b/tests/test_cli.sh index eb68c83e..fa43abc0 100755 --- a/tests/test_cli.sh +++ b/tests/test_cli.sh @@ -5,20 +5,23 @@ rm -rf /var/tmp/beakerlib-*/ function setup_tests { + local share_dir=$1 + local blueprints_dir=$2 + # explicitly enable sshd for live-iso b/c it is disabled by default # due to security concerns (no root password required) - sed -i.orig 's/^services.*/services --disabled="network" --enabled="NetworkManager,sshd"/' $1/composer/live-iso.ks + sed -i.orig 's/^services.*/services --disabled="network" --enabled="NetworkManager,sshd"/' $share_dir/composer/live-iso.ks # 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} - {print}" $1/composer/live-iso.ks)" > $1/composer/live-iso.ks + {print}" $share_dir/composer/live-iso.ks)" > $share_dir/composer/live-iso.ks # 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 - cat >> $BLUEPRINTS_DIR/example-http-server.toml << __EOF__ + cat >> $blueprints_dir/example-http-server.toml << __EOF__ [customizations.kernel] append = "custom_cmdline_arg" @@ -40,12 +43,12 @@ if [ -z "$CLI" ]; then cp -R ./share/* $SHARE_DIR chmod a+rx -R $SHARE_DIR - setup_tests $SHARE_DIR + setup_tests $SHARE_DIR $BLUEPRINTS_DIR # Start the lorax-composer daemon ./src/sbin/lorax-composer --sharedir $SHARE_DIR $BLUEPRINTS_DIR & else - SHARE_DIR="/usr/share/lorax" - setup_tests $SHARE_DIR + export PACKAGE="composer-cli" + setup_tests /usr/share/lorax /var/lib/lorax/composer/blueprints systemctl restart lorax-composer fi @@ -85,7 +88,7 @@ if [ -z "$CLI" ]; then teardown_tests $SHARE_DIR else systemctl stop lorax-composer - teardown_tests $SHARE_DIR + teardown_tests /usr/share/lorax # start lorax-composer again so we can continue with manual or other kinds # of testing on the same system systemctl start lorax-composer