Skip to content

Commit

Permalink
Fix testFollowerBehaviour (#96257) (#96269)
Browse files Browse the repository at this point in the history
The test was failing when responseDelay == leaderCheckTimeoutMillis.
This resulted in scheduling both handling the response and timeout at the same
mills and executing them in random order. The fix makes it impossible to
reply the same time as request is timeout as the behavior is not deterministic
 in such case.
  • Loading branch information
idegtiarenko committed May 23, 2023
1 parent fb243a9 commit 3445e5b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ protected void onSendRequest(long requestId, String action, TransportRequest req
super.onSendRequest(requestId, action, request, node);

final boolean mustSucceed = leaderCheckRetryCount - 1 <= consecutiveFailedRequestsCount;
final long responseDelay = randomLongBetween(0, leaderCheckTimeoutMillis + (mustSucceed ? -1 : 60000));
final long responseDelay = randomValueOtherThan(
leaderCheckTimeoutMillis,
() -> randomLongBetween(0, leaderCheckTimeoutMillis + (mustSucceed ? -1 : 60000))
);
final boolean successResponse = allResponsesFail.get() == false && (mustSucceed || randomBoolean());

if (responseDelay >= leaderCheckTimeoutMillis) {
assert responseDelay != leaderCheckTimeoutMillis;
if (responseDelay > leaderCheckTimeoutMillis) {
timeoutCount.incrementAndGet();
consecutiveFailedRequestsCount += 1;
} else if (successResponse == false) {
Expand Down

0 comments on commit 3445e5b

Please sign in to comment.