fix(tool): add retry to api compare tests#6568
Conversation
WalkthroughAdds a configurable per-test retry mechanism to API compare: Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (Compare cmd)
participant Runner as TestRunner (run_tests)
participant JoinSet as JoinSet (per-test tasks)
participant Node as External Node (Forest/Lotus)
participant Reporter as Reporter/Dump
CLI->>Runner: invoke run_tests(n_retries)
Runner->>JoinSet: spawn task per test
loop per-test retry loop
JoinSet->>Node: send RPC request
Node-->>JoinSet: response (valid/timeout/rejected)
JoinSet->>JoinSet: evaluate_test_success(response, criteria)
alt success
JoinSet-->>Runner: return success result
else failure and retries remain
JoinSet->>JoinSet: sleep (exponential backoff)
JoinSet->>Node: retry RPC request
else final failure
JoinSet-->>Runner: return final failure result
end
end
Runner->>Reporter: update report / optional dump per result
Reporter-->>Runner: ack
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/tool/subcommands/api_cmd/api_compare_tests.rs`:
- Line 3021: The loop using while let Some(Ok((success, test, test_result))) =
futures.next().await swallows task JoinError by only matching Ok and exiting on
the first Err; change the loop to match Some(res) and explicitly handle
Err(join_err) by propagating it with context (e.g., using anyhow::Context or
map_err and a descriptive message) so failed test tasks return an error instead
of terminating silently, then continue processing or return the propagated error
as appropriate from the surrounding function that manages futures.
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/tool/subcommands/api_cmd/api_compare_tests.rs (1)
2920-2939:⚠️ Potential issue | 🟡 MinorAdd a doc comment for public
run_tests(documentn_retries).
Public functions should be documented, and the new retry parameter’s semantics (retries vs total attempts) deserve a brief note.As per coding guidelines "Document all public functions and structs with doc comments".✏️ Suggested doc comment
+/// Run API comparison tests. +/// +/// `n_retries` is the number of retry attempts per test (total attempts = n_retries + 1). pub(super) async fn run_tests(
🧹 Nitpick comments (1)
src/tool/subcommands/api_cmd/api_compare_tests.rs (1)
2991-3011: Release the semaphore permit before backoff sleeps to preserve concurrency.
Holding the permit across the sleep throttles unrelated tests; drop it before sleeping so only active attempts consume slots.♻️ Suggested change
let test_result = test.run(&forest, &lotus).await; let success = evaluate_test_success(&test_result, &test, &test_criteria_overrides); if success || n_retries_left == 0 { return (success, test, test_result); } + drop(_permit); // Sleep before each retry tokio::time::sleep(Duration::from_secs(backoff_secs)).await;
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #6563
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
New Features
Improvements
Chores