1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2024-11-24 21:06:31 +00:00
nginx-proxy/test/lib/helpers.bash

23 lines
487 B
Bash
Raw Normal View History

## add the retry function to bats
# Retry a command $1 times until it succeeds. Wait $2 seconds between retries.
function retry {
local attempts=$1
shift
local delay=$1
shift
local i
for ((i=0; i < attempts; i++)); do
run "$@"
if [ "$status" -eq 0 ]; then
echo "$output"
return 0
fi
sleep $delay
done
echo "Command \"$@\" failed $attempts times. Status: $status. Output: $output" >&2
false
}