mirror of
https://github.com/thib8956/nginx-proxy
synced 2024-12-26 20:46:32 +00:00
4bd30f5d2c
This test suite is implemented using [bats](https://github.com/sstephenson/bats). Not all features are tested. For instance ssl features and custom nginx config are missing. Probably others. This test suite won't work with TravisCI. Too many evenings were wasted trying to overcome [issues](http://stackoverflow.com/questions/32846800/travis-fails-to-stop-docker-containers) that arises only on the TravisCI platform. However it runs on [CircleCI](https://circleci.com) which is also free for opensource projects.
23 lines
487 B
Bash
23 lines
487 B
Bash
## 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
|
|
}
|