mirror of
https://github.com/openai/codex.git
synced 2026-09-11 20:36:49 +00:00
## 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
23 lines
777 B
Rust
23 lines
777 B
Rust
//! Bounded startup assertions that preserve fixture failures during teardown.
|
|
|
|
use anyhow::Result;
|
|
use std::future::Future;
|
|
use std::time::Duration;
|
|
use tokio::time::timeout;
|
|
|
|
/// Allow local configuration and state-database setup on loaded CI workers.
|
|
pub const STARTUP_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 30);
|
|
|
|
/// Fail before the caller's mock server drops and verifies downstream requests.
|
|
/// Returning an error instead would let an unmet mock expectation mask its cause.
|
|
pub async fn expect_startup<T>(startup: impl Future<Output = Result<T>>) -> T {
|
|
timeout(STARTUP_TIMEOUT, startup)
|
|
.await
|
|
.expect("test fixture startup timed out")
|
|
.expect("test fixture startup failed")
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "startup_tests.rs"]
|
|
mod tests;
|