Skip to content

fix: rate limit test udpated #5

fix: rate limit test udpated

fix: rate limit test udpated #5

name: Test Rate Limits
on:
push:
branches:
- DC-4682-rate-limit-test-fix
workflow_dispatch:
inputs:
test_count:
description: "Number of requests to make (default: 110)"
required: false
default: "110"
type: string
env:
CREATE_DB_WORKER_URL: ${{ secrets.CREATE_DB_WORKER_URL }}
CLAIM_DB_WORKER_URL: ${{ secrets.CLAIM_DB_WORKER_URL }}
jobs:
test-rate-limits:
name: Test Rate Limits
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test Create DB Worker Rate Limits
shell: bash
run: |
echo "πŸš€ Testing create-db-worker rate limits..."
TEST_COUNT="${{ github.event.inputs.test_count || '110' }}"
echo "πŸ” Making $TEST_COUNT requests to $CREATE_DB_WORKER_URL/test"
success_count=0
rate_limited_count=0
error_count=0
for i in $(seq 1 $TEST_COUNT); do
echo "Request $i/$TEST_COUNT"
response=$(curl -s -w "%{http_code}" -o /tmp/response_$i.json "$CREATE_DB_WORKER_URL/test")
status_code="${response: -3}"
if [ "$status_code" = "200" ]; then
echo " βœ… Success (200)"
((success_count++))
elif [ "$status_code" = "429" ]; then
echo " ⚠️ Rate Limited (429)"
((rate_limited_count++))
else
echo " ❌ Error ($status_code)"
((error_count++))
fi
sleep 0.1
done
echo ""
echo "πŸ“Š Create DB Worker Results:"
echo " Success: $success_count"
echo " Rate Limited: $rate_limited_count"
echo " Errors: $error_count"
echo " Total: $TEST_COUNT"
if [ "$error_count" -gt 0 ]; then
echo "❌ Exiting with error due to unexpected status codes."
exit 1
fi
- name: Test Claim DB Worker Rate Limits
shell: bash
run: |
echo "πŸš€ Testing claim-db-worker rate limits..."
TEST_COUNT="${{ github.event.inputs.test_count || '110' }}"
echo "πŸ” Making $TEST_COUNT requests to $CLAIM_DB_WORKER_URL/test"
success_count=0
rate_limited_count=0
error_count=0
for i in $(seq 1 $TEST_COUNT); do
echo "Request $i/$TEST_COUNT"
response=$(curl -s -w "%{http_code}" -o /tmp/response_$i.json "$CLAIM_DB_WORKER_URL/test")
status_code="${response: -3}"
if [ "$status_code" = "200" ]; then
echo " βœ… Success (200)"
((success_count++))
elif [ "$status_code" = "429" ]; then
echo " ⚠️ Rate Limited (429)"
((rate_limited_count++))
else
echo " ❌ Error ($status_code)"
((error_count++))
fi
sleep 0.1
done
echo ""
echo "πŸ“Š Claim DB Worker Results:"
echo " Success: $success_count"
echo " Rate Limited: $rate_limited_count"
echo " Errors: $error_count"
echo " Total: $TEST_COUNT"
if [ "$error_count" -gt 0 ]; then
echo "❌ Exiting with error due to unexpected status codes."
exit 1
fi
- name: Summary
run: |
echo "🎯 Rate Limit Testing Complete!"
echo ""
echo "Both workers have been tested with ${{ github.event.inputs.test_count || '110' }} requests each."
echo ""
echo "βœ… Expected behavior:"
echo "- Initial requests return 200 (Success)"
echo "- Remaining requests should return 429 (Rate Limited)"
echo "- Any other status codes indicate a problem"