fix: tackling 502s

This commit is contained in:
Aditya
2024-05-22 20:58:59 +05:30
parent 8f3e663f20
commit b2cc556b6f
+15 -1
View File
@@ -43,19 +43,33 @@ jobs:
- name: Register a user and check the status code - name: Register a user and check the status code
run: | run: |
MAX_RETRIES=30
RETRY_INTERVAL=2
for (( i=1; i<=$MAX_RETRIES; i++ ))
do
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" 'http://localhost:3001/api/v1/register' \ STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" 'http://localhost:3001/api/v1/register' \
-H 'Accept: */*' \ -H 'Accept: */*' \
-H 'Accept-Language: en-US,en;q=0.9' \ -H 'Accept-Language: en-US,en;q=0.9' \
-H 'Connection: keep-alive' \ -H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
--data-raw '{"username":"demo@demo.io","password":"supercoolpassword"}') --data-raw '{"username":"demo@demo.io","password":"supercoolpassword"}')
if [ "$STATUS_CODE" -eq 200 ]; then if [ "$STATUS_CODE" -eq 200 ]; then
echo "User registration was successful with status code 200." echo "User registration was successful with status code 200."
else exit 0
elif [ "$STATUS_CODE" -ne 502 ]; then
echo "User registration failed with status code $STATUS_CODE." echo "User registration failed with status code $STATUS_CODE."
exit 1 exit 1
fi fi
echo "Received status code 502. Retrying in $RETRY_INTERVAL seconds... ($i/$MAX_RETRIES)"
sleep $RETRY_INTERVAL
done
echo "User registration failed after $MAX_RETRIES attempts."
exit 1
- name: Get the API key and run a health check - name: Get the API key and run a health check
run: | run: |
RESPONSE=$(curl -s -k -u admin:StrongShufflePassword321! 'https://localhost:9200/users/_search') RESPONSE=$(curl -s -k -u admin:StrongShufflePassword321! 'https://localhost:9200/users/_search')