Skip to content

Commit e67b9e1

Browse files
mch2wangdongyu.danny
authored and
wangdongyu.danny
committed
Fix test RestStatusTests.testStatusReturnsFailureStatusWhenFailuresExist (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 <marc.handalian@gmail.com>
1 parent d99e0e0 commit e67b9e1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/src/test/java/org/opensearch/core/RestStatusTests.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public void testStatusReturnsFailureStatusWhenFailuresExist() {
5555
heapOfFailures.add(failure);
5656
}
5757

58-
assertEquals(heapOfFailures.peek().status(), RestStatus.status(successfulShards, totalShards, failures));
58+
final RestStatus status = heapOfFailures.peek().status();
59+
// RestStatus.status will return RestStatus.OK when the highest failure code is 100 level.
60+
final RestStatus expected = status.getStatusFamilyCode() == 1 ? RestStatus.OK : status;
61+
62+
assertEquals(expected, RestStatus.status(successfulShards, totalShards, failures));
5963
}
6064

6165
public void testSerialization() throws IOException {

0 commit comments

Comments
 (0)