Skip to content

Commit 0c14f41

Browse files
github-actions[bot]andrross
authored andcommitted
Fix PIT flaky tests (#4632)
* Fixing PIT flaky tests Signed-off-by: Bharathwaj G <bharath78910@gmail.com> (cherry picked from commit 0c80a7a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Signed-off-by: Andrew Ross <andrross@amazon.com>
1 parent 870d13d commit 0c14f41

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
134134
- Fix AbstractStringFieldDataTestCase tests to account for TotalHits lower bound ([4867](https://github.com/opensearch-project/OpenSearch/pull/4867))
135135
- [Segment Replication] Fix bug of replica shard's translog not purging on index flush when segment replication is enabled ([4975](https://github.com/opensearch-project/OpenSearch/pull/4975))
136136
- Fix bug in SlicedInputStream with zero length ([#4863](https://github.com/opensearch-project/OpenSearch/pull/4863))
137+
- Fixing PIT flaky tests ([4632](https://github.com/opensearch-project/OpenSearch/pull/4632))
137138
-
138139

139140
### Security

client/rest-high-level/src/test/java/org/opensearch/client/PitIT.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.IOException;
2525
import java.util.ArrayList;
2626
import java.util.List;
27+
import java.util.concurrent.CountDownLatch;
2728
import java.util.concurrent.TimeUnit;
2829
import java.util.stream.Collectors;
2930

@@ -71,7 +72,7 @@ public void testCreateAndDeletePit() throws IOException {
7172
assertTrue(deletePitResponse.getDeletePitResults().get(0).getPitId().equals(createPitResponse.getId()));
7273
}
7374

74-
public void testDeleteAllAndListAllPits() throws IOException {
75+
public void testDeleteAllAndListAllPits() throws IOException, InterruptedException {
7576
CreatePitRequest pitRequest = new CreatePitRequest(new TimeValue(1, TimeUnit.DAYS), true, "index");
7677
CreatePitResponse pitResponse = execute(pitRequest, highLevelClient()::createPit, highLevelClient()::createPitAsync);
7778
CreatePitResponse pitResponse1 = execute(pitRequest, highLevelClient()::createPit, highLevelClient()::createPitAsync);
@@ -90,16 +91,19 @@ public void testDeleteAllAndListAllPits() throws IOException {
9091
List<String> pits = getAllPitResponse.getPitInfos().stream().map(r -> r.getPitId()).collect(Collectors.toList());
9192
assertTrue(pits.contains(pitResponse.getId()));
9293
assertTrue(pits.contains(pitResponse1.getId()));
94+
CountDownLatch countDownLatch = new CountDownLatch(1);
9395
ActionListener<DeletePitResponse> deletePitListener = new ActionListener<>() {
9496
@Override
9597
public void onResponse(DeletePitResponse response) {
98+
countDownLatch.countDown();
9699
for (DeletePitInfo deletePitInfo : response.getDeletePitResults()) {
97100
assertTrue(deletePitInfo.isSuccessful());
98101
}
99102
}
100103

101104
@Override
102105
public void onFailure(Exception e) {
106+
countDownLatch.countDown();
103107
if (!(e instanceof OpenSearchStatusException)) {
104108
throw new AssertionError("Delete all failed");
105109
}
@@ -123,6 +127,7 @@ public void onFailure(Exception e) {
123127
};
124128
highLevelClient().getAllPitsAsync(RequestOptions.DEFAULT, getPitsListener);
125129
highLevelClient().deleteAllPitsAsync(RequestOptions.DEFAULT, deletePitListener);
130+
assertTrue(countDownLatch.await(10, TimeUnit.SECONDS));
126131
// validate no pits case
127132
getAllPitResponse = highLevelClient().getAllPits(RequestOptions.DEFAULT);
128133
assertTrue(getAllPitResponse.getPitInfos().size() == 0);

server/src/test/java/org/opensearch/search/PitMultiNodeTests.java

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public Settings onNodeStopped(String nodeName) throws Exception {
9898
ActionFuture<CreatePitResponse> execute = client().execute(CreatePitAction.INSTANCE, request);
9999
ExecutionException ex = expectThrows(ExecutionException.class, execute::get);
100100
assertTrue(ex.getMessage().contains("Failed to execute phase [create_pit]"));
101-
assertTrue(ex.getMessage().contains("Partial shards failure"));
102101
validatePitStats("index", 0, 0);
103102
return super.onNodeStopped(nodeName);
104103
}

0 commit comments

Comments
 (0)