mirror of
https://github.com/openai/codex.git
synced 2026-08-23 13:09:46 +00:00
Test remote environments reported ready before selection (#37156)
## What changed - Add end-to-end coverage for a remote environment whose provisioning status is reported ready before it is selected for a turn. - Verify that `wait_for_environment` makes remote execution tools and selected capability-root context available once the transport is ready. - Update pending-environment and relay tests to cover separate materialization and readiness reporting, including deferred connection and reconnection. GitOrigin-RevId: d86d66e8f722e9bafac88b93d93e7c5244a7156e
This commit is contained in:
@@ -123,7 +123,7 @@ impl NoiseRendezvousConnectProvider for FreshBundleNoiseConnectProvider {
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn deferred_noise_environment_connects_and_reconnects_with_fresh_bundle() -> Result<()> {
|
||||
async fn pending_noise_environment_connects_and_reconnects_after_ready_report() -> Result<()> {
|
||||
let listener = TcpListener::bind("127.0.0.1:0").await?;
|
||||
let rendezvous_address = listener.local_addr()?;
|
||||
let environment_rendezvous_url =
|
||||
@@ -218,11 +218,8 @@ async fn deferred_noise_environment_connects_and_reconnects_with_fresh_bundle()
|
||||
calls: AtomicUsize::new(0),
|
||||
});
|
||||
let manager = EnvironmentManager::without_environments(http_client_factory);
|
||||
let registration = manager
|
||||
.register_deferred_noise_environment(ENVIRONMENT_ID.to_string(), provider.clone())?;
|
||||
let environment = manager
|
||||
.get_environment(ENVIRONMENT_ID)
|
||||
.context("deferred Noise environment")?;
|
||||
.materialize_pending_noise_environment(ENVIRONMENT_ID.to_string(), provider.clone())?;
|
||||
let mut connection_state = environment
|
||||
.subscribe_connection_state()
|
||||
.context("remote environment connection state")?;
|
||||
@@ -235,9 +232,21 @@ async fn deferred_noise_environment_connects_and_reconnects_with_fresh_bundle()
|
||||
path: PathUri::parse("file:///plugins/executor-plugin")?,
|
||||
},
|
||||
}];
|
||||
registration.complete(Ok(EnvironmentReadyInfo {
|
||||
selected_capability_roots: selected_capability_roots.clone(),
|
||||
}))?;
|
||||
let reported = manager
|
||||
.report_environment_provisioning_status(
|
||||
ENVIRONMENT_ID.to_string(),
|
||||
Ok(EnvironmentReadyInfo {
|
||||
selected_capability_roots: selected_capability_roots.clone(),
|
||||
}),
|
||||
provider.clone(),
|
||||
)?
|
||||
.context("ready report should apply to the pending environment")?;
|
||||
assert!(Arc::ptr_eq(&environment, &reported));
|
||||
assert_eq!(provider.calls(), 0);
|
||||
let initial_info = tokio::spawn({
|
||||
let environment = Arc::clone(&environment);
|
||||
async move { environment.info().await }
|
||||
});
|
||||
let harness_websocket = accept_websocket(&listener, "harness").await?;
|
||||
assert_eq!(
|
||||
timeout(TEST_TIMEOUT, proxy_request_rx.recv()).await?,
|
||||
@@ -248,9 +257,9 @@ async fn deferred_noise_environment_connects_and_reconnects_with_fresh_bundle()
|
||||
harness_websocket,
|
||||
Arc::new(Mutex::new(Vec::new())),
|
||||
));
|
||||
let initial_info = timeout(TEST_TIMEOUT, environment.info())
|
||||
let initial_info = timeout(TEST_TIMEOUT, initial_info)
|
||||
.await
|
||||
.context("deferred Noise environment should become ready")??;
|
||||
.context("pending Noise environment should become ready")???;
|
||||
assert_eq!(
|
||||
environment.selected_capability_roots(),
|
||||
selected_capability_roots
|
||||
@@ -292,7 +301,7 @@ async fn deferred_noise_environment_connects_and_reconnects_with_fresh_bundle()
|
||||
));
|
||||
let recovered_info = timeout(TEST_TIMEOUT, environment.info())
|
||||
.await
|
||||
.context("deferred Noise environment should reconnect")??;
|
||||
.context("pending Noise environment should reconnect")??;
|
||||
|
||||
assert_eq!(recovered_info, initial_info);
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user