diff --git a/tests/cli/lib/lib.sh b/tests/cli/lib/lib.sh index 98e788ec..d29db151 100755 --- a/tests/cli/lib/lib.sh +++ b/tests/cli/lib/lib.sh @@ -152,3 +152,18 @@ check_compose_status() { return 1 fi } + +# Wait until the compose is done (finished or failed) +wait_for_compose() { + local UUID=$1 + if [ -n "$UUID" ]; then + until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do + sleep 20 + rlLogInfo "Waiting for compose to finish ..." + done; + check_compose_status "$UUID" + else + rlFail "Compose UUID is empty!" + fi +} + diff --git a/tests/cli/test_build_and_deploy_aws.sh b/tests/cli/test_build_and_deploy_aws.sh index 4a8ffd5d..bdede0b0 100755 --- a/tests/cli/test_build_and_deploy_aws.sh +++ b/tests/cli/test_build_and_deploy_aws.sh @@ -82,14 +82,7 @@ __EOF__ rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - rlLogInfo "Waiting for compose to finish ..." - sleep 30 - done; - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStartTest "Import AMI image in AWS" diff --git a/tests/cli/test_build_and_deploy_azure.sh b/tests/cli/test_build_and_deploy_azure.sh index 7c8eeec4..e4d60161 100755 --- a/tests/cli/test_build_and_deploy_azure.sh +++ b/tests/cli/test_build_and_deploy_azure.sh @@ -69,14 +69,7 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - rlLogInfo "Waiting for compose to finish ..." - sleep 30 - done; - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStartTest "Upload image to Azure" diff --git a/tests/cli/test_build_and_deploy_openstack.sh b/tests/cli/test_build_and_deploy_openstack.sh index 07ca100c..85f5e165 100755 --- a/tests/cli/test_build_and_deploy_openstack.sh +++ b/tests/cli/test_build_and_deploy_openstack.sh @@ -77,14 +77,7 @@ __EOF__ rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - rlLogInfo "Waiting for compose to finish ..." - sleep 30 - done; - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStartTest "Upload QCOW2 image to OpenStack" diff --git a/tests/cli/test_build_and_deploy_vmware.sh b/tests/cli/test_build_and_deploy_vmware.sh index e5134f07..e8dd4cd4 100755 --- a/tests/cli/test_build_and_deploy_vmware.sh +++ b/tests/cli/test_build_and_deploy_vmware.sh @@ -98,14 +98,7 @@ __EOF__ rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - rlLogInfo "Waiting for compose to finish ..." - sleep 30 - done; - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStartTest "Upload VMDK image in vCenter" diff --git a/tests/cli/test_compose_ext4-filesystem.sh b/tests/cli/test_compose_ext4-filesystem.sh index 7ba1d231..7440f65e 100755 --- a/tests/cli/test_compose_ext4-filesystem.sh +++ b/tests/cli/test_compose_ext4-filesystem.sh @@ -27,15 +27,7 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 10 - rlLogInfo "Waiting for compose to finish ..." - done; - check_compose_status "$UUID" - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStartCleanup diff --git a/tests/cli/test_compose_google.sh b/tests/cli/test_compose_google.sh index 84e5b112..7943ad95 100755 --- a/tests/cli/test_compose_google.sh +++ b/tests/cli/test_compose_google.sh @@ -23,15 +23,7 @@ rlJournalStart rlPhaseEnd rlPhaseStart "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 10 - rlLogInfo "Waiting for compose to finish..." - done - check_compose_status "$UUID" - else - flFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStart "compose check" diff --git a/tests/cli/test_compose_live-iso.sh b/tests/cli/test_compose_live-iso.sh index 5d5b3e89..13603bdb 100755 --- a/tests/cli/test_compose_live-iso.sh +++ b/tests/cli/test_compose_live-iso.sh @@ -30,15 +30,7 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 20 - rlLogInfo "Waiting for compose to finish ..." - done; - check_compose_status "$UUID" - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlRun -t -c "$CLI compose image $UUID" IMAGE="$UUID-live.iso" diff --git a/tests/cli/test_compose_partitioned-disk.sh b/tests/cli/test_compose_partitioned-disk.sh index ce3e9138..b2fa5dfe 100755 --- a/tests/cli/test_compose_partitioned-disk.sh +++ b/tests/cli/test_compose_partitioned-disk.sh @@ -27,15 +27,7 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 10 - rlLogInfo "Waiting for compose to finish ..." - done; - check_compose_status "$UUID" - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID rlPhaseEnd rlPhaseStartCleanup diff --git a/tests/cli/test_compose_qcow2.sh b/tests/cli/test_compose_qcow2.sh index b74a751b..1627244f 100755 --- a/tests/cli/test_compose_qcow2.sh +++ b/tests/cli/test_compose_qcow2.sh @@ -58,16 +58,7 @@ __EOF__ rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 20 - rlLogInfo "Waiting for compose to finish ..." - done; - check_compose_status "$UUID" - else - rlFail "Compose UUID is empty!" - fi - + wait_for_compose $UUID rlRun -t -c "$CLI compose image $UUID" IMAGE="$UUID-disk.qcow2" rlPhaseEnd diff --git a/tests/cli/test_compose_sanity.sh b/tests/cli/test_compose_sanity.sh index d2caf5f4..56140c42 100755 --- a/tests/cli/test_compose_sanity.sh +++ b/tests/cli/test_compose_sanity.sh @@ -31,11 +31,8 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "compose image" + wait_for_compose $UUID if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 5 - rlLogInfo "Waiting for compose to finish ..." - done; check_compose_status "$UUID" rlRun -t -c "$CLI compose image $UUID" @@ -45,8 +42,6 @@ rlJournalStart 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" - else - rlFail "Compose UUID is empty!" fi rlPhaseEnd diff --git a/tests/cli/test_compose_tar.sh b/tests/cli/test_compose_tar.sh index cb163f1a..2de3542d 100755 --- a/tests/cli/test_compose_tar.sh +++ b/tests/cli/test_compose_tar.sh @@ -29,15 +29,7 @@ rlJournalStart rlPhaseEnd rlPhaseStartTest "compose finished" - if [ -n "$UUID" ]; then - until $CLI compose info $UUID | grep 'FINISHED\|FAILED'; do - sleep 10 - rlLogInfo "Waiting for compose to finish ..." - done; - check_compose_status "$UUID" - else - rlFail "Compose UUID is empty!" - fi + wait_for_compose $UUID # Running a compose can lead to a different selinux policy in the # kernel, which may break docker. Reload the policy from the host and