gw-01 — Verification
One command
cd gw-01-l4-data-plane && bash scripts/verify.sh
Runs go vet, go build, and go test -race. Exits 0 and prints
=== gw-01 OK === on success.
What the tests prove
| Test | Invariant |
|---|---|
TestProxyForwards | bidirectional forwarding works; Accepted and byte counters move during the connection (proves per-write counting / live metrics) |
TestParseProxyV1 | PROXY v1 header parses; the bufio.Reader still holds the payload after the header |
TestParseProxyV1Bad | malformed PROXY headers (wrong verb, missing fields, bad family, bad IP, bad port) are rejected, not crashed on |
TestProxyProtocolEndToEnd | end-to-end: origin recovers the real client source port from the emitted PROXY header |
TestHalfClose | a client FIN propagates one direction only; the origin's reply still reaches the client (no premature teardown) |
TestGracefulDrain | on cancel, in-flight is drained (force-closed at the deadline) and new dials are refused |
All run under -race, so the connection-tracking map, WaitGroup, and
atomic counters are checked for data races.
What "green" does NOT guarantee
- No zero-copy. The data path copies through userspace; production
would
splice(2)the inspect-free path (GUIDE.md §6.2). - No real load characterization. Tests verify behavior, not
throughput; use the GUIDE.md §5 lab with
wrkfor that. - No multi-origin LB. One origin only; connection-level balancing is an exercise (GUIDE.md §9) and the L4 limit that motivates gw-02/gw-06.
- No Kubernetes drain ordering. The readiness-before-stop sequence needs a cluster (gw-09); the unit test only covers the in-process drain/force-close.
Manual checks worth doing
# force an accept-queue overflow and see ListenOverflows climb (GUIDE §5D)
# watch outbound connection churn with vs without keep-alive (GUIDE §5A)
# strace the process to confirm epoll/kqueue (no thread-per-conn) (GUIDE §5C)