|
| 1 | +# E2E Test Framework |
| 2 | + |
| 3 | +A comprehensive end-to-end testing framework for Semantic Router with support for multiple deployment profiles. |
| 4 | + |
| 5 | +## Architecture |
| 6 | + |
| 7 | +The framework is designed to be extensible and supports multiple test profiles: |
| 8 | + |
| 9 | +- **ai-gateway**: Tests Semantic Router with Envoy AI Gateway integration |
| 10 | +- **istio**: Tests Semantic Router with Istio Gateway (future) |
| 11 | +- **production-stack**: Tests vLLM Production Stack configurations (future) |
| 12 | +- **llm-d**: Tests with LLM-D (future) |
| 13 | +- **dynamo**: Tests with Nvidia Dynamo (future) |
| 14 | +- **aibrix**: Tests with vLLM AIBrix (future) |
| 15 | + |
| 16 | +## Directory Structure |
| 17 | + |
| 18 | +``` |
| 19 | +e2e/ |
| 20 | +├── cmd/ |
| 21 | +│ └── e2e/ # Main test runner |
| 22 | +├── pkg/ |
| 23 | +│ ├── framework/ # Core test framework |
| 24 | +│ ├── cluster/ # Kind cluster management |
| 25 | +│ ├── docker/ # Docker image operations |
| 26 | +│ ├── helm/ # Helm deployment utilities |
| 27 | +│ └── testcases/ # Test case definitions |
| 28 | +├── profiles/ |
| 29 | +│ ├── ai-gateway/ # AI Gateway test profile |
| 30 | +│ ├── istio/ # Istio test profile (future) |
| 31 | +│ └── ... |
| 32 | +└── README.md |
| 33 | +``` |
| 34 | + |
| 35 | +## Quick Start |
| 36 | + |
| 37 | +### Run all tests with default profile (ai-gateway) |
| 38 | + |
| 39 | +```bash |
| 40 | +make e2e-test |
| 41 | +``` |
| 42 | + |
| 43 | +### Run specific profile |
| 44 | + |
| 45 | +```bash |
| 46 | +make e2e-test PROFILE=ai-gateway |
| 47 | +``` |
| 48 | + |
| 49 | +### Run with custom options |
| 50 | + |
| 51 | +```bash |
| 52 | +# Keep cluster after test |
| 53 | +make e2e-test KEEP_CLUSTER=true |
| 54 | + |
| 55 | +# Use existing cluster |
| 56 | +make e2e-test USE_EXISTING_CLUSTER=true |
| 57 | + |
| 58 | +# Verbose output |
| 59 | +make e2e-test VERBOSE=true |
| 60 | +``` |
| 61 | + |
| 62 | +## Adding New Test Profiles |
| 63 | + |
| 64 | +1. Create a new directory under `profiles/` |
| 65 | +2. Implement the `Profile` interface |
| 66 | +3. Register test cases using the test case registry |
| 67 | +4. Add profile-specific deployment configurations |
| 68 | + |
| 69 | +See `profiles/ai-gateway/` for a complete example. |
| 70 | + |
| 71 | +## Test Case Registration |
| 72 | + |
| 73 | +Test cases are registered using a simple function-based approach: |
| 74 | + |
| 75 | +```go |
| 76 | +func init() { |
| 77 | + testcases.Register("my-test", testcases.TestCase{ |
| 78 | + Name: "My Test", |
| 79 | + Description: "Description of what this test does", |
| 80 | + Fn: func(ctx context.Context, client *kubernetes.Clientset) error { |
| 81 | + // Test implementation |
| 82 | + return nil |
| 83 | + }, |
| 84 | + }) |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +## Framework Features |
| 89 | + |
| 90 | +- **Automatic cluster lifecycle management**: Creates and cleans up Kind clusters |
| 91 | +- **Docker image building and loading**: Builds images and loads them into Kind |
| 92 | +- **Helm deployment automation**: Deploys required Helm charts |
| 93 | +- **Parallel test execution**: Runs independent tests in parallel |
| 94 | +- **Detailed logging**: Provides comprehensive test output |
| 95 | +- **Resource cleanup**: Ensures proper cleanup even on failures |
| 96 | + |
| 97 | +## Prerequisites |
| 98 | + |
| 99 | +Before running E2E tests, ensure you have the following tools installed: |
| 100 | + |
| 101 | +- [Go](https://golang.org/doc/install) 1.24 or later |
| 102 | +- [Docker](https://docs.docker.com/get-docker/) |
| 103 | +- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) |
| 104 | +- [kubectl](https://kubernetes.io/docs/tasks/tools/) |
| 105 | +- [Helm](https://helm.sh/docs/intro/install/) |
| 106 | + |
| 107 | +## Getting Started |
| 108 | + |
| 109 | +### 1. Install dependencies |
| 110 | + |
| 111 | +```bash |
| 112 | +make e2e-deps |
| 113 | +``` |
| 114 | + |
| 115 | +### 2. Build the E2E test binary |
| 116 | + |
| 117 | +```bash |
| 118 | +make build-e2e |
| 119 | +``` |
| 120 | + |
| 121 | +### 3. Run tests |
| 122 | + |
| 123 | +```bash |
| 124 | +# Run all tests with default profile (ai-gateway) |
| 125 | +make e2e-test |
| 126 | + |
| 127 | +# Run with verbose output |
| 128 | +make e2e-test E2E_VERBOSE=true |
| 129 | + |
| 130 | +# Run and keep cluster for debugging |
| 131 | +make e2e-test-debug |
| 132 | + |
| 133 | +# Run specific test cases |
| 134 | +make e2e-test-specific E2E_TESTS="basic-health-check,chat-completions-request" |
| 135 | +``` |
| 136 | + |
| 137 | +## CI Integration |
| 138 | + |
| 139 | +The E2E tests are automatically run in GitHub Actions on: |
| 140 | + |
| 141 | +- Pull requests to `main` branch |
| 142 | +- Pushes to `main` branch |
| 143 | + |
| 144 | +See `.github/workflows/integration-test-ai-gateway.yml` for the CI configuration. |
| 145 | + |
| 146 | +## Troubleshooting |
| 147 | + |
| 148 | +### Cluster creation fails |
| 149 | + |
| 150 | +```bash |
| 151 | +# Clean up any existing cluster |
| 152 | +make e2e-cleanup |
| 153 | + |
| 154 | +# Try again |
| 155 | +make e2e-test |
| 156 | +``` |
| 157 | + |
| 158 | +### Tests fail with timeout |
| 159 | + |
| 160 | +Increase the timeout in the test case or check if the cluster has enough resources: |
| 161 | + |
| 162 | +```bash |
| 163 | +# Check cluster status |
| 164 | +kubectl get nodes |
| 165 | +kubectl get pods --all-namespaces |
| 166 | +``` |
| 167 | + |
| 168 | +### Port forward fails |
| 169 | + |
| 170 | +Make sure no other process is using port 8080: |
| 171 | + |
| 172 | +```bash |
| 173 | +# Check what's using port 8080 |
| 174 | +lsof -i :8080 |
| 175 | + |
| 176 | +# Kill the process if needed |
| 177 | +kill -9 <PID> |
| 178 | +``` |
| 179 | + |
| 180 | +## Development |
| 181 | + |
| 182 | +### Adding a new test case |
| 183 | + |
| 184 | +1. Create a new test function in `profiles/<profile>/testcases.go` |
| 185 | +2. Register it in the `init()` function |
| 186 | +3. Add the test case name to the profile's `GetTestCases()` method |
| 187 | + |
| 188 | +Example: |
| 189 | + |
| 190 | +```go |
| 191 | +func init() { |
| 192 | + testcases.Register("my-new-test", testcases.TestCase{ |
| 193 | + Description: "My new test description", |
| 194 | + Tags: []string{"ai-gateway", "functional"}, |
| 195 | + Fn: testMyNewFeature, |
| 196 | + }) |
| 197 | +} |
| 198 | + |
| 199 | +func testMyNewFeature(ctx context.Context, client *kubernetes.Clientset, opts testcases.TestCaseOptions) error { |
| 200 | + // Test implementation |
| 201 | + return nil |
| 202 | +} |
| 203 | +``` |
| 204 | + |
| 205 | +### Adding a new profile |
| 206 | + |
| 207 | +1. Create a new directory under `profiles/` |
| 208 | +2. Implement the `Profile` interface |
| 209 | +3. Register test cases |
| 210 | +4. Update `cmd/e2e/main.go` to include the new profile |
| 211 | + |
| 212 | +See `profiles/ai-gateway/` for a complete example. |
0 commit comments