tests: Use a loop to wait for VM and sshd to start
Related: rhbz#1733504
This commit is contained in:
parent
9d7fcc8642
commit
c2c6bfa458
@ -16,6 +16,28 @@ if [ "$COMPOSER_TEST_FAIL_FAST" == "1" ]; then
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
export QEMU_BIN="/usr/bin/qemu-system-$(uname -m)"
|
||||||
|
export QEMU="$QEMU_BIN -machine accel=kvm:tcg"
|
||||||
|
export SSH_PORT=2222
|
||||||
|
|
||||||
|
boot_image() {
|
||||||
|
QEMU_BOOT=$1
|
||||||
|
TIMEOUT=$2
|
||||||
|
rlRun -t -c "$QEMU -m 2048 $QEMU_BOOT -nographic -monitor none \
|
||||||
|
-net user,id=nic0,hostfwd=tcp::$SSH_PORT-:22 -net nic &"
|
||||||
|
# wait for ssh to become ready (yes, http is the wrong protocol, but it returns the header)
|
||||||
|
tries=0
|
||||||
|
until curl -sS -m 15 "http://localhost:$SSH_PORT/" | grep 'OpenSSH'; do
|
||||||
|
tries=$((tries + 1))
|
||||||
|
if [ $tries -gt $TIMEOUT ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
echo "DEBUG: Waiting for ssh become ready before testing ..."
|
||||||
|
done;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# a generic helper function unifying the specific checks executed on a running
|
# a generic helper function unifying the specific checks executed on a running
|
||||||
# image instance
|
# image instance
|
||||||
verify_image() {
|
verify_image() {
|
||||||
|
@ -13,8 +13,6 @@ set -e
|
|||||||
. $(dirname $0)/lib/lib.sh
|
. $(dirname $0)/lib/lib.sh
|
||||||
|
|
||||||
CLI="${CLI:-./src/bin/composer-cli}"
|
CLI="${CLI:-./src/bin/composer-cli}"
|
||||||
QEMU_BIN="/usr/libexec/qemu-kvm"
|
|
||||||
QEMU="$QEMU_BIN -machine accel=kvm:tcg"
|
|
||||||
|
|
||||||
rlJournalStart
|
rlJournalStart
|
||||||
rlPhaseStartSetup
|
rlPhaseStartSetup
|
||||||
@ -60,16 +58,12 @@ __EOF__
|
|||||||
rlPhaseEnd
|
rlPhaseEnd
|
||||||
|
|
||||||
rlPhaseStartTest "Start VM instance"
|
rlPhaseStartTest "Start VM instance"
|
||||||
rlRun -t -c "$QEMU -m 2048 -boot c -cdrom $IMAGE -nographic \
|
boot_image "-boot d -cdrom $IMAGE" 120
|
||||||
-net user,id=nic0,hostfwd=tcp::2222-:22 -net nic &"
|
|
||||||
# 60 seconds timeout at boot menu screen
|
|
||||||
# then media check + boot ~ 30 seconds
|
|
||||||
sleep 120
|
|
||||||
rlPhaseEnd
|
rlPhaseEnd
|
||||||
|
|
||||||
rlPhaseStartTest "Verify VM instance"
|
rlPhaseStartTest "Verify VM instance"
|
||||||
# run generic tests to verify the instance
|
# run generic tests to verify the instance
|
||||||
ROOT_ACCOUNT_LOCKED=0 verify_image root localhost "-p 2222"
|
ROOT_ACCOUNT_LOCKED=0 verify_image liveuser localhost "-p $SSH_PORT"
|
||||||
rlPhaseEnd
|
rlPhaseEnd
|
||||||
|
|
||||||
rlPhaseStartCleanup
|
rlPhaseStartCleanup
|
||||||
|
@ -13,8 +13,6 @@ set -e
|
|||||||
. $(dirname $0)/lib/lib.sh
|
. $(dirname $0)/lib/lib.sh
|
||||||
|
|
||||||
CLI="${CLI:-./src/bin/composer-cli}"
|
CLI="${CLI:-./src/bin/composer-cli}"
|
||||||
QEMU_BIN="/usr/libexec/qemu-kvm"
|
|
||||||
QEMU="$QEMU_BIN -machine accel=kvm:tcg"
|
|
||||||
|
|
||||||
rlJournalStart
|
rlJournalStart
|
||||||
rlPhaseStartSetup
|
rlPhaseStartSetup
|
||||||
@ -74,14 +72,12 @@ __EOF__
|
|||||||
rlPhaseEnd
|
rlPhaseEnd
|
||||||
|
|
||||||
rlPhaseStartTest "Start VM instance"
|
rlPhaseStartTest "Start VM instance"
|
||||||
rlRun -t -c "$QEMU -m 2048 -boot c -hda $IMAGE -nographic \
|
boot_image "-boot c -hda $IMAGE" 60
|
||||||
-net user,id=nic0,hostfwd=tcp::2222-:22 -net nic &"
|
|
||||||
sleep 60
|
|
||||||
rlPhaseEnd
|
rlPhaseEnd
|
||||||
|
|
||||||
rlPhaseStartTest "Verify VM instance"
|
rlPhaseStartTest "Verify VM instance"
|
||||||
# run generic tests to verify the instance
|
# run generic tests to verify the instance
|
||||||
verify_image root localhost "-i $SSH_KEY_DIR/id_rsa -p 2222"
|
verify_image root localhost "-i $SSH_KEY_DIR/id_rsa -p $SSH_PORT"
|
||||||
rlPhaseEnd
|
rlPhaseEnd
|
||||||
|
|
||||||
rlPhaseStartCleanup
|
rlPhaseStartCleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user