[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:
parent
78fbb7c49e
commit
a8d7841bc1
@ -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
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user