Stabilize remaining Bazel timing flakes

This commit is contained in:
Joe Gershenson
2026-04-15 13:22:09 -07:00
parent c7d99c63cf
commit b0bea0225b
5 changed files with 29 additions and 7 deletions
+1 -1
View File
@@ -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"],
)
+20
View File
@@ -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 {
+1 -1
View File
@@ -186,7 +186,7 @@ async fn wait_for_subagent_notification(parent_thread: &Arc<CodexThread>) -> 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<CodexThread>, message: &str) {
@@ -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![
@@ -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,