From fbf6c687fe73f84aedf2a8426f1a2ff897fa07c8 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Fri, 22 May 2026 17:15:45 -0700 Subject: [PATCH] codex: fix CI failure on PR #24142 --- .../app-server/tests/suite/v2/analytics.rs | 5 +- .../tests/suite/v2/plugin_install.rs | 80 +++++++------------ .../tests/suite/v2/plugin_uninstall.rs | 46 +++++------ 3 files changed, 51 insertions(+), 80 deletions(-) diff --git a/codex-rs/app-server/tests/suite/v2/analytics.rs b/codex-rs/app-server/tests/suite/v2/analytics.rs index c4a48f8caf..06adf862b9 100644 --- a/codex-rs/app-server/tests/suite/v2/analytics.rs +++ b/codex-rs/app-server/tests/suite/v2/analytics.rs @@ -111,7 +111,10 @@ pub(crate) async fn wait_for_analytics_event( }; for request in &requests { if request.method != "POST" - || request.url.path() != "/codex/analytics-events/events" + || !request + .url + .path() + .ends_with("/codex/analytics-events/events") { continue; } diff --git a/codex-rs/app-server/tests/suite/v2/plugin_install.rs b/codex-rs/app-server/tests/suite/v2/plugin_install.rs index 9d17e8747f..bd80ce4a3a 100644 --- a/codex-rs/app-server/tests/suite/v2/plugin_install.rs +++ b/codex-rs/app-server/tests/suite/v2/plugin_install.rs @@ -58,6 +58,8 @@ use wiremock::matchers::method; use wiremock::matchers::path; use wiremock::matchers::query_param; +use super::analytics::wait_for_analytics_event; + // Plugin install tests wait on connector discovery after the install response path // starts, which is noticeably slower on Windows CI. const DEFAULT_TIMEOUT: Duration = Duration::from_secs(60); @@ -727,22 +729,22 @@ async fn plugin_install_tracks_analytics_event() -> Result<()> { let response: PluginInstallResponse = to_response(response)?; assert_eq!(response.apps_needing_auth, Vec::::new()); - let payload = wait_for_plugin_analytics_payload(&analytics_server).await?; + let event = + wait_for_analytics_event(&analytics_server, DEFAULT_TIMEOUT, "codex_plugin_installed") + .await?; assert_eq!( - payload, + event, json!({ - "events": [{ - "event_type": "codex_plugin_installed", - "event_params": { - "plugin_id": "sample-plugin@debug", - "plugin_name": "sample-plugin", - "marketplace_name": "debug", - "has_skills": false, - "mcp_server_count": 0, - "connector_ids": [], - "product_client_id": DEFAULT_CLIENT_NAME, - } - }] + "event_type": "codex_plugin_installed", + "event_params": { + "plugin_id": "sample-plugin@debug", + "plugin_name": "sample-plugin", + "marketplace_name": "debug", + "has_skills": false, + "mcp_server_count": 0, + "connector_ids": [], + "product_client_id": DEFAULT_CLIENT_NAME, + } }) ); Ok(()) @@ -780,22 +782,21 @@ async fn plugin_install_tracks_remote_plugin_analytics_event() -> Result<()> { let response: PluginInstallResponse = to_response(response)?; assert_eq!(response.apps_needing_auth, Vec::::new()); - let payload = wait_for_plugin_analytics_payload(&server).await?; + let event = + wait_for_analytics_event(&server, DEFAULT_TIMEOUT, "codex_plugin_installed").await?; assert_eq!( - payload, + event, json!({ - "events": [{ - "event_type": "codex_plugin_installed", - "event_params": { - "plugin_id": REMOTE_PLUGIN_ID, - "plugin_name": "linear", - "marketplace_name": "openai-curated-remote", - "has_skills": true, - "mcp_server_count": 0, - "connector_ids": [], - "product_client_id": DEFAULT_CLIENT_NAME, - } - }] + "event_type": "codex_plugin_installed", + "event_params": { + "plugin_id": REMOTE_PLUGIN_ID, + "plugin_name": "linear", + "marketplace_name": "openai-curated-remote", + "has_skills": true, + "mcp_server_count": 0, + "connector_ids": [], + "product_client_id": DEFAULT_CLIENT_NAME, + } }) ); Ok(()) @@ -1288,29 +1289,6 @@ async fn mount_backend_analytics_events(server: &MockServer) { .await; } -async fn wait_for_plugin_analytics_payload(server: &MockServer) -> Result { - timeout(DEFAULT_TIMEOUT, async { - loop { - let Some(requests) = server.received_requests().await else { - tokio::time::sleep(Duration::from_millis(25)).await; - continue; - }; - if let Some(request) = requests.iter().find(|request| { - request.method == "POST" - && request - .url - .path() - .ends_with("/codex/analytics-events/events") - }) { - return serde_json::from_slice(&request.body) - .map_err(|err| anyhow::anyhow!("invalid analytics payload: {err}")); - } - tokio::time::sleep(Duration::from_millis(25)).await; - } - }) - .await? -} - fn write_remote_plugin_catalog_config( codex_home: &std::path::Path, base_url: &str, diff --git a/codex-rs/app-server/tests/suite/v2/plugin_uninstall.rs b/codex-rs/app-server/tests/suite/v2/plugin_uninstall.rs index 4feede934d..5256dec571 100644 --- a/codex-rs/app-server/tests/suite/v2/plugin_uninstall.rs +++ b/codex-rs/app-server/tests/suite/v2/plugin_uninstall.rs @@ -24,6 +24,8 @@ use wiremock::matchers::header; use wiremock::matchers::method; use wiremock::matchers::path; +use super::analytics::wait_for_analytics_event; + const DEFAULT_TIMEOUT: Duration = Duration::from_secs(10); const REMOTE_PLUGIN_ID: &str = "plugins~Plugin_linear"; const WORKSPACE_REMOTE_PLUGIN_ID: &str = "plugins_69f27c3e67848191a45cbaa5f2adb39d"; @@ -116,37 +118,25 @@ async fn plugin_uninstall_tracks_analytics_event() -> Result<()> { let response: PluginUninstallResponse = to_response(response)?; assert_eq!(response, PluginUninstallResponse {}); - let payload = timeout(DEFAULT_TIMEOUT, async { - loop { - let Some(requests) = analytics_server.received_requests().await else { - tokio::time::sleep(Duration::from_millis(25)).await; - continue; - }; - if let Some(request) = requests.iter().find(|request| { - request.method == "POST" && request.url.path() == "/codex/analytics-events/events" - }) { - break request.body.clone(); - } - tokio::time::sleep(Duration::from_millis(25)).await; - } - }) + let event = wait_for_analytics_event( + &analytics_server, + DEFAULT_TIMEOUT, + "codex_plugin_uninstalled", + ) .await?; - let payload: serde_json::Value = serde_json::from_slice(&payload).expect("analytics payload"); assert_eq!( - payload, + event, json!({ - "events": [{ - "event_type": "codex_plugin_uninstalled", - "event_params": { - "plugin_id": "sample-plugin@debug", - "plugin_name": "sample-plugin", - "marketplace_name": "debug", - "has_skills": false, - "mcp_server_count": 0, - "connector_ids": [], - "product_client_id": DEFAULT_CLIENT_NAME, - } - }] + "event_type": "codex_plugin_uninstalled", + "event_params": { + "plugin_id": "sample-plugin@debug", + "plugin_name": "sample-plugin", + "marketplace_name": "debug", + "has_skills": false, + "mcp_server_count": 0, + "connector_ids": [], + "product_client_id": DEFAULT_CLIENT_NAME, + } }) ); Ok(())