[tests] Use a function to wait for compose to finish

The function is meant to replace the duplicate pieces of code used in various
tests, the polling interval is unified to 20 seconds.

Cherry-picked from 836f0ddf

Related: rhbz#1769525
This commit is contained in:
Jiri Kortus 2019-09-06 18:56:19 +02:00 committed by Alexander Todorov
parent e7f2706461
commit 16daa25137
12 changed files with 26 additions and 93 deletions

View File

@ -152,3 +152,18 @@ check_compose_status() {
return 1 return 1
fi 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
}

View File

@ -82,14 +82,7 @@ __EOF__
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "Import AMI image in AWS" rlPhaseStartTest "Import AMI image in AWS"

View File

@ -69,14 +69,7 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "Upload image to Azure" rlPhaseStartTest "Upload image to Azure"

View File

@ -77,14 +77,7 @@ __EOF__
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "Upload QCOW2 image to OpenStack" rlPhaseStartTest "Upload QCOW2 image to OpenStack"

View File

@ -98,14 +98,7 @@ __EOF__
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "Upload VMDK image in vCenter" rlPhaseStartTest "Upload VMDK image in vCenter"

View File

@ -27,15 +27,7 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStartCleanup rlPhaseStartCleanup

View File

@ -23,15 +23,7 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStart "compose finished" rlPhaseStart "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStart "compose check" rlPhaseStart "compose check"

View File

@ -30,15 +30,7 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlRun -t -c "$CLI compose image $UUID" rlRun -t -c "$CLI compose image $UUID"
IMAGE="$UUID-live.iso" IMAGE="$UUID-live.iso"

View File

@ -27,15 +27,7 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlPhaseEnd rlPhaseEnd
rlPhaseStartCleanup rlPhaseStartCleanup

View File

@ -58,16 +58,7 @@ __EOF__
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
rlRun -t -c "$CLI compose image $UUID" rlRun -t -c "$CLI compose image $UUID"
IMAGE="$UUID-disk.qcow2" IMAGE="$UUID-disk.qcow2"
rlPhaseEnd rlPhaseEnd

View File

@ -31,11 +31,8 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose image" rlPhaseStartTest "compose image"
wait_for_compose $UUID
if [ -n "$UUID" ]; then 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" check_compose_status "$UUID"
rlRun -t -c "$CLI compose image $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/"
rlAssertExists "/var/lib/lorax/composer/results/$UUID/root.tar.xz" rlAssertExists "/var/lib/lorax/composer/results/$UUID/root.tar.xz"
rlAssertNotDiffer "/var/lib/lorax/composer/results/$UUID/root.tar.xz" "$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 fi
rlPhaseEnd rlPhaseEnd

View File

@ -29,15 +29,7 @@ rlJournalStart
rlPhaseEnd rlPhaseEnd
rlPhaseStartTest "compose finished" rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then wait_for_compose $UUID
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
# Running a compose can lead to a different selinux policy in the # Running a compose can lead to a different selinux policy in the
# kernel, which may break docker. Reload the policy from the host and # kernel, which may break docker. Reload the policy from the host and