feat(quic): heap-sampling soak test, FD-leak canary, phantom-stream guard, loss harness

Follow-up to b8c6e080 addressing the gaps I called out in the
"is this the best we can do?" reply.

1. **Heap-sampling soak test** (`QuicHeapSoakTest`). Long-form, default-
   skipped via `-PquicSoakSeconds=N` propagated by `quic/build.gradle.kts`
   to the jvmTest task. Without the property the test early-returns with
   a printed SKIPPED line, so `./gradlew test` stays fast for CI. With
   the property, drives moq-lite-shaped peer-uni churn at ~50 streams/s
   for N seconds, samples `totalMemory - freeMemory` six times across
   the run, and fails if the post-warmup → final delta exceeds 10 MB
   (the acceptance threshold from the audio-rooms soak prompt).
   Production use: `-PquicSoakSeconds=1800` for the 30-minute soak.

2. **FD-leak canary** added to `QuicConnectionDriverLifecycleTest`. On
   Linux, samples `/proc/self/fd` size before / after the 100-session
   loop; banded at +16 entries for ambient JVM noise. macOS / Windows
   silently no-op because /proc isn't there. Catches socket / pipe
   leaks the thread-count check would miss.

3. **Phantom-stream guard.** Added `retiredStreamIdSet` (capped FIFO
   ring at 4 096 entries, ~80 s of moq-lite churn) plus
   `isStreamIdRetiredLocked` on the connection. Parser checks before
   `getOrCreatePeerStreamLocked` and drops STREAM frames the peer
   retransmits on already-retired streams. Eliminates the
   "duplicate ACK lost → peer retransmits FIN → we mint a phantom
   QuicStream" edge case I papered over in the previous commit.
   Pinned by `phantomGuardDropsRetransmitOnRetiredPeerStream`.

4. **moq-lite loss harness** (`MoqLiteLossHarnessTest`). First pass at
   soak target #5: drive 50 best-effort group streams with 5%
   uniform packet loss, assert the listener surfaces ≥ 90% with
   payloads intact and the connection stays CONNECTED. Out of scope
   here: reorder injection, latency-under-loss measurement, full
   end-to-end with a real moq-lite publisher.

Tests:
 - `QuicHeapSoakTest` — gated, validates 10MB heap acceptance band.
 - `QuicConnectionDriverLifecycleTest::repeatedSessionLifecycleDoesNotLeakThreads`
   — now also enforces /proc/self/fd bound.
 - `StreamRetirementSoakTest::phantomGuardDropsRetransmitOnRetiredPeerStream`
   — pins the duplicate-frame drop semantics.
 - `MoqLiteLossHarnessTest` — 2 cases (lossy + lossRate=0 baseline).

https://claude.ai/code/session_018KPKWRg5baX5Anf7zfEyec
This commit is contained in:
Claude
2026-05-07 22:10:27 +00:00
parent bfc983bff7
commit c65eef6927
7 changed files with 706 additions and 7 deletions
+11
View File
@@ -124,3 +124,14 @@ tasks.register<JavaExec>("interop") {
args(host, port)
systemProperty("interopTimeoutSec", timeoutSec)
}
// Long-form audio-rooms soak test. Disabled by default — `./gradlew test`
// must stay fast for CI. Opt in with `-PquicSoakSeconds=N` (e.g. 1800 for
// the 30-minute run from the soak prompt). Without the property the test
// class checks for null and skips via `Assume.assumeTrue`.
tasks.withType<Test>().configureEach {
val soakSeconds = (project.findProperty("quicSoakSeconds") as? String)
if (soakSeconds != null) {
systemProperty("quicSoakSeconds", soakSeconds)
}
}