vmcheck: add timeout option for vm_ssh_wait

Closes: #360
Approved by: cgwalters
This commit is contained in:
Jonathan Lebon 2016-06-24 16:40:20 -04:00 committed by Atomic Bot
parent 55e1cfeb99
commit 65f5678ecb
3 changed files with 14 additions and 5 deletions

View File

@ -6,7 +6,7 @@ Tests are divided into two groups:
- Tests in the `vmcheck` directory are destructive and
installed. They are run inside a VM. Use `make vmcheck` to
run these.
run these (see also `HACKING.md` in the top directory).
The `common` directory contains files used by multiple
tests. The `utils` directory contains helper utilities

View File

@ -33,18 +33,25 @@ vm_send() {
}
# wait until ssh is available on the vm
# - $1 timeout in second (optional)
vm_ssh_wait() {
# XXX: add timeout
while ! vm_cmd true &> /dev/null; do
timeout=${1:-0}
while [ $timeout -gt 0 ]; do
if vm_cmd true &> /dev/null; then
return 0
fi
timeout=$((timeout - 1))
sleep 1
done
# final check at the timeout mark
vm_cmd true &> /dev/null
}
# reboot the vm
vm_reboot() {
vm_cmd systemctl reboot || :
sleep 2 # give time for port to go down
vm_ssh_wait
vm_ssh_wait 10
}
# check that the given files exist on the VM

View File

@ -9,8 +9,10 @@ echo " ControlPersist yes" >> ssh-config
export SSH="ssh -F $PWD/ssh-config vmcheck"
export SCP="scp -F $PWD/ssh-config"
. ${commondir}/libvm.sh
# stand up ssh connection and sanity check that it all works
if ! $SSH true &> /dev/null; then
if ! vm_ssh_wait 10; then
echo "ERROR: A running VM is required for 'make vmcheck'."
exit 1
fi