[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#1770193
This commit is contained in:
Jiri Kortus 2019-09-06 18:56:19 +02:00 committed by Brian C. Lane
parent 78fbb7c49e
commit a8d7841bc1
11 changed files with 34 additions and 79 deletions

View File

@ -143,3 +143,26 @@ check_kernel_cmdline() {
rlRun -t -c "ssh $SSH_OPTS ${SSH_USER}@${SSH_MACHINE} 'grep custom_cmdline_arg /proc/cmdline'" 0 \
"System booted from the image contains specified parameter on kernel command line"
}
# Fail if the compose failed, only call after checking for FINISHED|FAILED
check_compose_status() {
UUID="$1"
if "$CLI" compose details "$UUID" | grep FAILED; then
rlFail "compose $UUID FAILED"
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 details $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

@ -88,14 +88,7 @@ __EOF__
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $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

@ -75,14 +75,7 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $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

@ -83,14 +83,7 @@ __EOF__
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $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

@ -104,14 +104,7 @@ __EOF__
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $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,14 +27,7 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $UUID | grep 'FINISHED\|FAILED'; do
sleep 60
rlLogInfo "Waiting for compose to finish ..."
done;
else
rlFail "Compose UUID is empty!"
fi
wait_for_compose $UUID
rlPhaseEnd
rlPhaseStartCleanup

View File

@ -44,14 +44,7 @@ __EOF__
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $UUID | grep 'FINISHED\|FAILED'; do
sleep 20
rlLogInfo "Waiting for compose to finish ..."
done;
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,14 +27,7 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $UUID | grep 'FINISHED\|FAILED'; do
sleep 60
rlLogInfo "Waiting for compose to finish ..."
done;
else
rlFail "Compose UUID is empty!"
fi
wait_for_compose $UUID
rlPhaseEnd
rlPhaseStartCleanup

View File

@ -58,15 +58,7 @@ __EOF__
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $UUID | grep 'FINISHED\|FAILED'; do
sleep 20
rlLogInfo "Waiting for compose to finish ..."
done;
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,9 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose image"
wait_for_compose $UUID
if [ -n "$UUID" ]; then
until $CLI compose details $UUID | grep 'FINISHED\|FAILED'; do
sleep 60
rlLogInfo "Waiting for compose to finish ..."
done;
check_compose_status "$UUID"
rlRun -t -c "$CLI compose image $UUID"
rlAssertExists "$UUID-root.tar.xz"
@ -44,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

@ -30,14 +30,7 @@ rlJournalStart
rlPhaseEnd
rlPhaseStartTest "compose finished"
if [ -n "$UUID" ]; then
until $CLI compose details $UUID | grep 'FINISHED\|FAILED'; do
sleep 10
rlLogInfo "Waiting for compose to finish ..."
done;
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