Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rust/.config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Kill a hung test (per-test 120s budget) so a broken wait fails instead of stalling.
[profile.default]
slow-timeout = { period = "60s", terminate-after = 2 }
15 changes: 9 additions & 6 deletions rust/src/server/src/tls_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,19 @@ async fn tls_handshake_timeout_drops_silent_client() {
let (addr, shutdown) = spawn_server(Some(server_tls(&certs, 0))).await;

let mut tcp = TcpStream::connect(&addr).await.expect("connect");
tokio::task::yield_now().await;
tokio::time::advance(tls::TLS_HANDSHAKE_TIMEOUT + Duration::from_millis(1)).await;
tokio::task::yield_now().await;

let start = tokio::time::Instant::now();
let mut buf = [0u8; 1];
let read = tokio::time::timeout(Duration::from_secs(1), tcp.read(&mut buf)).await;
let read = tcp.read(&mut buf).await;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound the read so the test can fail itself

If the TLS handshake timeout regresses or is not armed, this bare read().await has no test-local timeout and will wait forever under cargo test or any runner/profile that does not apply the new nextest slow-timeout. That turns the regression this test is meant to catch into a hung test process rather than an assertion failure; wrap the read in a Tokio timeout longer than TLS_HANDSHAKE_TIMEOUT so the test fails deterministically.

Useful? React with 👍 / 👎.

@tahsintunan tahsintunan Jul 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is covered by the slow-timeout in .config/nextest.toml, which terminates a hung test at 120s. Also, nextest is our canonical/only CI runner for the rust workspace (cargo test isn't used).

assert!(
matches!(read, Ok(Ok(0)) | Ok(Err(_))),
matches!(read, Ok(0) | Err(_)),
"server must drop a stalled TLS handshake (expected close, got {read:?})"
);
// The close is the handshake deadline, not an earlier one
assert!(
start.elapsed() >= tls::TLS_HANDSHAKE_TIMEOUT,
"closed too early to be the handshake deadline: {:?}",
start.elapsed()
);
shutdown.cancel();
}

Expand Down
Loading