woocommerce/packages/js/e2e-environment/bin/wait-for-build.sh

33 lines
893 B
Bash
Raw Permalink Normal View History

#!/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
MAX_ATTEMPTS=30
2019-12-20 00:10:44 +00:00
# Delay (in seconds) between each polling attempt
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"
RAWDATA=$(curl -s -o /dev/null -w '%{http_code}' ${WP_BASE_URL}/?pagename=ready)
while [[ "${RAWDATA: -3}" != "200" ]]
do
echo "$(date) - Waiting for testing environment"
sleep ${DELAY_SEC}
((count++))
if [[ $count -gt ${MAX_ATTEMPTS} ]]; then
echo "$(date) - Testing environment couldn't be found"
exit 1
fi
RAWDATA=$(curl -s -o /dev/null -w '%{http_code}' ${WP_BASE_URL}/?pagename=ready)
done
if [[ $count -gt 0 ]]; then
echo "$(date) - Testing environment is ready"
fi