test: stabilize gateway nextest timing

This commit is contained in:
elky
2026-06-30 18:42:57 +08:00
parent f179ee72f9
commit 778b106023
3 changed files with 24 additions and 9 deletions
@@ -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!(
@@ -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")
@@ -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;
}