vmcheck: add timeout option for vm_ssh_wait
Closes: #360 Approved by: cgwalters
This commit is contained in:
parent
55e1cfeb99
commit
65f5678ecb
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user