Skip to content

Commit 8aab8ce

Browse files
committed
ai: update serena memories
1 parent d59ccec commit 8aab8ce

File tree

4 files changed

+251
-0
lines changed

4 files changed

+251
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# InferaDB Integration Tests - Project Overview
2+
3+
## Purpose
4+
E2E test suite validating InferaDB Engine and Control services in Kubernetes. Tests run against a Tailscale-based dev environment.
5+
6+
## Tech Stack
7+
- **Language**: Rust 1.85 (2021 edition)
8+
- **Runtime**: Tokio async runtime
9+
- **HTTP Client**: reqwest (with cookies, JSON support)
10+
- **JWT**: jsonwebtoken (EdDSA/Ed25519)
11+
- **Serialization**: serde/serde_json
12+
- **Testing**: Built-in Rust test framework with tokio::test
13+
14+
## Architecture
15+
Tests use a `TestFixture` pattern that:
16+
1. Registers a test user via Control API
17+
2. Creates organization, vault, client, and certificate
18+
3. Generates JWTs signed with Ed25519 keys
19+
4. Makes authenticated requests to Engine (Access) API
20+
5. Cleans up resources on Drop
21+
22+
## Test Categories (33 total tests)
23+
| Category | Count | Focus |
24+
|-----------------|-------|-------------------------------------------|
25+
| Authentication | 7 | JWT validation, Ed25519, expiration |
26+
| Vault Isolation | 4 | Multi-tenant separation |
27+
| Cache Behavior | 4 | Hit/miss, expiration, concurrency |
28+
| Concurrency | 5 | Parallel requests, race conditions |
29+
| E2E Workflows | 2 | Registration → authorization journeys |
30+
| Management | 5 | Org suspension, client deactivation |
31+
| Resilience | 6 | Recovery, degradation, error propagation |
32+
33+
## Key Files
34+
- `integration/mod.rs` - TestFixture, TestContext, API types
35+
- `integration/auth_jwt_tests.rs` - JWT authentication tests
36+
- `integration/vault_isolation_tests.rs` - Multi-tenancy tests
37+
- `integration/cache_tests.rs` - Caching behavior tests
38+
- `integration/concurrency_tests.rs` - Parallel operation tests
39+
- `integration/e2e_workflows_tests.rs` - Full journey tests
40+
- `integration/control_integration_tests.rs` - Management tests
41+
- `integration/resilience_tests.rs` - Failure scenario tests
42+
43+
## API Endpoints
44+
Tests target a unified Tailscale endpoint (auto-discovered):
45+
- Control API: `{base}/control/v1/*`
46+
- Engine (Access) API: `{base}/access/v1/*`
47+
48+
## Environment Variables
49+
| Variable | Purpose |
50+
|-------------------|------------------------------|
51+
| `INFERADB_API_URL`| Override auto-discovered URL |
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# InferaDB Integration Tests - Style & Conventions
2+
3+
## Rust Formatting (.rustfmt.toml)
4+
- **Edition**: 2024 style
5+
- **Imports**: Group by StdExternalCrate, crate-level granularity
6+
- **Line width**: Uses MAX heuristics
7+
- **Comment width**: 100 chars, wrap/normalize enabled
8+
- **Newlines**: Unix style
9+
- **Derives**: Don't merge (each derive separate)
10+
- **Format nightly**: `cargo +nightly fmt`
11+
12+
## Code Style Patterns
13+
14+
### Test Structure
15+
```rust
16+
#[tokio::test]
17+
async fn test_descriptive_name() {
18+
// Setup
19+
let fixture = TestFixture::create().await.expect("Failed to create test fixture");
20+
21+
// Action
22+
let jwt = fixture.generate_jwt(None, &["scope"]).expect("...");
23+
let response = fixture.call_server_evaluate(&jwt, ...).await.expect("...");
24+
25+
// Assert
26+
assert_eq!(response.status(), StatusCode::OK, "context message");
27+
28+
// Cleanup
29+
fixture.cleanup().await.expect("Failed to cleanup");
30+
}
31+
```
32+
33+
### Error Handling
34+
- Use `anyhow::Result<T>` for test setup
35+
- Use `.expect("descriptive message")` for infallible operations
36+
- Use `.context("message")` for contextual errors
37+
38+
### Naming Conventions
39+
- Test functions: `test_<what>_<scenario>` (e.g., `test_jwt_with_expired_token`)
40+
- Request types: `<Entity>Request` (e.g., `CreateVaultRequest`)
41+
- Response types: `<Entity>Response` (e.g., `VaultResponse`)
42+
- Constants: `SCREAMING_SNAKE_CASE`
43+
44+
### Documentation
45+
- Module-level doc comments explain purpose
46+
- Inline comments for non-obvious logic
47+
- No docstrings on individual test functions (test name should be descriptive)
48+
49+
### Assertions
50+
- Use `assert_eq!` with failure message context
51+
- Use `assert!` with descriptive conditions
52+
- Use `assert_matches!` for pattern matching (from assert_matches crate)
53+
54+
### Imports
55+
```rust
56+
// Standard library first (handled by rustfmt)
57+
use std::{...};
58+
59+
// External crates
60+
use anyhow::{Context, Result};
61+
use reqwest::StatusCode;
62+
// etc.
63+
64+
// Crate imports
65+
use super::*; // For test modules
66+
```
67+
68+
## Clippy
69+
- All warnings treated as errors (`-D warnings`)
70+
- No `#[allow(...)]` without justification
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# InferaDB Integration Tests - Commands
2+
3+
## Prerequisites
4+
- Tailscale running: `tailscale status`
5+
- Dev environment: `inferadb dev start`
6+
7+
## Testing Commands
8+
9+
```bash
10+
# Run all tests (recommended)
11+
make test
12+
13+
# Run specific test suite
14+
make test-suite SUITE=auth_jwt
15+
make test-suite SUITE=vault_isolation
16+
make test-suite SUITE=cache
17+
make test-suite SUITE=concurrency
18+
make test-suite SUITE=e2e_workflows
19+
make test-suite SUITE=control_integration
20+
make test-suite SUITE=resilience
21+
22+
# Run single test
23+
make test-single TEST=test_valid_jwt_from_management_client
24+
25+
# Verbose output
26+
make test-verbose
27+
28+
# Direct cargo (with mise)
29+
mise exec -- cargo test --test integration -- --test-threads=1
30+
mise exec -- cargo test --test integration auth_jwt -- --nocapture
31+
```
32+
33+
## Code Quality
34+
35+
```bash
36+
# Full check (format + lint + audit)
37+
make check
38+
39+
# Individual checks
40+
make format # rustfmt (nightly)
41+
make lint # clippy with -D warnings
42+
make audit # cargo-audit
43+
make deny # cargo-deny
44+
```
45+
46+
## Setup & Maintenance
47+
48+
```bash
49+
# Initial setup
50+
make setup
51+
52+
# Clean build artifacts
53+
make clean
54+
```
55+
56+
## Environment Override
57+
58+
```bash
59+
# Use custom API URL instead of Tailscale discovery
60+
INFERADB_API_URL=http://localhost:9090 make test
61+
```
62+
63+
## Unix Utilities (Darwin)
64+
65+
```bash
66+
# Standard utilities work the same
67+
git status
68+
ls -la
69+
grep -r "pattern" .
70+
find . -name "*.rs"
71+
```
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# InferaDB Integration Tests - Task Completion Checklist
2+
3+
## Before Committing
4+
5+
### 1. Format Code
6+
```bash
7+
make format
8+
# Or: mise exec -- cargo +nightly fmt --all
9+
```
10+
11+
### 2. Run Linter
12+
```bash
13+
make lint
14+
# Or: mise exec -- cargo clippy --all-targets -- -D warnings
15+
```
16+
17+
### 3. Run Tests (if environment available)
18+
```bash
19+
make test
20+
# Tests require: Tailscale running + dev environment deployed
21+
```
22+
23+
### 4. Security Audit (if dependencies changed)
24+
```bash
25+
make audit
26+
make deny
27+
```
28+
29+
## Quick Validation
30+
```bash
31+
# Full check (format + lint + audit)
32+
make check
33+
```
34+
35+
## When Adding New Tests
36+
37+
1. Place in appropriate test module:
38+
- `auth_jwt_tests.rs` - Authentication
39+
- `vault_isolation_tests.rs` - Multi-tenancy
40+
- `cache_tests.rs` - Caching
41+
- `concurrency_tests.rs` - Parallel operations
42+
- `e2e_workflows_tests.rs` - Full journeys
43+
- `control_integration_tests.rs` - Management ops
44+
- `resilience_tests.rs` - Failure scenarios
45+
46+
2. Follow test naming: `test_<feature>_<scenario>`
47+
48+
3. Use `TestFixture::create()` for setup
49+
50+
4. Include cleanup: `fixture.cleanup().await`
51+
52+
5. Add descriptive assertion messages
53+
54+
## When Modifying mod.rs
55+
56+
- Update `TestFixture` if adding new API calls
57+
- Add new request/response types as needed
58+
- Document new public functions
59+
- Update imports if adding test modules

0 commit comments

Comments
 (0)