Skip to content

Commit e7de79b

Browse files
spikymonkeyAlbertoimpl
authored andcommitted
Retry CF API login
* 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?
1 parent 4a10971 commit e7de79b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ci/scripts/acceptance-tests.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,22 @@ EOF
5353
prepare_cf() {
5454
local -r test_instances_org="$DEFAULT_ORG-instances"
5555

56-
cf login -a "$CF_API_HOST" -u "$CF_USERNAME" -p "$CF_PASSWORD" -o system --skip-ssl-validation
56+
local api_available="false"
57+
local max_attempts=5
58+
local attempts=1
59+
local sleep_seconds=30
60+
while [ "$api_available" == "false" ] && [ $attempts -le $max_attempts ]; do
61+
echo "Attempting to log in ($attempts/$max_attempts)"
62+
cf login -a "$CF_API_HOST" -u "$CF_USERNAME" -p "$CF_PASSWORD" -o system --skip-ssl-validation
63+
64+
if [ $? ]; then
65+
api_available="true"
66+
else
67+
echo "API not ready yet; sleeping for ${sleep_seconds}s..."
68+
attempts=$((attempts + 1))
69+
sleep ${sleep_seconds}
70+
fi
71+
done
5772

5873
cf create-org "$DEFAULT_ORG"
5974
cf create-space "$DEFAULT_SPACE" -o "$DEFAULT_ORG"

0 commit comments

Comments
 (0)