# Relay E2E Testing Patterns

> Salvaged from pruned branch `claude/review-test-processes-ARrKk` (commit 4197f99, 2026-02-17).
> These files are **reference patterns** for relay M4/M5 E2E testing, not active tests.

## What's here

| File | Purpose |
|------|---------|
| `virtual_network.py` | Linux network namespace infrastructure — creates isolated nodes on a virtual LAN using veth pairs and a bridge. Real kernel networking, no mocks. |
| `test_real_integration.py` | Full E2E tests: Client → LLMHosts proxy → Ollama (real inference). Exercises OpenAI and Anthropic wire formats over the virtual LAN. |
| `conftest.py` | Pytest fixtures for setting up the virtual LAN and launching Ollama + proxy in separate namespaces. |

## Architecture

```
┌──────────┐   veth    ┌──────────┐   veth    ┌──────────┐
│  node-0  │◄─────────►│  bridge   │◄─────────►│  node-1  │
│  Ollama  │           │ 10.99.0.1 │           │  Proxy   │
│ 10.99.0.2│           └──────────┘           │ 10.99.0.3│
└──────────┘                                   └──────────┘
                                                     ▲
                                                     │ veth
                                               ┌──────────┐
                                               │  node-2  │
                                               │  Client  │
                                               │ 10.99.0.4│
                                               └──────────┘
```

## When to use

Adapt these patterns for relay milestones M4 (relay server deployment) and M5 (production hardening). Replace the direct proxy→Ollama path with Client → relay_server → relay_core → proxy → Ollama to validate the full tunnel chain with real traffic.

## Requirements

- Root access (network namespaces require `CAP_NET_ADMIN`)
- `iproute2` installed
- Ollama with `qwen2.5:0.5b` pulled (small model for fast test cycles)
