End-to-end integration tests for the API Gateway, validating API deployment, routing, policy enforcement, and service health.
┌─────────────────────────────────────────────────────────────────────┐
│ Test Suite (Godog) │
│ ┌───────────────┐ ┌───────────────┐ ┌───────────────────────┐ │
│ │ Feature Files │ │ Step Defs │ │ Test State │ │
│ │ (Gherkin) │ │ (Go) │ │ (HTTP Client/Context) │ │
│ └───────────────┘ └───────────────┘ └───────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────┐
│ Docker Compose Environment │
│ ┌───────────────────┐ ┌─────────────────┐ ┌──────────────────┐ │
│ │ gateway-controller│ │ router │ │ policy-engine │ │
│ │ :9090 (REST) │ │ :8080 (HTTP) │ │ :9002 │ │
│ │ :18000 (xDS) │ │ :9901 (Admin) │ │ │ │
│ └───────────────────┘ └─────────────────┘ └──────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────┐ │
│ │ sample-backend │ │
│ │ :9080 │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
Components:
- Godog - BDD test framework (Go implementation of Cucumber)
- Docker Compose - Orchestrates gateway services for testing
- Coverage Collector - Gathers code coverage from instrumented binaries
- Test Reporter - Generates JSON/formatted test reports
- Go 1.25.1 or later
- Docker and Docker Compose
- Built
gateway-controller:coverageimage
# Build coverage-instrumented image and run tests
make test-all
# Or run separately:
make build-coverage-image
make testgateway/it/
├── features/ # Gherkin feature files (.feature)
│ ├── health.feature # Health check scenarios
│ └── api_deploy.feature # API deployment scenarios
├── steps/ # Reusable step definitions
│ ├── http_steps.go # HTTP request steps
│ └── assert_steps.go # Response assertion steps
├── steps_health.go # Health-specific steps
├── steps_api.go # API deployment steps
├── state.go # Test state management
├── setup.go # Docker Compose lifecycle
├── coverage.go # Coverage collection
├── reporter.go # Test reporting
├── suite_test.go # Main test entry point
├── docker-compose.test.yaml
├── Makefile
├── CONTRIBUTING.md # Guide for writing new tests
└── README.md
| Command | Description |
|---|---|
make test |
Run integration tests |
make test-postgres |
Run integration tests with Postgres backend |
make test-all |
Build coverage images + run tests |
make test-verbose |
Run tests with verbose output |
make build-coverage |
Build coverage-instrumented images |
make clean |
Remove containers, volumes, and artifacts |
make check-docker |
Verify Docker is available |
make coverage-report |
Open coverage HTML report in browser |
# Run all tests
make test-all
# Run tests with Postgres-backed gateway-controller
make test-postgres
# Run tests with an explicit compose file
COMPOSE_FILE=docker-compose.test.postgres.yaml make test
# Run with Go directly (with extended timeout for coverage builds)
COMPOSE_FILE=docker-compose.test.yaml go test -v -timeout 30m ./...
# Run specific scenario (use @tag)
COMPOSE_FILE=docker-compose.test.postgres.yaml go test -v -timeout 30m ./... -godog.tags="@wip"Note: The default Go test timeout is 10 minutes. The full integration test suite with coverage instrumentation typically takes longer to complete, so a 30-minute timeout is recommended. Note: The Postgres test compose keeps the database internal to the Docker network and does not expose a host port.
After running tests, reports are available at:
| Report | Location |
|---|---|
| Test Results (JSON) | reports/integration-test-results.json |
| Coverage Summary | coverage/integration-test-coverage.txt |
| Coverage HTML | coverage/integration-test-coverage.html |
| Coverage JSON | coverage/integration-test-coverage-report.json |
Feature: API Deployment and Invocation
Background:
Given the gateway services are running
Scenario: Deploy a simple HTTP API and invoke it successfully
When I deploy this API configuration:
"""
apiVersion: gateway.api-platform.wso2.com/v1alpha1
kind: RestApi
metadata:
name: weather-api-v1.0
spec:
displayName: Weather-API
version: v1.0
context: /weather/$version
upstream:
main:
url: http://sample-backend:9080/api/v2
operations:
- method: GET
path: /{country_code}/{city}
"""
Then the response should be successful
And I wait for 2 seconds
When I send a GET request to "http://localhost:8080/weather/v1.0/us/seattle"
Then the response should be successfulSee CONTRIBUTING.md for detailed instructions on:
- Writing feature files
- Available step definitions
- Adding new steps
- Best practices