Skip to content

Commit

Permalink
Fix test RestStatusTests.testStatusReturnsFailureStatusWhenFailuresEx…
Browse files Browse the repository at this point in the history
…ist (opensearch-project#15011)

This test has a reproducible failure when the highest "failure" status
is 100 level. This happens because RestStatus.status treats these as OK.

Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 authored and wangdongyu.danny committed Aug 22, 2024
1 parent d99e0e0 commit e67b9e1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public void testStatusReturnsFailureStatusWhenFailuresExist() {
heapOfFailures.add(failure);
}

assertEquals(heapOfFailures.peek().status(), RestStatus.status(successfulShards, totalShards, failures));
final RestStatus status = heapOfFailures.peek().status();
// RestStatus.status will return RestStatus.OK when the highest failure code is 100 level.
final RestStatus expected = status.getStatusFamilyCode() == 1 ? RestStatus.OK : status;

assertEquals(expected, RestStatus.status(successfulShards, totalShards, failures));
}

public void testSerialization() throws IOException {
Expand Down

0 comments on commit e67b9e1

Please sign in to comment.