c65eef6927
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
138 lines
4.5 KiB
Kotlin
138 lines
4.5 KiB
Kotlin
/*
|
|
* Copyright (c) 2025 Vitor Pamplona
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
* the Software without restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
* Software, and to permit persons to whom the Software is furnished to do so,
|
|
* subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
plugins {
|
|
alias(libs.plugins.kotlinMultiplatform)
|
|
alias(libs.plugins.androidKotlinMultiplatformLibrary)
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
freeCompilerArgs.add("-Xexpect-actual-classes")
|
|
}
|
|
jvm {
|
|
compilerOptions {
|
|
jvmTarget.set(JvmTarget.JVM_21)
|
|
}
|
|
}
|
|
|
|
android {
|
|
namespace = "com.vitorpamplona.quic"
|
|
compileSdk =
|
|
libs.versions.android.compileSdk
|
|
.get()
|
|
.toInt()
|
|
minSdk =
|
|
libs.versions.android.minSdk
|
|
.get()
|
|
.toInt()
|
|
|
|
compilerOptions {
|
|
jvmTarget.set(JvmTarget.JVM_21)
|
|
}
|
|
|
|
withHostTest {}
|
|
}
|
|
|
|
sourceSets {
|
|
commonMain {
|
|
dependencies {
|
|
implementation(libs.kotlin.stdlib)
|
|
implementation(libs.kotlinx.coroutines.core)
|
|
api(project(":quartz"))
|
|
}
|
|
}
|
|
|
|
commonTest {
|
|
dependencies {
|
|
implementation(libs.kotlin.test)
|
|
implementation(libs.kotlinx.coroutines.test)
|
|
}
|
|
}
|
|
|
|
val jvmAndroid =
|
|
create("jvmAndroid") {
|
|
dependsOn(commonMain.get())
|
|
}
|
|
|
|
jvmMain {
|
|
dependsOn(jvmAndroid)
|
|
}
|
|
|
|
androidMain {
|
|
dependsOn(jvmAndroid)
|
|
}
|
|
|
|
jvmTest {
|
|
dependencies {
|
|
implementation(libs.kotlin.test)
|
|
implementation(libs.kotlinx.coroutines.test)
|
|
implementation(libs.secp256k1.kmp.jni.jvm)
|
|
}
|
|
}
|
|
|
|
getByName("androidHostTest") {
|
|
dependencies {
|
|
implementation(libs.kotlin.test)
|
|
implementation(libs.kotlinx.coroutines.test)
|
|
implementation(libs.secp256k1.kmp.jni.jvm)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Run the live-interop runner against a real QUIC server. Configure target
|
|
* via -PinteropHost=… -PinteropPort=… -PinteropTimeoutSec=…
|
|
*
|
|
* Usage:
|
|
* ./gradlew :quic:interop -PinteropHost=127.0.0.1 -PinteropPort=4433
|
|
*/
|
|
tasks.register<JavaExec>("interop") {
|
|
group = "verification"
|
|
description = "Drive QuicConnection against a real QUIC server (default 127.0.0.1:4433)."
|
|
dependsOn("jvmTestClasses", "jvmJar")
|
|
classpath =
|
|
files(
|
|
tasks.named("jvmJar"),
|
|
configurations.named("jvmTestRuntimeClasspath"),
|
|
layout.buildDirectory.dir("classes/kotlin/jvm/test"),
|
|
)
|
|
mainClass.set("com.vitorpamplona.quic.interop.InteropRunnerKt")
|
|
val host = (project.findProperty("interopHost") as? String) ?: "127.0.0.1"
|
|
val port = (project.findProperty("interopPort") as? String) ?: "4433"
|
|
val timeoutSec = (project.findProperty("interopTimeoutSec") as? String) ?: "10"
|
|
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)
|
|
}
|
|
}
|