Skip to content

Commit

Permalink
Update http_test.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
smarunich authored Jan 12, 2024
1 parent 1747a69 commit ecc8759
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions samples/http_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ while true; do
((TOTAL_ATTEMPTS++))

echo -e "${BLUE}$(date +"%H:%M:%S")${NC} connecting to ${GREEN}fx.internal.az-ms.com${NC}..."
START_TIME=$(date +%s.%N)
OUTPUT=$(curl -Ivs http://fx.internal.az-ms.com 2>&1)
END_TIME=$(date +%s.%N)
ELAPSED_TIME=$(echo "$END_TIME - $START_TIME" | bc)

if echo "$OUTPUT" | grep -q "error"; then
# Increment the failure counter
Expand All @@ -50,6 +53,10 @@ while true; do
# Extract, color code the IP in 'Connected to' line, and display it
CONNECTED_LINE=$(echo "$OUTPUT" | grep -E 'Connected to' | head -n 1)
echo -e "${CONNECTED_LINE}" | sed -r 's/([0-9]{1,3}(\.[0-9]{1,3}){3})/'$'\e[33m''&'$'\e[39m''/'

# Extract and display the line containing the HTTP response code
RESPONSE_CODE_LINE=$(echo "$OUTPUT" | grep -E 'HTTP/' | tail -1)
echo -e "${RESPONSE_CODE_LINE}"

# Extract, color code, and display the 'location:' line
LOCATION_LINE=$(echo "$OUTPUT" | grep -E 'location:' | head -n 1)
Expand All @@ -64,6 +71,11 @@ while true; do
# Extract and display the 'x-envoy-upstream-service-time' line
ENVOY_TIME_LINE=$(echo "$OUTPUT" | grep -E 'x-envoy-upstream-service-time:' | head -n 1)
echo -e "${ENVOY_TIME_LINE}"



# Display the time taken for the curl command
echo -e "Time taken for request: ${ELAPSED_TIME}s"
fi

sleep 0.5
Expand Down

0 comments on commit ecc8759

Please sign in to comment.