From 778b106023569157778d0258247b6f1d30587603 Mon Sep 17 00:00:00 2001 From: elky Date: Tue, 30 Jun 2026 18:42:57 +0800 Subject: [PATCH] test: stabilize gateway nextest timing --- .../src/tests/ai_execute/stream/decision.rs | 21 ++++++++++++++++--- .../src/tests/ai_execute/sync/cli.rs | 4 ++-- .../src/tests/video/registry_poller.rs | 8 +++---- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/apps/aether-gateway/src/tests/ai_execute/stream/decision.rs b/apps/aether-gateway/src/tests/ai_execute/stream/decision.rs index 7ed5e2ebf..b93d776fc 100644 --- a/apps/aether-gateway/src/tests/ai_execute/stream/decision.rs +++ b/apps/aether-gateway/src/tests/ai_execute/stream/decision.rs @@ -2373,12 +2373,27 @@ async fn gateway_retries_next_local_openai_chat_stream_candidate_after_retryable assert_eq!(stored_candidates.len(), 2); let failed_candidate = stored_candidates .iter() - .find(|candidate| candidate.candidate_index == 0) - .expect("primary failed candidate should be stored"); + .find(|candidate| { + candidate.status == RequestCandidateStatus::Failed && candidate.status_code == Some(429) + }) + .expect("retryable 429 failed candidate should be stored"); let success_candidate = stored_candidates .iter() - .find(|candidate| candidate.candidate_index == 1) + .find(|candidate| { + candidate.status == RequestCandidateStatus::Success + && candidate.status_code == Some(200) + }) .expect("backup success candidate should be stored"); + assert_ne!( + ( + failed_candidate.candidate_index, + failed_candidate.retry_index + ), + ( + success_candidate.candidate_index, + success_candidate.retry_index + ) + ); assert_eq!(failed_candidate.status, RequestCandidateStatus::Failed); assert_eq!(failed_candidate.status_code, Some(429)); assert_eq!( diff --git a/apps/aether-gateway/src/tests/ai_execute/sync/cli.rs b/apps/aether-gateway/src/tests/ai_execute/sync/cli.rs index 9a854dcbf..4377eed35 100644 --- a/apps/aether-gateway/src/tests/ai_execute/sync/cli.rs +++ b/apps/aether-gateway/src/tests/ai_execute/sync/cli.rs @@ -1257,11 +1257,11 @@ async fn gateway_executes_openai_responses_sync_after_api_key_concurrency_wait_b .await .expect("inflight request should complete") }); - wait_until(1_000, || { + wait_until(5_000, || { *execution_runtime_hits.lock().expect("mutex should lock") >= 1 }) .await; - let pending_deadline = tokio::time::Instant::now() + std::time::Duration::from_millis(1_000); + let pending_deadline = tokio::time::Instant::now() + std::time::Duration::from_millis(5_000); loop { let inflight_candidates = request_candidate_repository .list_by_request_id("trace-openai-cli-local-timeout-inflight-123") diff --git a/apps/aether-gateway/src/tests/video/registry_poller.rs b/apps/aether-gateway/src/tests/video/registry_poller.rs index c7ec0dbde..e1dfd576c 100644 --- a/apps/aether-gateway/src/tests/video/registry_poller.rs +++ b/apps/aether-gateway/src/tests/video/registry_poller.rs @@ -177,7 +177,7 @@ async fn gateway_background_video_task_poller_refreshes_due_openai_task_from_rep assert!(!background_tasks.is_empty(), "poller task should spawn"); let stored = { - let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(2); + let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(5); loop { let stored = repository .find(VideoTaskLookupKey::Id("task-local-123")) @@ -189,7 +189,7 @@ async fn gateway_background_video_task_poller_refreshes_due_openai_task_from_rep } assert!( tokio::time::Instant::now() < deadline, - "poller did not refresh task within 2s" + "poller did not refresh task within 5s" ); tokio::time::sleep(std::time::Duration::from_millis(10)).await; } @@ -284,7 +284,7 @@ async fn gateway_background_video_task_poller_refreshes_due_openai_task_from_rep assert!(!background_tasks.is_empty(), "poller task should spawn"); let stored = { - let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(2); + let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(5); loop { let stored = repository .find(VideoTaskLookupKey::Id("task-local-123")) @@ -296,7 +296,7 @@ async fn gateway_background_video_task_poller_refreshes_due_openai_task_from_rep } assert!( tokio::time::Instant::now() < deadline, - "poller did not refresh task within 2s" + "poller did not refresh task within 5s" ); tokio::time::sleep(std::time::Duration::from_millis(10)).await; }