fixtures/scripts/_head.sh in zold-0.14.23 vs fixtures/scripts/_head.sh in zold-0.14.24

- old
+ new

@@ -10,52 +10,56 @@ function reserve_port { python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()' } function wait_for_url { + i=0 while ! curl --silent --fail $1 > /dev/null; do - ((p++)) || sleep 5 - if ((p==30)); then - echo "URL $1 is not available after $p seconds of waiting" + ((i++)) || sleep 0 + if ((i==30)); then + echo "URL $1 is not available after ${i} attempts" exit 12 fi sleep 5 done } function wait_for_port { + i=0 while ! nc -z localhost $1; do - ((p++)) || sleep 5 - if ((p==30)); then - echo "Port $1 is not available after $p seconds of waiting" + ((i++)) || sleep 0 + if ((i==30)); then + echo "Port $1 is not available after ${i} attempts" exit 13 fi sleep 5 done } function wait_for_file { + i=0 while [ ! -f $1 ]; do - ((c++)) || sleep 5 - if ((c==30)); then - echo "File $1 not found, giving up after $c seconds of waiting" + ((i++)) || sleep 0 + if ((i==30)); then + echo "File $1 not found, giving up after ${i} attempts" exit 14 fi sleep 5 done } function halt_nodes { for p in "$@"; do pid=$(curl --silent "http://localhost:$p/pid?halt=test" || echo 'absent') if [[ "${pid}" =~ ^[0-9]+$ ]]; then + i=0 while kill -0 ${pid}; do - ((c++)) || sleep 5 - if ((c==30)); then - echo "Waiting for process ${pid} to die" + ((i++)) || sleep 0 + if ((i==30)); then + echo "Process ${pid} didn't die, it's a bug" exit 15 fi - echo "Still waiting for process ${pid} to die, cycle no.${c}" + echo "Still waiting for process ${pid} to die, attempt no.${i}" sleep 5 done echo "Process ${pid} is dead!" fi echo "Node at TCP port ${p} stopped!"