2018-01-18 18:42:19 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-12-20 00:10:44 +00:00
|
|
|
# Max amount of time to wait for the Docker container to be built
|
|
|
|
# Allowing 30 polling attempts, 10 seconds delay between each attempt
|
2019-12-19 22:48:03 +00:00
|
|
|
MAX_ATTEMPTS=30
|
|
|
|
|
2019-12-20 00:10:44 +00:00
|
|
|
# Delay (in seconds) between each polling attempt
|
2019-12-19 22:48:03 +00:00
|
|
|
DELAY_SEC=10
|
|
|
|
|
|
|
|
# Counter for the loop that checks if the Docker container had been built
|
|
|
|
count=0
|
2020-07-24 13:12:07 +00:00
|
|
|
WP_BASE_URL=$(node utils/get-base-url.js)
|
2020-07-28 19:23:32 +00:00
|
|
|
printf "Testing URL: $WP_BASE_URL\n\n"
|
|
|
|
|
2020-07-24 13:12:07 +00:00
|
|
|
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' ${WP_BASE_URL}/?pagename=ready)" != "200" ]]
|
2019-12-19 22:48:03 +00:00
|
|
|
|
2019-12-15 15:32:26 +00:00
|
|
|
do
|
2021-08-17 17:58:20 +00:00
|
|
|
echo "$(date) - Waiting for testing environment"
|
2019-12-19 22:48:03 +00:00
|
|
|
sleep ${DELAY_SEC}
|
|
|
|
|
|
|
|
((count++))
|
|
|
|
|
|
|
|
if [[ $count -gt ${MAX_ATTEMPTS} ]]; then
|
2021-08-17 17:58:20 +00:00
|
|
|
echo "$(date) - Testing environment couldn't be found"
|
|
|
|
exit 1
|
2019-12-19 22:48:03 +00:00
|
|
|
fi
|
2019-12-15 15:32:26 +00:00
|
|
|
done
|
2019-12-19 22:48:03 +00:00
|
|
|
|
2020-04-07 18:09:24 +00:00
|
|
|
if [[ $count -gt 0 ]]; then
|
2021-08-17 17:58:20 +00:00
|
|
|
echo "$(date) - Testing environment is ready"
|
2020-04-07 18:09:24 +00:00
|
|
|
fi
|