mirror of
https://github.com/openai/codex.git
synced 2026-11-09 16:41:37 +00:00
Harden core test fixture startup assertions (#41194)
## Why Test fixture setup can take more than five seconds on loaded CI workers, and failures returned from setup can be obscured when downstream mocks verify their expectations during teardown. ## What changed - Add a shared `expect_startup` helper with a 30-second timeout that panics on either timeout or setup failure before mock teardown runs. - Use the helper for remote-environment and unified-exec fixture setup, and allow the same startup window for the initial exec-server requests. ## Testing Add paused-time tests covering successful startup after five seconds, timeout reporting, and propagation of setup errors in the presence of unmet mocks. GitOrigin-RevId: 39db69bde2983acd023a1911a6fad106674e169a
This commit is contained in:
1 parent
56239d7a61
commit
8aea62b2d8
5 files changed
+86
-31
No files matched your search
@@ -0,0 +1,43 @@
|
||||
//! Keeps startup failures visible even when downstream mocks have unmet expectations.
|
||||
|
||||
use super::expect_startup;
|
||||
use crate::responses::ev_completed;
|
||||
use crate::responses::mount_sse_sequence;
|
||||
use crate::responses::sse;
|
||||
use crate::responses::start_mock_server;
|
||||
use anyhow::Result;
|
||||
use anyhow::anyhow;
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::future::pending;
|
||||
use std::future::ready;
|
||||
use std::time::Duration;
|
||||
use tokio::time::sleep;
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn startup_can_complete_after_five_seconds() {
|
||||
let value = expect_startup(async {
|
||||
sleep(Duration::from_secs(/*secs*/ 6)).await;
|
||||
Ok("ready")
|
||||
})
|
||||
.await;
|
||||
assert_eq!(value, "ready");
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
#[should_panic(expected = "test fixture startup timed out")]
|
||||
async fn startup_timeout_is_not_masked_by_mock_expectations() {
|
||||
let server = start_mock_server().await;
|
||||
mount_sse_sequence(&server, vec![sse(vec![ev_completed("unused")])]).await;
|
||||
|
||||
expect_startup(pending::<Result<()>>()).await;
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
#[should_panic(expected = "injected startup failure")]
|
||||
async fn startup_error_is_not_masked_by_mock_expectations() {
|
||||
let server = start_mock_server().await;
|
||||
mount_sse_sequence(&server, vec![sse(vec![ev_completed("unused")])]).await;
|
||||
let startup: Result<()> = Err(anyhow!("injected startup failure"));
|
||||
|
||||
expect_startup(ready(startup)).await;
|
||||
}
|
||||
Reference in new issue
Block a user