Skip to content

Commit 9be5395

Browse files
committed
consume large uncompressed response to avoid illumos hangs
Gemini's theory: When a test case requests the /large-response endpoint but compression is disabled (either by config, lack of header, or rejection), the server attempts to write the full ~5KB JSON body to the socket. On illumos, the default TCP socket buffer size is likely smaller than on macOS/Linux, causing the server's write operation to block because the test client never reads the data to drain the buffer. When teardown() is called, the server hangs trying to finish the write during graceful shutdown, eventually timing out. The fix is to consume the response body in these tests.
1 parent 0780483 commit 9be5395

File tree

1 file changed

+21
-5
lines changed
  • dropshot/tests/integration-tests

1 file changed

+21
-5
lines changed

dropshot/tests/integration-tests/gzip.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,14 @@ async fn test_no_gzip_without_accept_encoding() {
413413
let uri = client.url("/large-response");
414414

415415
// Request without any Accept-Encoding header should not get compressed response
416-
let response = make_plain_request_response(client, &uri).await;
416+
let mut response = make_plain_request_response(client, &uri).await;
417417

418418
assert_eq!(response.headers().get(header::CONTENT_ENCODING), None);
419419

420+
// Consume the response body to avoid blocking teardown on platforms with
421+
// small socket buffers (e.g., illumos).
422+
get_response_bytes(&mut response).await;
423+
420424
testctx.teardown().await;
421425
}
422426

@@ -547,13 +551,16 @@ async fn test_reject_gzip_with_quality_zero() {
547551
.body(dropshot::Body::empty())
548552
.expect("Failed to construct request");
549553

550-
let response = client
554+
let mut response = client
551555
.make_request_with_request(request, StatusCode::OK)
552556
.await
553557
.expect("Request should succeed");
554558

555559
assert_eq!(response.headers().get(header::CONTENT_ENCODING), None);
556560

561+
// Consume response body (see test_no_gzip_without_accept_encoding).
562+
get_response_bytes(&mut response).await;
563+
557564
testctx.teardown().await;
558565
}
559566

@@ -564,7 +571,7 @@ async fn test_vary_header_is_set() {
564571

565572
// Request with Accept-Encoding: gzip
566573
let uri = client.url("/large-response");
567-
let response = get_gzip_response(client, &uri).await;
574+
let mut response = get_gzip_response(client, &uri).await;
568575

569576
// Should have Vary: Accept-Encoding header
570577
assert!(
@@ -580,6 +587,9 @@ async fn test_vary_header_is_set() {
580587
vary_value
581588
);
582589

590+
// Consume response body (see test_no_gzip_without_accept_encoding).
591+
get_response_bytes(&mut response).await;
592+
583593
testctx.teardown().await;
584594
}
585595

@@ -673,10 +683,13 @@ async fn test_compression_config_disabled() {
673683

674684
// Request WITH Accept-Encoding: gzip but compression disabled in config
675685
let uri = client.url("/large-response");
676-
let response = get_gzip_response(client, &uri).await;
686+
let mut response = get_gzip_response(client, &uri).await;
677687

678688
assert_eq!(response.headers().get(header::CONTENT_ENCODING), None);
679689

690+
// Consume response body (see test_no_gzip_without_accept_encoding).
691+
get_response_bytes(&mut response).await;
692+
680693
testctx.teardown().await;
681694
}
682695

@@ -725,7 +738,7 @@ async fn test_vary_header_on_non_gzip_requests() {
725738

726739
// Request WITHOUT Accept-Encoding: gzip for a compressible resource
727740
let uri = client.url("/large-response");
728-
let response = make_plain_request_response(client, &uri).await;
741+
let mut response = make_plain_request_response(client, &uri).await;
729742

730743
// Should NOT be compressed
731744
assert!(
@@ -747,5 +760,8 @@ async fn test_vary_header_on_non_gzip_requests() {
747760
vary_value
748761
);
749762

763+
// Consume response body (see test_no_gzip_without_accept_encoding).
764+
get_response_bytes(&mut response).await;
765+
750766
testctx.teardown().await;
751767
}

0 commit comments

Comments
 (0)