Skip to content

Commit

Permalink
Fix a test failure caused by random number (#1392)
Browse files Browse the repository at this point in the history
This PR should fix the test failure in testSuccessInThePresenceOfVariousErrors.
It's caused by setting Blob_Not_Found to two original DC hosts. With current change, this would be prevented.
  • Loading branch information
justinlin-linkedin authored Feb 19, 2020
1 parent 2f94c66 commit 64b257e
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,27 @@ private void doTestSuccessInThePresenceOfVariousErrors(String dcWherePutHappened
serverErrors.remove(ServerErrorCode.No_Error);
serverErrors.remove(ServerErrorCode.Blob_Authorization_Failure);
boolean goodServerMarked = false;
boolean notFoundSetInOriginalDC = false;
for (MockServer mockServer : mockServers) {
if (!goodServerMarked && mockServer.getDataCenter().equals(dcWherePutHappened)) {
mockServer.setServerErrorForAllRequests(ServerErrorCode.No_Error);
goodServerMarked = true;
ServerErrorCode code = serverErrors.get(random.nextInt(serverErrors.size()));
// make sure in the original dc, we don't set Blob_Not_Found twice.
if (mockServer.getDataCenter().equals(dcWherePutHappened)) {
if (!goodServerMarked) {
mockServer.setServerErrorForAllRequests(ServerErrorCode.No_Error);
goodServerMarked = true;
} else {
if (!notFoundSetInOriginalDC) {
mockServer.setServerErrorForAllRequests(code);
notFoundSetInOriginalDC = code == ServerErrorCode.Blob_Not_Found;
} else {
while (code == ServerErrorCode.Blob_Not_Found) {
code = serverErrors.get(random.nextInt(serverErrors.size()));
}
mockServer.setServerErrorForAllRequests(code);
}
}
} else {
mockServer.setServerErrorForAllRequests(serverErrors.get(random.nextInt(serverErrors.size())));
mockServer.setServerErrorForAllRequests(code);
}
}
getAndAssertSuccess();
Expand Down

0 comments on commit 64b257e

Please sign in to comment.