[Rust Frontend] Fix flaky tls_handshake_timeout_drops_silent_client test (#47873)

Signed-off-by: Tahsin Tunan <tahsintunan@gmail.com>
This commit is contained in:
Tahsin Tunan
2026-07-15 11:05:38 +00:00
committed by GitHub
parent 4e04bcbce6
commit 1b30ae4ca4
2 changed files with 12 additions and 6 deletions
+3
View File
@@ -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 }
+9 -6
View File
@@ -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;
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();
}