From b0bea0225b9f6af5ca0bbe9f3b43a8314b51fcce Mon Sep 17 00:00:00 2001 From: Joe Gershenson Date: Wed, 15 Apr 2026 11:01:25 -0700 Subject: [PATCH] Stabilize remaining Bazel timing flakes --- codex-rs/app-server/BUILD.bazel | 2 +- codex-rs/app-server/tests/suite/auth.rs | 20 +++++++++++++++++++ codex-rs/core/src/agent/control_tests.rs | 2 +- codex-rs/mcp-server/tests/common/responses.rs | 1 + codex-rs/mcp-server/tests/suite/codex_tool.rs | 11 +++++----- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/codex-rs/app-server/BUILD.bazel b/codex-rs/app-server/BUILD.bazel index 0930670ca5..165fef218e 100644 --- a/codex-rs/app-server/BUILD.bazel +++ b/codex-rs/app-server/BUILD.bazel @@ -6,7 +6,7 @@ codex_rust_crate( integration_test_tags_extra_by_stem = { "all": ["flaky"], }, - integration_test_args = ["--test-threads=4"], + integration_test_args = ["--test-threads=2"], integration_test_timeout = "long", test_tags = ["no-sandbox"], ) diff --git a/codex-rs/app-server/tests/suite/auth.rs b/codex-rs/app-server/tests/suite/auth.rs index e6134e4802..4044c2fa92 100644 --- a/codex-rs/app-server/tests/suite/auth.rs +++ b/codex-rs/app-server/tests/suite/auth.rs @@ -17,6 +17,7 @@ use codex_login::REFRESH_TOKEN_URL_OVERRIDE_ENV_VAR; use pretty_assertions::assert_eq; use std::path::Path; use tempfile::TempDir; +use tokio::time::sleep; use tokio::time::timeout; use wiremock::Mock; use wiremock::MockServer; @@ -26,6 +27,23 @@ use wiremock::matchers::path; const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); +async fn wait_for_received_requests(server: &MockServer, expected: usize) -> Result<()> { + timeout(DEFAULT_READ_TIMEOUT, async { + loop { + let received = server + .received_requests() + .await + .map_or(0, |requests| requests.len()); + if received >= expected { + break; + } + sleep(std::time::Duration::from_millis(25)).await; + } + }) + .await?; + Ok(()) +} + fn create_config_toml_custom_provider( codex_home: &Path, requires_openai_auth: bool, @@ -373,6 +391,7 @@ async fn get_auth_status_omits_token_after_proactive_refresh_failure() -> Result ) .await?; timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??; + wait_for_received_requests(&server, 1).await?; let request_id = mcp .send_get_auth_status_request(GetAuthStatusParams { @@ -440,6 +459,7 @@ async fn get_auth_status_returns_token_after_proactive_refresh_recovery() -> Res ) .await?; timeout(DEFAULT_READ_TIMEOUT, mcp.initialize()).await??; + wait_for_received_requests(&server, 1).await?; let failed_request_id = mcp .send_get_auth_status_request(GetAuthStatusParams { diff --git a/codex-rs/core/src/agent/control_tests.rs b/codex-rs/core/src/agent/control_tests.rs index 6fc74b30e8..06184c2309 100644 --- a/codex-rs/core/src/agent/control_tests.rs +++ b/codex-rs/core/src/agent/control_tests.rs @@ -186,7 +186,7 @@ async fn wait_for_subagent_notification(parent_thread: &Arc) -> boo sleep(Duration::from_millis(25)).await; } }; - timeout(Duration::from_secs(2), wait).await.is_ok() + timeout(Duration::from_secs(30), wait).await.is_ok() } async fn persist_thread_for_tree_resume(thread: &Arc, message: &str) { diff --git a/codex-rs/mcp-server/tests/common/responses.rs b/codex-rs/mcp-server/tests/common/responses.rs index 48a575a4c6..9d93d3dec2 100644 --- a/codex-rs/mcp-server/tests/common/responses.rs +++ b/codex-rs/mcp-server/tests/common/responses.rs @@ -14,6 +14,7 @@ pub fn create_shell_command_sse_response( "command": command_str, "workdir": workdir.map(|w| w.to_string_lossy()), "timeout_ms": timeout_ms, + "login": false, }))?; let response_id = format!("resp-{call_id}"); Ok(responses::sse(vec![ diff --git a/codex-rs/mcp-server/tests/suite/codex_tool.rs b/codex-rs/mcp-server/tests/suite/codex_tool.rs index f8896864bc..7ea221932c 100644 --- a/codex-rs/mcp-server/tests/suite/codex_tool.rs +++ b/codex-rs/mcp-server/tests/suite/codex_tool.rs @@ -27,7 +27,7 @@ use mcp_test_support::create_apply_patch_sse_response; use mcp_test_support::create_final_assistant_message_sse_response; use mcp_test_support::create_mock_responses_server; use mcp_test_support::create_shell_command_sse_response; -use mcp_test_support::format_with_current_shell; +use mcp_test_support::format_with_current_shell_non_login; // Allow ample time on slower CI or under load to avoid flakes. const DEFAULT_READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20); @@ -70,8 +70,8 @@ async fn shell_command_approval_triggers_elicitation() -> anyhow::Result<()> { created_filename.to_string(), "-Force".to_string(), ], - // `powershell.exe` startup can be slow on loaded Windows CI workers - 10_000, + // `powershell.exe` startup can be slow on loaded Windows CI workers. + 30_000, ) } else { ( @@ -79,8 +79,9 @@ async fn shell_command_approval_triggers_elicitation() -> anyhow::Result<()> { 5_000, ) }; - let expected_shell_command = - format_with_current_shell(&shlex::try_join(shell_command.iter().map(String::as_str))?); + let expected_shell_command = format_with_current_shell_non_login(&shlex::try_join( + shell_command.iter().map(String::as_str), + )?); let McpHandle { process: mut mcp_process,