Skip to content

Commit 9d60cd2

Browse files
committed
refactor: clean up e2e tests
1 parent e9bc18a commit 9d60cd2

17 files changed

+463
-286
lines changed

.tarpaulin.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tarpaulin Configuration for InferaDB Management API
1+
# Tarpaulin Configuration for InferaDB Integration Tests
22
# Code coverage testing configuration
33
#
44
# Usage:

AGENTS.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# InferaDB Integration Tests
22

3-
End-to-end tests validating InferaDB Server and Management API in Kubernetes.
3+
End-to-end tests validating InferaDB Engine and Control in Kubernetes.
44

55
## Quick Commands
66

@@ -31,7 +31,7 @@ cargo +nightly fmt --all
3131
| `cache_tests` | 4 | Hit/miss patterns, expiration, concurrent load |
3232
| `concurrency_tests` | 5 | Parallel requests, race conditions |
3333
| `e2e_workflows_tests` | 2 | User journeys from registration to authz |
34-
| `management_integration_tests` | 5 | Org suspension, client deactivation |
34+
| `control_integration_tests` | 5 | Org suspension, client deactivation |
3535
| `resilience_tests` | 6 | Service recovery, graceful degradation |
3636

3737
## Architecture
@@ -46,31 +46,32 @@ let fixture = TestFixture::create().await?;
4646
// Generate JWT with scopes
4747
let jwt = fixture.generate_jwt(None, &["inferadb.check"])?;
4848

49-
// Call server endpoint
49+
// Call engine endpoint
5050
let response = fixture
51-
.call_server_evaluate(&jwt, "document:1", "viewer", "user:alice")
51+
.call_engine_evaluate(&jwt, "document:1", "viewer", "user:alice")
5252
.await?;
5353

5454
fixture.cleanup().await?;
5555
```
5656

5757
### Environment Variables
5858

59-
| Variable | Default | Purpose |
60-
| -------------------- | ----------------------- | ------------------------ |
61-
| `SERVER_API_URL` | `http://localhost:8080` | InferaDB Server endpoint |
62-
| `MANAGEMENT_API_URL` | `http://localhost:8081` | Management API endpoint |
63-
| `TEST_TIMEOUT_SECS` | `30` | Per-test timeout |
59+
| Variable | Default | Purpose |
60+
| ----------------- | ------------------------------ | --------------------- |
61+
| `ENGINE_URL` | `http://inferadb-engine:8080` | Engine HTTP endpoint |
62+
| `CONTROL_URL` | `http://inferadb-control:9090` | Control HTTP endpoint |
63+
| `ENGINE_GRPC_URL` | `http://inferadb-engine:8081` | Engine gRPC endpoint |
64+
| `ENGINE_MESH_URL` | `http://inferadb-engine:8082` | Engine mesh endpoint |
6465

6566
### K8s Services
6667

6768
Tests run against services in `inferadb` namespace:
6869

69-
| Service | Port | Purpose |
70-
| -------------- | ---- | ----------------------- |
71-
| Server API | 8080 | Authorization endpoints |
72-
| Management API | 8081 | Tenant/vault management |
73-
| Metrics | 9090 | Prometheus metrics |
70+
| Service | Port | Purpose |
71+
| ------- | ---- | ----------------------- |
72+
| Engine | 8080 | Authorization endpoints |
73+
| Control | 9090 | Tenant/vault management |
74+
| Metrics | 9090 | Prometheus metrics |
7475

7576
## Writing Tests
7677

@@ -86,7 +87,7 @@ async fn test_vault_isolation() {
8687
let jwt_b = fixture.generate_jwt(Some(vault_b), &["inferadb.check"])?;
8788

8889
// Verify isolation
89-
let response = fixture.call_server_evaluate(&jwt_a, "doc:1", "view", "user:x").await?;
90+
let response = fixture.call_engine_evaluate(&jwt_a, "doc:1", "view", "user:x").await?;
9091
assert_eq!(response.status(), StatusCode::OK);
9192

9293
fixture.cleanup().await?;
@@ -99,8 +100,8 @@ async fn test_vault_isolation() {
99100
| ------------------------ | ------------------------- |
100101
| `create()` | Initialize test context |
101102
| `generate_jwt()` | Create Ed25519-signed JWT |
102-
| `call_server_evaluate()` | Call /v1/check endpoint |
103-
| `call_management_api()` | Call Management API |
103+
| `call_engine_evaluate()` | Call /v1/check endpoint |
104+
| `call_control_api()` | Call Control API |
104105
| `cleanup()` | Teardown test resources |
105106

106107
## Critical Patterns
@@ -159,7 +160,7 @@ fixture.cleanup().await.expect("cleanup failed");
159160
| --------------------- | ------------------------------------------------------------------------------------- |
160161
| Services not starting | `kubectl get pods -n inferadb && kubectl logs -n inferadb deployment/inferadb-engine` |
161162
| Port conflicts | `lsof -i :8080 -i :8081` or `make purge && make start` |
162-
| Tests timing out | Increase `TEST_TIMEOUT_SECS`, check Docker RAM (4GB+) |
163+
| Tests timing out | Check Docker RAM (4GB+ recommended), check pod logs for errors |
163164
| Connection refused | Restart port-forwarding: `make start` |
164165

165166
## Code Quality

CLAUDE.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# InferaDB Integration Tests
22

3-
End-to-end tests validating InferaDB Server and Management API in Kubernetes.
3+
End-to-end tests validating InferaDB Engine and Control in Kubernetes.
44

55
## Quick Commands
66

@@ -31,7 +31,7 @@ cargo +nightly fmt --all
3131
| `cache_tests` | 4 | Hit/miss patterns, expiration, concurrent load |
3232
| `concurrency_tests` | 5 | Parallel requests, race conditions |
3333
| `e2e_workflows_tests` | 2 | User journeys from registration to authz |
34-
| `management_integration_tests` | 5 | Org suspension, client deactivation |
34+
| `control_integration_tests` | 5 | Org suspension, client deactivation |
3535
| `resilience_tests` | 6 | Service recovery, graceful degradation |
3636

3737
## Architecture
@@ -46,31 +46,32 @@ let fixture = TestFixture::create().await?;
4646
// Generate JWT with scopes
4747
let jwt = fixture.generate_jwt(None, &["inferadb.check"])?;
4848

49-
// Call server endpoint
49+
// Call engine endpoint
5050
let response = fixture
51-
.call_server_evaluate(&jwt, "document:1", "viewer", "user:alice")
51+
.call_engine_evaluate(&jwt, "document:1", "viewer", "user:alice")
5252
.await?;
5353

5454
fixture.cleanup().await?;
5555
```
5656

5757
### Environment Variables
5858

59-
| Variable | Default | Purpose |
60-
| -------------------- | ----------------------- | ------------------------ |
61-
| `SERVER_API_URL` | `http://localhost:8080` | InferaDB Server endpoint |
62-
| `MANAGEMENT_API_URL` | `http://localhost:8081` | Management API endpoint |
63-
| `TEST_TIMEOUT_SECS` | `30` | Per-test timeout |
59+
| Variable | Default | Purpose |
60+
| ----------------- | ------------------------------ | --------------------- |
61+
| `ENGINE_URL` | `http://inferadb-engine:8080` | Engine HTTP endpoint |
62+
| `CONTROL_URL` | `http://inferadb-control:9090` | Control HTTP endpoint |
63+
| `ENGINE_GRPC_URL` | `http://inferadb-engine:8081` | Engine gRPC endpoint |
64+
| `ENGINE_MESH_URL` | `http://inferadb-engine:8082` | Engine mesh endpoint |
6465

6566
### K8s Services
6667

6768
Tests run against services in `inferadb` namespace:
6869

69-
| Service | Port | Purpose |
70-
| -------------- | ---- | ----------------------- |
71-
| Server API | 8080 | Authorization endpoints |
72-
| Management API | 8081 | Tenant/vault management |
73-
| Metrics | 9090 | Prometheus metrics |
70+
| Service | Port | Purpose |
71+
| ------- | ---- | ----------------------- |
72+
| Engine | 8080 | Authorization endpoints |
73+
| Control | 9090 | Tenant/vault management |
74+
| Metrics | 9090 | Prometheus metrics |
7475

7576
## Writing Tests
7677

@@ -86,7 +87,7 @@ async fn test_vault_isolation() {
8687
let jwt_b = fixture.generate_jwt(Some(vault_b), &["inferadb.check"])?;
8788

8889
// Verify isolation
89-
let response = fixture.call_server_evaluate(&jwt_a, "doc:1", "view", "user:x").await?;
90+
let response = fixture.call_engine_evaluate(&jwt_a, "doc:1", "view", "user:x").await?;
9091
assert_eq!(response.status(), StatusCode::OK);
9192

9293
fixture.cleanup().await?;
@@ -99,8 +100,8 @@ async fn test_vault_isolation() {
99100
| ------------------------ | ------------------------- |
100101
| `create()` | Initialize test context |
101102
| `generate_jwt()` | Create Ed25519-signed JWT |
102-
| `call_server_evaluate()` | Call /v1/check endpoint |
103-
| `call_management_api()` | Call Management API |
103+
| `call_engine_evaluate()` | Call /v1/check endpoint |
104+
| `call_control_api()` | Call Control API |
104105
| `cleanup()` | Teardown test resources |
105106

106107
## Critical Patterns
@@ -159,7 +160,7 @@ fixture.cleanup().await.expect("cleanup failed");
159160
| --------------------- | ------------------------------------------------------------------------------------- |
160161
| Services not starting | `kubectl get pods -n inferadb && kubectl logs -n inferadb deployment/inferadb-engine` |
161162
| Port conflicts | `lsof -i :8080 -i :8081` or `make purge && make start` |
162-
| Tests timing out | Increase `TEST_TIMEOUT_SECS`, check Docker RAM (4GB+) |
163+
| Tests timing out | Check Docker RAM (4GB+ recommended), check pod logs for errors |
163164
| Connection refused | Restart port-forwarding: `make start` |
164165

165166
## Code Quality

README.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# InferaDB Integration Tests
22

3-
**E2E test suite** — validates Server and Management API in Kubernetes.
3+
E2E test suite validating Engine and Control in Kubernetes.
44

55
> [!IMPORTANT]
66
> Under active development. Not production-ready.
77
88
## Quick Start
99

1010
```bash
11-
./scripts/k8s-local-start.sh # Start K8s stack
12-
./scripts/k8s-local-run-integration-tests.sh # Run tests
13-
./scripts/k8s-local-stop.sh # Stop (preserves data)
11+
make start # Start K8s stack
12+
make test # Run tests
13+
make stop # Stop (preserves data)
1414
```
1515

1616
Run specific suites:
@@ -39,39 +39,36 @@ cargo test --test integration cache
3939
| ------------------------------------ | ---------------------------- |
4040
| `k8s-local-start.sh` | Deploy stack to local K8s |
4141
| `k8s-local-stop.sh` | Stop services, preserve data |
42-
| `k8s-local-purge.sh` | Remove all resources |
4342
| `k8s-local-status.sh` | Check deployment health |
43+
| `k8s-local-update.sh` | Rebuild and redeploy images |
44+
| `k8s-local-purge.sh` | Remove all resources |
4445
| `k8s-local-run-integration-tests.sh` | Execute test suite |
4546

4647
## Environment
4748

48-
| Service | URL |
49-
| ---------- | ----------------------- |
50-
| Server | `http://localhost:8080` |
51-
| Management | `http://localhost:8081` |
52-
| Metrics | `http://localhost:9090` |
49+
Tests run inside K8s using service DNS. Override for local development:
5350

54-
| Variable | Default | Purpose |
55-
| -------------------- | ----------------------- | ------------------- |
56-
| `SERVER_API_URL` | `http://localhost:8080` | Server endpoint |
57-
| `MANAGEMENT_API_URL` | `http://localhost:8081` | Management endpoint |
58-
| `TEST_TIMEOUT_SECS` | `30` | Per-test timeout |
51+
| Variable | Default (in K8s) | Purpose |
52+
| ----------------- | ------------------------------ | --------------------- |
53+
| `CONTROL_URL` | `http://inferadb-control:9090` | Control HTTP endpoint |
54+
| `ENGINE_URL` | `http://inferadb-engine:8080` | Engine HTTP endpoint |
55+
| `ENGINE_GRPC_URL` | `http://inferadb-engine:8081` | Engine gRPC endpoint |
56+
| `ENGINE_MESH_URL` | `http://inferadb-engine:8082` | Engine mesh endpoint |
5957

6058
## Writing Tests
6159

6260
```rust
6361
#[tokio::test]
6462
async fn test_my_feature() {
65-
let fixture = TestFixture::create().await.unwrap();
63+
let fixture = TestFixture::create().await.expect("setup failed");
6664
let jwt = fixture.generate_jwt(None, &["inferadb.check"]).unwrap();
6765

6866
let response = fixture
69-
.call_server_evaluate(&jwt, "document:1", "viewer", "user:alice")
67+
.call_engine_evaluate(&jwt, "document:1", "viewer", "user:alice")
7068
.await
7169
.unwrap();
7270

7371
assert_eq!(response.status(), StatusCode::OK);
74-
fixture.cleanup().await.unwrap();
7572
}
7673
```
7774

@@ -80,8 +77,8 @@ async fn test_my_feature() {
8077
| Issue | Solution |
8178
| --------------------- | ------------------------------------------------------------------------------------- |
8279
| Services not starting | `kubectl get pods -n inferadb && kubectl logs -n inferadb deployment/inferadb-engine` |
83-
| Port in use | `./scripts/k8s-local-purge.sh && ./scripts/k8s-local-start.sh` |
84-
| Tests timing out | Increase `TEST_TIMEOUT_SECS=60`, check Docker RAM (4GB+) |
80+
| Port in use | `make purge && make start` |
81+
| Tests timing out | Check Docker RAM (4GB+ recommended), check pod logs for errors |
8582

8683
## License
8784

docker-compose.integration.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# Docker Compose for K8s Integration Tests
22
# This runs only the test runner against a local kind cluster
3-
# The server and management API are deployed in Kubernetes
4-
5-
networks:
6-
host:
7-
name: host
8-
external: true
3+
# The Engine and Control are deployed in Kubernetes
94

105
services:
116
# Test runner - Executes integration tests against K8s cluster
@@ -14,14 +9,17 @@ services:
149
context: ..
1510
dockerfile: tests/Dockerfile.integration
1611
container_name: inferadb-k8s-test-runner
17-
network_mode: host
12+
# Use bridge network so we can reach host via host.docker.internal (works on macOS/Windows)
13+
extra_hosts:
14+
- "host.docker.internal:host-gateway"
1815
environment:
1916
- RUST_LOG=debug
2017
# Connect to K8s NodePort endpoints (mapped to host ports via kind extraPortMappings)
21-
- MANAGEMENT_API_URL=http://localhost:9090
22-
- SERVER_URL=http://localhost:8080
23-
- SERVER_INTERNAL_URL=http://localhost:8082
24-
- SERVER_GRPC_URL=http://localhost:8081
18+
# Use host.docker.internal to reach the host machine from within Docker
19+
- CONTROL_URL=http://host.docker.internal:9090
20+
- ENGINE_URL=http://host.docker.internal:8080
21+
- ENGINE_MESH_URL=http://host.docker.internal:8082
22+
- ENGINE_GRPC_URL=http://host.docker.internal:8081
2523
- TEST_TIMEOUT=300
2624
volumes:
2725
- ../tests:/workspace/tests

integration/auth_jwt_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// JWT Authentication Flow Tests
22
//
3-
// Tests for validating JWT-based authentication between server and management API
3+
// Tests for validating JWT-based authentication between engine and control
44

55
use reqwest::StatusCode;
66

@@ -68,7 +68,7 @@ async fn test_jwt_for_nonexistent_vault() {
6868
.await
6969
.expect("Failed to call server");
7070

71-
// Should fail with 404 Not Found (vault doesn't exist in management API)
71+
// Should fail with 404 Not Found (vault doesn't exist in control)
7272
assert_eq!(
7373
response.status(),
7474
StatusCode::NOT_FOUND,
@@ -139,7 +139,7 @@ async fn test_jwt_with_expired_token() {
139139
// Generate JWT with past expiration (requires custom encoding)
140140
let now = Utc::now();
141141
let claims = ClientClaims {
142-
iss: fixture.ctx.management_url.clone(),
142+
iss: fixture.ctx.control_url.clone(),
143143
sub: format!("client:{}", fixture.client_id),
144144
aud: REQUIRED_AUDIENCE.to_string(),
145145
exp: (now - Duration::minutes(10)).timestamp(), // Expired 10 minutes ago
@@ -182,7 +182,7 @@ async fn test_jwt_with_invalid_kid() {
182182
// Generate JWT with fake kid
183183
let now = Utc::now();
184184
let claims = ClientClaims {
185-
iss: format!("{}/v1", fixture.ctx.management_url),
185+
iss: format!("{}/v1", fixture.ctx.control_url),
186186
sub: format!("client:{}", fixture.client_id),
187187
aud: REQUIRED_AUDIENCE.to_string(),
188188
exp: (now + Duration::minutes(5)).timestamp(),

0 commit comments

Comments
 (0)