[Rust Frontend] Fix flaky `tls_handshake_timeout_drops_silent_client` test (#47873)
Signed-off-by: Tahsin Tunan <tahsintunan@gmail.com>
Tahsin Tunan committed
Jul 15, 2026 at 17:05 UTC
1b30ae4ca403588f1df37901d3b530d1fe5c48c4
2 files changed
+12
-6
rust/.config/nextest.toml
new
+3
@@ -0,0 +1,3 @@
1
+# Kill a hung test (per-test 120s budget) so a broken wait fails instead of stalling.
2
+[profile.default]
3
+slow-timeout = { period = "60s", terminate-after = 2 }
rust/src/server/src/tls_tests.rs
+9
-6
@@ -526,16 +526,19 @@ async fn tls_handshake_timeout_drops_silent_client() {
526
let (addr, shutdown) = spawn_server(Some(server_tls(&certs, 0))).await;
527
528
let mut tcp = TcpStream::connect(&addr).await.expect("connect");
529
- tokio::task::yield_now().await;
530
- tokio::time::advance(tls::TLS_HANDSHAKE_TIMEOUT + Duration::from_millis(1)).await;
531
- tokio::task::yield_now().await;
532
-
529
+ let start = tokio::time::Instant::now();
530
let mut buf = [0u8; 1];
534
- let read = tokio::time::timeout(Duration::from_secs(1), tcp.read(&mut buf)).await;
531
+ let read = tcp.read(&mut buf).await;
532
assert!(
536
- matches!(read, Ok(Ok(0)) | Ok(Err(_))),
533
+ matches!(read, Ok(0) | Err(_)),
534
"server must drop a stalled TLS handshake (expected close, got {read:?})"
535
);
536
+ // The close is the handshake deadline, not an earlier one
537
+ assert!(
538
+ start.elapsed() >= tls::TLS_HANDSHAKE_TIMEOUT,
539
+ "closed too early to be the handshake deadline: {:?}",
540
+ start.elapsed()
541
+ );
542
shutdown.cancel();
543
}
544