From 9ed0047a610aa8e4413dfb456fbf40d7b2f38644 Mon Sep 17 00:00:00 2001 From: jif Date: Thu, 13 Aug 2026 11:50:18 +0000 Subject: [PATCH] Stabilize exec-server byte-budget tests (#38362) ## What changed - Send the scripted HTTP response before queuing body deltas in the single-stream byte-budget test. - Allow 30 seconds for barrier requests in both byte-budget tests while retaining the default timeout for other operations. GitOrigin-RevId: ac65580b479d93fcbcca787f15e04c084f0aa56b --- codex-rs/exec-server/tests/http_client.rs | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/codex-rs/exec-server/tests/http_client.rs b/codex-rs/exec-server/tests/http_client.rs index b9593c2f6b..4c91a2232d 100644 --- a/codex-rs/exec-server/tests/http_client.rs +++ b/codex-rs/exec-server/tests/http_client.rs @@ -46,6 +46,7 @@ const HTTP_REQUEST_BODY_DELTA_METHOD: &str = "http/request/bodyDelta"; const INITIALIZE_METHOD: &str = "initialize"; const INITIALIZED_METHOD: &str = "initialized"; const TEST_TIMEOUT: Duration = Duration::from_secs(5); +const BYTE_BUDGET_TEST_TIMEOUT: Duration = Duration::from_secs(30); const HTTP_BODY_DELTA_CHANNEL_CAPACITY: u64 = 256; const HTTP_BODY_DELTA_BYTE_BUDGET: usize = 16 * 1024 * 1024; const OVERFLOWING_BODY_DELTA_FRAMES: u64 = 1_024; @@ -848,6 +849,16 @@ async fn http_response_body_stream_enforces_queued_byte_budget() -> Result<()> { stream_response: true, } ); + peer.write_response( + request_id, + HttpRequestResponse { + status: 200, + headers: Vec::new(), + body: Vec::new().into(), + }, + ) + .await?; + let frame_count = HTTP_BODY_DELTA_BYTE_BUDGET / MAX_HTTP_BODY_DELTA_BYTES + 1; for seq in 1..=frame_count as u64 { peer.write_body_delta(HttpRequestBodyDeltaNotification { @@ -859,15 +870,6 @@ async fn http_response_body_stream_enforces_queued_byte_budget() -> Result<()> { }) .await?; } - peer.write_response( - request_id, - HttpRequestResponse { - status: 200, - headers: Vec::new(), - body: Vec::new().into(), - }, - ) - .await?; let (barrier_request_id, barrier_params) = peer.read_http_request().await?; assert_eq!( @@ -925,7 +927,7 @@ async fn http_response_body_stream_enforces_queued_byte_budget() -> Result<()> { // Receiving this terminal notification proves the earlier byte-budget // notifications have all passed through the ordered notification handler. let (_response, mut barrier_stream) = timeout( - TEST_TIMEOUT, + BYTE_BUDGET_TEST_TIMEOUT, client.http_request_stream(HttpRequestParams { method: "GET".to_string(), url: "https://example.test/mcp/byte-budget-barrier".to_string(), @@ -1104,7 +1106,7 @@ async fn http_response_body_streams_share_queued_byte_budget() -> Result<()> { // This terminal notification is ordered after both streams contend for the // budget, so neither stream is drained before the overflow is observed. let (_response, mut barrier_stream) = timeout( - TEST_TIMEOUT, + BYTE_BUDGET_TEST_TIMEOUT, client.http_request_stream(HttpRequestParams { method: "GET".to_string(), url: "https://example.test/mcp/shared-budget-barrier".to_string(),