Fixes intermittent test failures in CI (#6282)

I'm seeing two tests fail intermittently in CI. This PR attempts to
address (or at least mitigate) the flakiness.

* summarize_context_three_requests_and_instructions - The test snapshots
server.received_requests() immediately after observing TaskComplete.
Because the OpenAI /v1/responses call is streamed, the HTTP request can
still be draining when that event fires, so wiremock occasionally
reports only two captured requests. Fix is to wait for async activity to
complete.
* archive_conversation_moves_rollout_into_archived_directory - times out
on a slow CI run. Mitigation is to increase timeout value from 10s to
20s.
This commit is contained in:
Eric Traut
2025-11-05 15:12:25 -06:00
committed by GitHub
parent 2ab1650d4d
commit d7953aed74
2 changed files with 10 additions and 13 deletions

View File

@@ -12,7 +12,7 @@ use std::path::Path;
use tempfile::TempDir; use tempfile::TempDir;
use tokio::time::timeout; use tokio::time::timeout;
const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20);
#[tokio::test(flavor = "multi_thread", worker_threads = 2)] #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn archive_conversation_moves_rollout_into_archived_directory() -> Result<()> { async fn archive_conversation_moves_rollout_into_archived_directory() -> Result<()> {

View File

@@ -108,19 +108,19 @@ async fn summarize_context_three_requests_and_instructions() {
let body = std::str::from_utf8(&req.body).unwrap_or(""); let body = std::str::from_utf8(&req.body).unwrap_or("");
body.contains("\"text\":\"hello world\"") && !body.contains(COMPACT_PROMPT_MARKER) body.contains("\"text\":\"hello world\"") && !body.contains(COMPACT_PROMPT_MARKER)
}; };
mount_sse_once_match(&server, first_matcher, sse1).await; let first_request_mock = mount_sse_once_match(&server, first_matcher, sse1).await;
let second_matcher = |req: &wiremock::Request| { let second_matcher = |req: &wiremock::Request| {
let body = std::str::from_utf8(&req.body).unwrap_or(""); let body = std::str::from_utf8(&req.body).unwrap_or("");
body.contains(COMPACT_PROMPT_MARKER) body.contains(COMPACT_PROMPT_MARKER)
}; };
mount_sse_once_match(&server, second_matcher, sse2).await; let second_request_mock = mount_sse_once_match(&server, second_matcher, sse2).await;
let third_matcher = |req: &wiremock::Request| { let third_matcher = |req: &wiremock::Request| {
let body = std::str::from_utf8(&req.body).unwrap_or(""); let body = std::str::from_utf8(&req.body).unwrap_or("");
body.contains(&format!("\"text\":\"{THIRD_USER_MSG}\"")) body.contains(&format!("\"text\":\"{THIRD_USER_MSG}\""))
}; };
mount_sse_once_match(&server, third_matcher, sse3).await; let third_request_mock = mount_sse_once_match(&server, third_matcher, sse3).await;
// Build config pointing to the mock server and spawn Codex. // Build config pointing to the mock server and spawn Codex.
let model_provider = ModelProviderInfo { let model_provider = ModelProviderInfo {
@@ -172,16 +172,13 @@ async fn summarize_context_three_requests_and_instructions() {
wait_for_event(&codex, |ev| matches!(ev, EventMsg::TaskComplete(_))).await; wait_for_event(&codex, |ev| matches!(ev, EventMsg::TaskComplete(_))).await;
// Inspect the three captured requests. // Inspect the three captured requests.
let requests = server.received_requests().await.unwrap(); let req1 = first_request_mock.single_request();
assert_eq!(requests.len(), 3, "expected exactly three requests"); let req2 = second_request_mock.single_request();
let req3 = third_request_mock.single_request();
let req1 = &requests[0]; let body1 = req1.body_json();
let req2 = &requests[1]; let body2 = req2.body_json();
let req3 = &requests[2]; let body3 = req3.body_json();
let body1 = req1.body_json::<serde_json::Value>().unwrap();
let body2 = req2.body_json::<serde_json::Value>().unwrap();
let body3 = req3.body_json::<serde_json::Value>().unwrap();
// Manual compact should keep the baseline developer instructions. // Manual compact should keep the baseline developer instructions.
let instr1 = body1.get("instructions").and_then(|v| v.as_str()).unwrap(); let instr1 = body1.get("instructions").and_then(|v| v.as_str()).unwrap();