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

Cherry-picked from 7b08fa8838

Related: rhbz#1825190
This commit is contained in:
Alexander Todorov 2019-11-29 14:23:28 +02:00 committed by Brian C. Lane
parent 6240df6caf
commit 6b2efa0da1
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" "`$CLI blueprints list | grep $bp`" "$bp"
done done
fi fi
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "blueprints save" rlPhaseStartTest "blueprints save"
rlRun -t -c "$CLI blueprints save example-http-server" rlRun -t -c "$CLI blueprints save test-http-server"
rlAssertExists "example-http-server.toml" rlAssertExists "test-http-server.toml"
rlAssertGrep "example-http-server" "example-http-server.toml" rlAssertGrep "test-http-server" "test-http-server.toml"
rlAssertGrep "httpd" "example-http-server.toml" rlAssertGrep "httpd" "test-http-server.toml"
# non-existing blueprint # non-existing blueprint
rlRun -t -c "$CLI blueprints save non-existing-bp" 1 rlRun -t -c "$CLI blueprints save non-existing-bp" 1

View File

@ -75,7 +75,8 @@ __EOF__
rlPhaseStartTest "compose start" rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing" 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 rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '` UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -62,7 +62,8 @@ rlJournalStart
rlPhaseStartTest "compose start" rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing" 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 rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '` UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -34,7 +34,8 @@ rlJournalStart
rlPhaseStartTest "compose start" rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing" 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 rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '` UUID=`echo $UUID | cut -f 2 -d' '`

View File

@ -16,7 +16,8 @@ CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart rlJournalStart
rlPhasStartTest "compose start" rlPhasStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing" 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 rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d ' '` UUID=`echo $UUID | cut -f 2 -d ' '`

View File

@ -20,7 +20,8 @@ CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart rlJournalStart
rlPhaseStartTest "compose start" rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing" 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 rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '` UUID=`echo $UUID | cut -f 2 -d' '`

View File

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

View File

@ -22,7 +22,8 @@ rlJournalStart
rlPhaseStartTest "compose start" rlPhaseStartTest "compose start"
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing" 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 rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '` UUID=`echo $UUID | cut -f 2 -d' '`

View File

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