Skip to content

Commit

Permalink
[Segment Replication] Wait for documents to replicate to replica shar…
Browse files Browse the repository at this point in the history
…ds (opensearch-project#4236)

* [Segment Replication] Add thread sleep to account for replica lag in delete operations test

Signed-off-by: Suraj Singh <surajrider@gmail.com>

* Address review comments, assertBusy on doc count rather than sleep

Signed-off-by: Suraj Singh <surajrider@gmail.com>

Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 authored and Rishikesh1159 committed Aug 17, 2022
1 parent f5156c9 commit 9511a89
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -293,9 +294,22 @@ public void testDeleteOperations() throws Exception {

refresh(INDEX_NAME);
waitForReplicaUpdate();

assertHitCount(client(nodeA).prepareSearch(INDEX_NAME).setSize(0).setPreference("_only_local").get(), expectedHitCount - 1);
assertHitCount(client(nodeB).prepareSearch(INDEX_NAME).setSize(0).setPreference("_only_local").get(), expectedHitCount - 1);
assertBusy(() -> {
final long nodeA_Count = client(nodeA).prepareSearch(INDEX_NAME)
.setSize(0)
.setPreference("_only_local")
.get()
.getHits()
.getTotalHits().value;
assertEquals(expectedHitCount - 1, nodeA_Count);
final long nodeB_Count = client(nodeB).prepareSearch(INDEX_NAME)
.setSize(0)
.setPreference("_only_local")
.get()
.getHits()
.getTotalHits().value;
assertEquals(expectedHitCount - 1, nodeB_Count);
}, 5, TimeUnit.SECONDS);
}
}

Expand Down

0 comments on commit 9511a89

Please sign in to comment.