Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Parameterize polling retry count and wait period
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Oct 25, 2019
1 parent c14cb77 commit 005ba5c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/e2e/lib/poll.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ function poll_until_equals() {
local what="$1"
local expected="$2"
local check_cmd="$3"
poll_until_true "$what" "[ '$expected' = \"\$( $check_cmd )\" ]"
local retries="$4"
local wait_period="$5"
poll_until_true "$what" "[ '$expected' = \"\$( $check_cmd )\" ]" "$retries" "$wait_period"
}

function poll_until_true() {
local what="$1"
local check_cmd="$2"
# timeout after $retries * $wait_period seconds
local retries=${3:-24}
local wait_period=${4:-5}
echo -n ">>> Waiting for $what " >&3
retries=24
count=0
until eval "$check_cmd"; do
echo -n '.' >&3
sleep 5
sleep $wait_period
count=$(($count + 1))
if [[ ${count} -eq ${retries} ]]; then
echo ' No more retries left!' >&3
Expand Down

0 comments on commit 005ba5c

Please sign in to comment.