From 44ede4807c33e59d5e2c67850b384a5c05da311c Mon Sep 17 00:00:00 2001 From: shahargl Date: Sat, 16 Nov 2024 16:19:27 +0200 Subject: [PATCH] feat: wip --- .github/workflows/test-haproxy-ingress.yml | 26 ++++++++++++++-- .github/workflows/test-nginx-ingress.yml | 36 ++++++++++++++++------ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-haproxy-ingress.yml b/.github/workflows/test-haproxy-ingress.yml index fe5bb59..1c465a9 100644 --- a/.github/workflows/test-haproxy-ingress.yml +++ b/.github/workflows/test-haproxy-ingress.yml @@ -133,7 +133,7 @@ jobs: run: | INGRESS_IP="127.0.0.1" APP_NAME=$(helm list -n default -o json | jq -r '.[0].name') - MAX_RETRIES=5 + MAX_RETRIES=20 RETRY_DELAY=10 test_endpoint() { @@ -148,11 +148,31 @@ jobs: if [ -n "$headers" ]; then echo "Full curl command: curl -v $headers \"$url\"" RESP=$(curl -v $headers "$url" 2>&1) - RESP_CODE=$(echo "$RESP" | grep "< HTTP" | awk '{print $3}') else echo "Full curl command: curl -v \"$url\"" RESP=$(curl -v "$url" 2>&1) - RESP_CODE=$(echo "$RESP" | grep "< HTTP" | awk '{print $3}') + fi + + # Extract response code, handling connection failures + RESP_CODE=$(echo "$RESP" | grep "< HTTP" | awk '{print $3}') + if [ -z "$RESP_CODE" ]; then + echo "โš ๏ธ No response code received - connection may have failed" + echo -e "\n๐Ÿ” Response Details:" + echo "------------------------" + echo "Response code: Connection failed" + echo -e "\n๐Ÿ“‹ Response Headers:" + echo "$RESP" | grep -E "^< " || echo "No headers found" + echo -e "\n๐Ÿ“ Response Body:" + echo "$RESP" | sed -n '/^* Connected/,/^* Connection/!p' | grep -v "^[*<>]" || echo "No body found" + echo "------------------------" + + if [ "$i" -lt "$MAX_RETRIES" ]; then + echo "โณ Waiting ${RETRY_DELAY}s before next attempt..." + sleep "$RETRY_DELAY" + continue + fi + echo "โŒ Failed to establish connection after $MAX_RETRIES attempts" + return 1 fi echo -e "\n๐Ÿ” Response Details:" diff --git a/.github/workflows/test-nginx-ingress.yml b/.github/workflows/test-nginx-ingress.yml index f78f45c..c2d85b3 100644 --- a/.github/workflows/test-nginx-ingress.yml +++ b/.github/workflows/test-nginx-ingress.yml @@ -140,20 +140,36 @@ jobs: echo "๐Ÿงช Testing endpoints..." echo "Frontend (/) - Should redirect to /incidents:" - RESP=$(curl -s -I http://localhost/) - echo "$RESP" | grep "HTTP" + RESP=$(curl -v http://localhost/ 2>&1) + echo -e "\n๐Ÿ“‹ Response Headers:" + echo "$RESP" | grep -E "^< " || echo "No headers found" + echo -e "\n๐Ÿ“ Response Body:" + echo "$RESP" | sed -n '/^* Connected/,/^* Connection/!p' | grep -v "^[*<>]" || echo "No body found" + + RESP_CODE=$(echo "$RESP" | grep "< HTTP" | awk '{print $3}') LOCATION=$(echo "$RESP" | grep -i "location") - echo "$LOCATION" + echo -e "\nResponse code: $RESP_CODE" + echo "Location header: $LOCATION" + if [[ "$LOCATION" != *"/incidents"* ]]; then echo "โŒ Redirect to /incidents not found" exit 1 fi + echo "โœ… Frontend redirect successful" echo -e "\nBackend (/v2/docs) - Should return API info:" - for i in {1..5}; do - echo "Attempt $i of 5..." - RESP=$(curl -s http://localhost/v2/docs/) - echo "Response: $RESP" + for i in {1..20}; do + echo -e "\nAttempt $i of 20..." + RESP=$(curl -v http://localhost/v2/docs/ 2>&1) + + echo -e "\n๐Ÿ“‹ Response Headers:" + echo "$RESP" | grep -E "^< " || echo "No headers found" + echo -e "\n๐Ÿ“ Response Body:" + echo "$RESP" | sed -n '/^* Connected/,/^* Connection/!p' | grep -v "^[*<>]" || echo "No body found" + + RESP_CODE=$(echo "$RESP" | grep "< HTTP" | awk '{print $3}') + echo -e "\nResponse code: $RESP_CODE" + if [[ $RESP == *"Rest API powering"* ]]; then echo "โœ… Backend response successful" break @@ -162,14 +178,16 @@ jobs: echo "โŒ Unexpected backend response after 5 attempts" exit 1 fi - echo "Waiting 2 seconds before next attempt..." + echo "โณ Waiting 2 seconds before next attempt..." sleep 2 done echo -e "\nWebSocket (/websocket) - Testing connection:" - wscat -c "ws://localhost/websocket/app/keepappkey?protocol=7&client=js&version=8.3.0&flash=false" & + echo "๐Ÿ”„ Attempting WebSocket connection..." + wscat -c "ws://localhost/websocket/app/keepappkey?protocol=7&client=js&version=8.3.0&flash=false" --showHeaders & WSCAT_PID=$! sleep 2 + echo "๐Ÿ“Š WebSocket connection attempt completed" kill $WSCAT_PID 2>/dev/null - name: Debug - Show logs on failure