From 6b2efa0da1f97ffb0e5dd36722b41271059e11c2 Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Fri, 29 Nov 2019 14:23:28 +0200 Subject: [PATCH] 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 7b08fa883893fb5c4fed859a9e66ca3a873a16bc Related: rhbz#1825190 --- tests/cli/lib/test-http-server.toml | 18 +++++++++++++++ tests/cli/test_blueprints_sanity.sh | 10 ++++---- tests/cli/test_build_and_deploy_aws.sh | 3 ++- tests/cli/test_build_and_deploy_azure.sh | 3 ++- tests/cli/test_compose_ext4-filesystem.sh | 3 ++- tests/cli/test_compose_google.sh | 3 ++- tests/cli/test_compose_partitioned-disk.sh | 3 ++- tests/cli/test_compose_sanity.sh | 11 +++++---- tests/cli/test_compose_tar.sh | 3 ++- tests/test_cli.sh | 27 ++++------------------ 10 files changed, 46 insertions(+), 38 deletions(-) create mode 100644 tests/cli/lib/test-http-server.toml diff --git a/tests/cli/lib/test-http-server.toml b/tests/cli/lib/test-http-server.toml new file mode 100644 index 00000000..6331724a --- /dev/null +++ b/tests/cli/lib/test-http-server.toml @@ -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" diff --git a/tests/cli/test_blueprints_sanity.sh b/tests/cli/test_blueprints_sanity.sh index 2847e1ec..58bb199e 100755 --- a/tests/cli/test_blueprints_sanity.sh +++ b/tests/cli/test_blueprints_sanity.sh @@ -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 diff --git a/tests/cli/test_build_and_deploy_aws.sh b/tests/cli/test_build_and_deploy_aws.sh index 949165f2..2f39e0e6 100755 --- a/tests/cli/test_build_and_deploy_aws.sh +++ b/tests/cli/test_build_and_deploy_aws.sh @@ -75,7 +75,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' '` diff --git a/tests/cli/test_build_and_deploy_azure.sh b/tests/cli/test_build_and_deploy_azure.sh index 201eb2ee..35dee17f 100755 --- a/tests/cli/test_build_and_deploy_azure.sh +++ b/tests/cli/test_build_and_deploy_azure.sh @@ -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' '` diff --git a/tests/cli/test_compose_ext4-filesystem.sh b/tests/cli/test_compose_ext4-filesystem.sh index 1e8b6f25..48224c1e 100755 --- a/tests/cli/test_compose_ext4-filesystem.sh +++ b/tests/cli/test_compose_ext4-filesystem.sh @@ -34,7 +34,8 @@ 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' '` diff --git a/tests/cli/test_compose_google.sh b/tests/cli/test_compose_google.sh index 7943ad95..bf8510fb 100755 --- a/tests/cli/test_compose_google.sh +++ b/tests/cli/test_compose_google.sh @@ -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 ' '` diff --git a/tests/cli/test_compose_partitioned-disk.sh b/tests/cli/test_compose_partitioned-disk.sh index b2fa5dfe..20ea3b6b 100755 --- a/tests/cli/test_compose_partitioned-disk.sh +++ b/tests/cli/test_compose_partitioned-disk.sh @@ -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' '` diff --git a/tests/cli/test_compose_sanity.sh b/tests/cli/test_compose_sanity.sh index 159fce15..686f008e 100755 --- a/tests/cli/test_compose_sanity.sh +++ b/tests/cli/test_compose_sanity.sh @@ -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 diff --git a/tests/cli/test_compose_tar.sh b/tests/cli/test_compose_tar.sh index 2b56c46e..8696fdef 100755 --- a/tests/cli/test_compose_tar.sh +++ b/tests/cli/test_compose_tar.sh @@ -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' '` diff --git a/tests/test_cli.sh b/tests/test_cli.sh index bee776cc..3a4ce5c8 100755 --- a/tests/test_cli.sh +++ b/tests/test_cli.sh @@ -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