[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
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
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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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