Skip to content

Commit 998ae73

Browse files
authored
Fix flaky failures in PitMultiNodeIT (#18282)
Add polling to test case that can briefly return non-zero PIT stats when a PIT request is rejected. Signed-off-by: Andrew Ross <andrross@amazon.com>
1 parent fd38d23 commit 998ae73

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/internalClusterTest/java/org/opensearch/search/pit/PitMultiNodeIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ public Settings onNodeStopped(String nodeName) throws Exception {
117117
ActionFuture<CreatePitResponse> execute = client().execute(CreatePitAction.INSTANCE, request);
118118
ExecutionException ex = expectThrows(ExecutionException.class, execute::get);
119119
assertTrue(ex.getMessage().contains("Failed to execute phase [create_pit]"));
120-
validatePitStats("index", 0, 0);
120+
// If the search must make a transport call to start the search then a
121+
// PIT context may be temporarily created on a separate thread. The test
122+
// will end up racing with the PIT decrement call and can very briefly
123+
// observe non-zero PIT stats, so we poll here and wait for stats to eventually
124+
// resolve to zero. In almost all cases the first call will observe zero stats.
125+
assertBusy(() -> validatePitStats("index", 0, 0));
121126
return super.onNodeStopped(nodeName);
122127
}
123128
});

0 commit comments

Comments
 (0)