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
This commit is contained in:
Lars Karlitski 2019-06-02 19:47:02 +02:00 committed by Alexander Todorov
parent 9b5554aa1e
commit 7c0d2577a8

View File

@ -5,20 +5,23 @@
rm -rf /var/tmp/beakerlib-*/ rm -rf /var/tmp/beakerlib-*/
function setup_tests { function setup_tests {
local share_dir=$1
local blueprints_dir=$2
# explicitly enable sshd for live-iso b/c it is disabled by default # explicitly enable sshd for live-iso b/c it is disabled by default
# due to security concerns (no root password required) # 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 # 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 # 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 # substitution as awk on RHEL-7 doesn't provide '-i inplace' option
echo "$(awk " echo "$(awk "
/%post/ && FLAG != 2 {FLAG=1} /%post/ && FLAG != 2 {FLAG=1}
/%end/ && FLAG == 1 {print \"sed -i 's/.*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' /etc/ssh/sshd_config\"; FLAG=2} /%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 # 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 # 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] [customizations.kernel]
append = "custom_cmdline_arg" append = "custom_cmdline_arg"
@ -40,12 +43,12 @@ if [ -z "$CLI" ]; then
cp -R ./share/* $SHARE_DIR cp -R ./share/* $SHARE_DIR
chmod a+rx -R $SHARE_DIR chmod a+rx -R $SHARE_DIR
setup_tests $SHARE_DIR setup_tests $SHARE_DIR $BLUEPRINTS_DIR
# Start the lorax-composer daemon # Start the lorax-composer daemon
./src/sbin/lorax-composer --sharedir $SHARE_DIR $BLUEPRINTS_DIR & ./src/sbin/lorax-composer --sharedir $SHARE_DIR $BLUEPRINTS_DIR &
else else
SHARE_DIR="/usr/share/lorax" export PACKAGE="composer-cli"
setup_tests $SHARE_DIR setup_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
systemctl restart lorax-composer systemctl restart lorax-composer
fi fi
@ -85,7 +88,7 @@ if [ -z "$CLI" ]; then
teardown_tests $SHARE_DIR teardown_tests $SHARE_DIR
else else
systemctl stop lorax-composer 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 # start lorax-composer again so we can continue with manual or other kinds
# of testing on the same system # of testing on the same system
systemctl start lorax-composer systemctl start lorax-composer