Skip to content

Commit

Permalink
Testing smoke test correction
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheislamdfe committed Oct 21, 2024
1 parent 36bcf9d commit 6b1bda5
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions .github/actions/deploy-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,47 @@ runs:
run: |
access_url=$(terraform -chdir=terraform/application output -json urls | jq -r '.[0]')
echo "ACCESS_URL=$access_url" >> $GITHUB_OUTPUT
check_url=$(terraform -chdir=terraform/application output -json urls | jq -r '.[1]')
echo "CHECK_URL=$check_url" >> $GITHUB_OUTPUT
access_external_domain=$(terraform -chdir=terraform/application output -raw local.access_external_domain 2>/dev/null || echo "")
check_external_domain=$(terraform -chdir=terraform/application output -raw local.check_external_domain 2>/dev/null || echo "")
echo "ACCESS_EXTERNAL_DOMAIN=$access_external_domain" >> $GITHUB_OUTPUT
echo "CHECK_EXTERNAL_DOMAIN=$check_external_domain" >> $GITHUB_OUTPUT
- name: Run smoke tests
shell: bash
run: |
# Parse the JSON array of URLs into a Bash array
urls=$(echo "$HOSTNAMES" | jq -r '.[]')
# Parse the JSON array of internal URLs into a Bash array
internal_urls=$(terraform -chdir=terraform/application output -json urls | jq -r '.[]')
# Get the external domains
access_external_domain="${{ steps.set_outputs.outputs.ACCESS_EXTERNAL_DOMAIN }}"
check_external_domain="${{ steps.set_outputs.outputs.CHECK_EXTERNAL_DOMAIN }}"
echo "Internal URLs:"
echo "$internal_urls"
# Loop over each URL and perform the curl check on the /health/all.json endpoint
for url in $urls; do
# Function to perform health check
perform_health_check() {
local url="$1"
echo "Check health for $url..."
curl -sS --fail "$url" > /dev/null && echo "Health check passed for $url" || echo "Health check failed for $url"
echo "Check health for $url/health/all.json..."
curl -sS --fail "$url/health/all.json" > /dev/null && echo "Health check passed for $url" || echo "Health check failed for $url"
curl -sS --fail "$url/health/all.json" > /dev/null && echo "Health check passed for $url/health/all.json" || echo "Health check failed for $url/health/all.json"
}
# Loop over each internal URL and perform the health checks
for url in $internal_urls; do
perform_health_check "$url"
done
# Perform health checks on external domains if they exist
if [ -n "$access_external_domain" ] && [ -n "$check_external_domain" ]; then
echo "Access External Domain: $access_external_domain"
echo "Check External Domain: $check_external_domain"
perform_health_check "https://$access_external_domain"
perform_health_check "https://$check_external_domain"
else
echo "External domains not available. Skipping external health checks."
fi

0 comments on commit 6b1bda5

Please sign in to comment.