X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=env%2Flib%2Fcommon.sh;h=7ec65c53c9e9797365898d4387569f8ed12bca35;hb=refs%2Fchanges%2F99%2F4499%2F2;hp=78f4c12d3ee53ddfe821b98cb9e69631bb1aa1fc;hpb=5a9a1e698a844e6753f3a72fd7dfb5e82898867a;p=icn.git diff --git a/env/lib/common.sh b/env/lib/common.sh index 78f4c12..7ec65c5 100755 --- a/env/lib/common.sh +++ b/env/lib/common.sh @@ -110,3 +110,17 @@ function node_networkdata { cat $NODES_FILE | jq -r --arg name "$name" '.nodes[] | select(.name==$name) | .net' } + +function wait_for { + local -r interval=${WAIT_FOR_INTERVAL:-30s} + local -r max_tries=${WAIT_FOR_TRIES:-20} + local try=0 + until "$@"; do + echo "[${try}/${max_tries}] - Waiting ${interval} for $*" + sleep ${interval} + try=$((try+1)) + if [[ ${try} -ge ${max_tries} ]]; then + return 1 + fi + done +}