From e67b9e16de6b970bed3fbf2b67fd372428fe2c66 Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Tue, 30 Jul 2024 12:31:33 -0700 Subject: [PATCH] Fix test RestStatusTests.testStatusReturnsFailureStatusWhenFailuresExist (#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 --- .../src/test/java/org/opensearch/core/RestStatusTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/org/opensearch/core/RestStatusTests.java b/server/src/test/java/org/opensearch/core/RestStatusTests.java index f8dba99aa8b60..fbd238bd035d0 100644 --- a/server/src/test/java/org/opensearch/core/RestStatusTests.java +++ b/server/src/test/java/org/opensearch/core/RestStatusTests.java @@ -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 {