Skip to content

Instantly share code, notes, and snippets.

@MaTriXy
Forked from netanelavr/stress-test-prompt
Created September 6, 2025 05:32
Show Gist options
  • Save MaTriXy/a3bc0802e3a0283ccab2915493f431aa to your computer and use it in GitHub Desktop.
Save MaTriXy/a3bc0802e3a0283ccab2915493f431aa to your computer and use it in GitHub Desktop.
stress-test-prompt
# API Stress Test
Create a Bash-based stress testing suite that simulates real user interactions with
your API and measures system performance under load.
## Core Script (`api_stress_test.sh`)
- Simulate realistic user flows with sequential API calls (GET, POST, PUT, DELETE)
- DELETE requests should be executed last to clean up test data
- Support bearer token authentication and custom headers
- Base URL should be configurable
- Inject stress test identifiers (`testId`, `isStressTest=true`) into headers or payload
- Use `wget` (instead of `curl`) for compatibility with K8s/minimal containers
## Server-Side Integration
Implement middleware that:
- Detect stress test flags from headers or payload
- Add contextual data to logs (e.g., `testId`, timestamps)
- Exclude stress test requests from monitoring tools (e.g., Sentry, Langfuse)
- Support conditional logic (e.g., bypass throttling, enable mocks, suppress alerts)
## Logging
- Log each request with: timestamp, HTTP method and URL, status code, response time
- Save logs to timestamped files (`test_001.log`, etc.)
## Wrapper Script (`run_stress_tests.sh`)
- Run the core script multiple times in parallel
- Configurable total runs
- Limit maximum concurrency
- At the end, generate a summary report with:
- Total successes and failures
- Response time statistics (average, minimum, maximum)
- HTTP status code distribution
## Implementation
Build two Bash scripts:
1. `api_stress_test.sh` – runs one sequence of API calls with logging
2. `run_stress_tests.sh` – runs the first script N times concurrently and produces a summary
---
Before you start -
What additional context do you need to tailor this to our environment?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment