test(agent): sync LaneDPerformanceFixesTest with MAX_RETRIES bump

This commit is contained in:
matevip 2026-05-21 14:43:52 +08:00
parent e61c9d46d3
commit 89f8413db8
2 changed files with 25 additions and 9 deletions

View File

@ -333,11 +333,22 @@ public class NodeStreamingChatHelper {
*/ */
private static final int CONTENT_REPEAT_CHECK_INTERVAL = 200; private static final int CONTENT_REPEAT_CHECK_INTERVAL = 200;
private static final int MAX_RETRIES = 10; /**
* Maximum retry attempts for SERVER_ERROR / transient network failures.
* Total LLM calls per turn = MAX_RETRIES + 1 (attempt 0 is the initial,
* attempts 1..MAX_RETRIES are the retries). Bumped from 5 to 10 in
* commit 1dd99b68 so sustained wiki batch load can ride out provider
* flaps without surfacing the error.
*
* <p>Package-private so {@code LaneDPerformanceFixesTest} can stay in
* sync without a magic number when this value changes again, the
* test follows automatically.
*/
static final int MAX_RETRIES = 10;
// RATE_LIMIT: fail fast to failover chain staying on the same // RATE_LIMIT: fail fast to failover chain staying on the same
// provider during a rate-limit window wastes time without recovery. // provider during a rate-limit window wastes time without recovery.
// SERVER_ERROR keeps MAX_RETRIES (upstream flaps often self-heal). // SERVER_ERROR keeps MAX_RETRIES (upstream flaps often self-heal).
private static final int MAX_RETRIES_RATE_LIMIT = 2; static final int MAX_RETRIES_RATE_LIMIT = 2;
private static final long BACKOFF_BASE_MS = 3000; private static final long BACKOFF_BASE_MS = 3000;
private static final long BACKOFF_CAP_MS = 60_000; private static final long BACKOFF_CAP_MS = 60_000;

View File

@ -169,7 +169,7 @@ class LaneDPerformanceFixesTest {
} }
@Test @Test
@DisplayName("SERVER_ERROR keeps full MAX_RETRIES=5 (not capped like RATE_LIMIT)") @DisplayName("SERVER_ERROR keeps full MAX_RETRIES (not capped like RATE_LIMIT)")
void serverErrorKeepsFullRetries() { void serverErrorKeepsFullRetries() {
AtomicInteger callCount = new AtomicInteger(0); AtomicInteger callCount = new AtomicInteger(0);
ChatModel model = mock(ChatModel.class); ChatModel model = mock(ChatModel.class);
@ -181,12 +181,17 @@ class LaneDPerformanceFixesTest {
var helper = helper(model); var helper = helper(model);
var result = helper.streamCall(model, smallPrompt(), "conv-d2b", "reasoning"); var result = helper.streamCall(model, smallPrompt(), "conv-d2b", "reasoning");
// SERVER_ERROR should use the full MAX_RETRIES=5 (6 total calls: attempt 0-5), // SERVER_ERROR should use the full MAX_RETRIES budget, NOT the reduced
// NOT the reduced MAX_RETRIES_RATE_LIMIT=2. // MAX_RETRIES_RATE_LIMIT=2. Total calls = MAX_RETRIES + 1 (attempt 0 +
assertTrue(callCount.get() > 3, // MAX_RETRIES retries). Reading the constant directly keeps this test
"SERVER_ERROR should retry more than RATE_LIMIT (>3 calls), but got " + callCount.get()); // in sync if MAX_RETRIES changes again last bumped 5 -> 10 in
assertEquals(6, callCount.get(), // commit 1dd99b68 to ride out provider flaps under wiki batch load.
"SERVER_ERROR should try 6 times total (attempt 0 through 5)"); int expectedCalls = NodeStreamingChatHelper.MAX_RETRIES + 1;
assertTrue(callCount.get() > NodeStreamingChatHelper.MAX_RETRIES_RATE_LIMIT + 1,
"SERVER_ERROR should retry more than RATE_LIMIT, but got " + callCount.get());
assertEquals(expectedCalls, callCount.get(),
"SERVER_ERROR should try " + expectedCalls + " times total " +
"(attempt 0 through " + NodeStreamingChatHelper.MAX_RETRIES + ")");
} }
@Test @Test