This directory contains a complete Docker Compose setup for testing the HTTP Runner with a sample REST API, network simulation via Toxiproxy, and comprehensive test scenarios.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ HTTP Runner │ │ Toxiproxy │ │ Test API │
│ │ │ (Network │ │ (Go REST │
│ - Executes │────┤ Simulator) │────┤ Service) │
│ tests │ │ - Latency │ │ - Users │
│ - Metrics │ │ - Errors │ │ - Products │
│ - Reports │ │ - Timeouts │ │ - Health │
└─────────────────┘ └─────────────────┘ └─────────────────┘
- Port: 8080
- Language: Go (using only standard library)
- Features:
- User CRUD operations (
/api/users) - Product management (
/api/products) - Health check (
/health) - Slow endpoint simulation (
/api/slow) - Random error simulation (
/api/random-error) - Echo service (
/api/echo)
- User CRUD operations (
- API Port: 8474
- Proxy Port: 8081 (proxies to testapi:8080)
- Purpose: Network condition simulation
- Features:
- Latency injection
- Connection timeouts
- Error rate simulation
- Bandwidth limiting
- Purpose: Execute comprehensive tests
- Features:
- Template support with environment variables
- JavaScript scripting (pre/post request)
- Metrics collection and analysis
- Multiple report formats (HTML, JSON, CSV)
- Validation checks
- Docker and Docker Compose installed
- Git (for CI/CD integration)
# Make the script executable (if not already)
chmod +x run-tests.sh
# Run the complete test suite
./run-tests.shThis will:
- Build all services from source
- Start the test API and Toxiproxy
- Wait for services to be healthy
- Execute comprehensive tests
- Generate reports in
reports/directory - Clean up containers
# Start services only
docker-compose up --build -d testapi toxiproxy
# Run specific test file
docker-compose run --rm httprunner ./httprunner -u 3 -i 5 -f tests/e2e/comprehensive-test.http
# Run with Toxiproxy simulation
docker-compose run --rm httprunner ./httprunner -u 2 -i 3 -f tests/e2e/toxiproxy-demo.http
# View logs
docker-compose logs testapi
docker-compose logs toxiproxy
# Clean up
docker-compose down -vComplete test suite demonstrating all HTTP Runner features:
- ✅ Health checks
- ✅ CRUD operations (Users, Products)
- ✅ Template variable usage
- ✅ Pre/post request JavaScript scripting
- ✅ Metrics collection and analysis
- ✅ Validation checks with
client.check() - ✅ Global variable management
- ✅ Performance monitoring
- ✅ Error handling
Network condition simulation:
- ✅ Normal proxy operation
- ✅ Latency injection (500ms delay)
- ✅ Performance impact measurement
- ✅ Toxic management via API
The following environment variables are available in test files:
BASEURL:http://testapi:8080- Direct API accessTOXIPROXY_URL:http://toxiproxy:8081- Proxied API accessAPI_VERSION:v1- API version for templating
After running tests, check the reports/ directory for:
test-results.html: Interactive HTML report with chartstest-results.json: Structured JSON data for automationtest-results.csv: CSV format for spreadsheet analysis
The included workflow (.github/workflows/integration-test.yml) will:
- Run on push to
main,develop, orfeat/*branches - Execute the full test suite
- Upload test reports as artifacts
- Cache Docker layers for faster builds
- name: Run HTTP Runner Integration Tests
run: |
chmod +x run-tests.sh
./run-tests.sh
- name: Upload Test Reports
uses: actions/upload-artifact@v3
with:
name: http-runner-reports
path: reports/# High concurrency test
docker-compose run --rm httprunner \
./httprunner -u 50 -i 20 -d 100 -f tests/e2e/comprehensive-test.http \
--html-report reports/load-test.html
# Stress test with Toxiproxy
# 1. Start services
docker-compose up -d testapi toxiproxy
# 2. Add bandwidth limiting
curl -X POST http://localhost:8474/proxies/testapi_proxy/toxics \
-H "Content-Type: application/json" \
-d '{"name":"bandwidth","type":"bandwidth","toxicity":1.0,"attributes":{"rate":1000}}'
# 3. Run tests
docker-compose run --rm httprunner \
./httprunner -u 10 -i 50 -f tests/e2e/comprehensive-test.http# Simulate connection timeouts
curl -X POST http://localhost:8474/proxies/testapi_proxy/toxics \
-H "Content-Type: application/json" \
-d '{"name":"timeout","type":"timeout","toxicity":0.3,"attributes":{"timeout":1000}}'- Edit
testapi/main.goto add new handlers - Update
tests/e2e/comprehensive-test.httpwith new test cases - Rebuild with
docker-compose build testapi
- Create new
.httpfiles in thetests/e2e/ortests/unit/directory - Use the same format as existing files
- Reference environment variables with
{{.VARIABLE_NAME}}
Edit toxiproxy-config.json to:
- Add more proxies
- Change upstream targets
- Pre-configure toxics
# Check service health
docker-compose ps
# View logs
docker-compose logs testapi
docker-compose logs toxiproxy
# Restart services
docker-compose restart# Run with verbose logging
docker-compose run --rm httprunner \
./httprunner -u 1 -i 1 -f tests/e2e/comprehensive-test.http -v
# Check API directly
curl http://localhost:8080/health
curl http://localhost:8081/health # via proxy# Check Docker network
docker network ls
docker network inspect dockercompose-testing_test-network
# Test connectivity
docker-compose run --rm httprunner wget -O- http://testapi:8080/healthWith this setup, you should expect:
- Direct API calls: < 50ms response time
- Proxied calls: < 100ms response time
- With 500ms latency toxic: ~550ms response time
- Test suite completion: 30-60 seconds
- Memory usage: < 500MB total for all services
This test environment provides a comprehensive way to validate HTTP Runner functionality across various network conditions and API scenarios.