Skip to content

Commit

Permalink
Retry CF API login
Browse files Browse the repository at this point in the history
* Sometimes cf login fails - this WIP will perform a retry
* But sometimes login succeeds and then a later command fails. We might need to extract the retry into a function and use it on every cf command?
  • Loading branch information
spikymonkey authored and Albertoimpl committed Oct 9, 2023
1 parent c043145 commit 0946512
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ci/scripts/acceptance-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ EOF
prepare_cf() {
local -r test_instances_org="$DEFAULT_ORG-instances"

cf login -a "$CF_API_HOST" -u "$CF_USERNAME" -p "$CF_PASSWORD" -o system --skip-ssl-validation
local api_available="false"
local max_attempts=5
local attempts=1
local sleep_seconds=30
while [ "$api_available" == "false" ] && [ $attempts -le $max_attempts ]; do
echo "Attempting to log in ($attempts/$max_attempts)"
cf login -a "$CF_API_HOST" -u "$CF_USERNAME" -p "$CF_PASSWORD" -o system --skip-ssl-validation

if [ $? ]; then
api_available="true"
else
echo "API not ready yet; sleeping for ${sleep_seconds}s..."
attempts=$((attempts + 1))
sleep ${sleep_seconds}
fi
done

cf create-org "$DEFAULT_ORG"
cf create-space "$DEFAULT_SPACE" -o "$DEFAULT_ORG"
Expand Down

0 comments on commit 0946512

Please sign in to comment.