tests: Do not rely on example blueprints

- avoids having to modify them in the first place so less changes
  to the SUT
- will help with transition to osbuild-composer backend
- each test which needs a blueprint either declares it on its own
  (some already do this) or may use a shared blueprints from the
  tests lib dir
This commit is contained in:
Alexander Todorov 2019-11-29 14:23:28 +02:00 committed by Brian C. Lane
parent 4dd7cf8798
commit 7b08fa8838
10 changed files with 46 additions and 38 deletions

View File

@ -0,0 +1,18 @@
name = "test-http-server"
description = "Http server with PHP and MySQL support used in tests."
version = "0.0.1"
[[modules]]
name = "httpd"
version = "2.4.*"
[[modules]]
name = "php"
version = "7.*"
[[packages]]
name = "openssh-server"
version = "*"
[customizations.kernel]
append = "custom_cmdline_arg console=ttyS0,115200n8"

View File

@ -17,13 +17,15 @@ rlJournalStart
"`$CLI blueprints list | grep $bp`" "$bp"
done
fi
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
rlPhaseEnd
rlPhaseStartTest "blueprints save"
rlRun -t -c "$CLI blueprints save example-http-server"
rlAssertExists "example-http-server.toml"
rlAssertGrep "example-http-server" "example-http-server.toml"
rlAssertGrep "httpd" "example-http-server.toml"
rlRun -t -c "$CLI blueprints save test-http-server"
rlAssertExists "test-http-server.toml"
rlAssertGrep "test-http-server" "test-http-server.toml"
rlAssertGrep "httpd" "test-http-server.toml"
# non-existing blueprint
rlRun -t -c "$CLI blueprints save non-existing-bp" 1

View File

@ -77,7 +77,8 @@ __EOF__
rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
UUID=`$CLI compose start example-http-server ami`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server ami`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -62,7 +62,8 @@ rlJournalStart
rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
UUID=`$CLI compose start example-http-server vhd`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server vhd`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -20,7 +20,8 @@ CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart
rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
UUID=`$CLI compose start example-http-server ext4-filesystem`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server ext4-filesystem`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -16,7 +16,8 @@ CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart
rlPhasStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
UUID=`$CLI compose start example-http-server google`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server google`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d ' '`

View File

@ -20,7 +20,8 @@ CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart
rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
UUID=`$CLI compose start example-http-server partitioned-disk`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server partitioned-disk`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -50,7 +50,8 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose start"
UUID=`$CLI compose start example-http-server ami`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server qcow2`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`
@ -81,7 +82,7 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose start again"
UUID=`$CLI compose start example-http-server ami`
UUID=`$CLI compose start test-http-server qcow2`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`
@ -101,12 +102,12 @@ rlJournalStart
check_compose_status "$UUID"
rlRun -t -c "$CLI compose image $UUID"
rlAssertExists "$UUID-root.tar.xz"
rlAssertExists "$UUID-disk.qcow2"
# because this path is listed in the documentation
rlAssertExists "/var/lib/lorax/composer/results/$UUID/"
rlAssertExists "/var/lib/lorax/composer/results/$UUID/root.tar.xz"
rlAssertNotDiffer "/var/lib/lorax/composer/results/$UUID/root.tar.xz" "$UUID-root.tar.xz"
rlAssertExists "/var/lib/lorax/composer/results/$UUID/disk.qcow2"
rlAssertNotDiffer "/var/lib/lorax/composer/results/$UUID/disk.qcow2" "$UUID-disk.qcow2"
fi
rlPhaseEnd

View File

@ -22,7 +22,8 @@ rlJournalStart
rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
UUID=`$CLI compose start example-http-server tar`
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
UUID=`$CLI compose start test-http-server tar`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -13,7 +13,6 @@ function setup_tests {
[ "$BACKEND" == "osbuild-composer" ] && return 0
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)
@ -41,27 +40,12 @@ function setup_tests {
/%end/ && FLAG == 1 {print \"sed -i 's/.*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' /etc/ssh/sshd_config\"; FLAG=2}
{print}" \
$share_dir/composer/live-iso.ks
# 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
# 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__
[customizations.kernel]
append = "custom_cmdline_arg console=ttyS0,115200n8"
__EOF__
}
function teardown_tests {
[ "$BACKEND" == "osbuild-composer" ] && return 0
local share_dir=$1
local blueprints_dir=$2
mv $share_dir/composer/live-iso.ks.orig $share_dir/composer/live-iso.ks
@ -69,9 +53,6 @@ function teardown_tests {
for cfg in "$share_dir"/templates.d/99-generic/live/config_files/*/*.orig; do
mv "$cfg" "${cfg%%.orig}"
done
rm -rf $blueprints_dir
mv ${blueprints_dir}.orig $blueprints_dir
}
# cloud credentials
@ -94,14 +75,14 @@ if [ -z "$CLI" ]; then
cp -R ./share/* $SHARE_DIR
chmod a+rx -R $SHARE_DIR
setup_tests $SHARE_DIR $BLUEPRINTS_DIR
setup_tests $SHARE_DIR
# start the backend daemon
composer_start
else
export PACKAGE="composer-cli"
export BLUEPRINTS_DIR="/var/lib/lorax/composer/blueprints"
composer_stop
setup_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
setup_tests /usr/share/lorax
composer_start
fi
@ -118,10 +99,10 @@ if [ -z "$CLI" ]; then
# stop backend and remove /run/weldr/api.socket
# only if running against source
composer_stop
teardown_tests $SHARE_DIR $BLUEPRINTS_DIR
teardown_tests $SHARE_DIR
else
composer_stop
teardown_tests /usr/share/lorax /var/lib/lorax/composer/blueprints
teardown_tests /usr/share/lorax
# start backend again so we can continue with manual or other kinds
# of testing on the same system
composer_start