Skip to content

Commit

Permalink
update index random function to fix the bogus documents deletion (#11142
Browse files Browse the repository at this point in the history
)

Signed-off-by: Neetika Singhal <[email protected]>
  • Loading branch information
neetikasinghal authored Nov 10, 2023
1 parent dcb64d8 commit 2bd709b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private Set<String> prepareData(int numShards) throws Exception {
fullExpectedIds.add(Integer.toString(i));
}
refresh();
indexRandomForConcurrentSearch("test");
return fullExpectedIds;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2013,10 +2013,6 @@ private static String randomStoreField() {
}

public void testHighlightNoMatchSize() throws IOException, InterruptedException {
assumeFalse(
"Concurrent search case muted pending fix: https:/opensearch-project/OpenSearch/issues/10900",
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
);
assertAcked(
prepareCreate("test").setMapping(
"text",
Expand Down Expand Up @@ -2128,10 +2124,6 @@ public void testHighlightNoMatchSize() throws IOException, InterruptedException
}

public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException, InterruptedException {
assumeFalse(
"Concurrent search case muted pending fix: https:/opensearch-project/OpenSearch/issues/10900",
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
);
assertAcked(
prepareCreate("test").setMapping(
"text",
Expand Down Expand Up @@ -2228,10 +2220,6 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException,
}

public void testHighlightNoMatchSizeNumberOfFragments() throws IOException, InterruptedException {
assumeFalse(
"Concurrent search case muted pending fix: https:/opensearch-project/OpenSearch/issues/10900",
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
);
assertAcked(
prepareCreate("test").setMapping(
"text",
Expand Down Expand Up @@ -3416,10 +3404,6 @@ public void testFiltersFunctionScoreQueryHighlight() throws Exception {
}

public void testHighlightQueryRewriteDatesWithNow() throws Exception {
assumeFalse(
"Concurrent search case muted pending fix: https:/opensearch-project/OpenSearch/issues/10434",
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
);
assertAcked(
client().admin()
.indices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1667,10 +1667,6 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
}
assertThat(actualErrors, emptyIterable());

if (dummyDocuments) {
bogusIds.addAll(indexRandomForMultipleSlices(indicesArray));
}

if (!bogusIds.isEmpty()) {
// delete the bogus types again - it might trigger merges or at least holes in the segments and enforces deleted docs!
for (List<String> doc : bogusIds) {
Expand All @@ -1686,6 +1682,9 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
client().admin().indices().prepareRefresh(indicesArray).setIndicesOptions(IndicesOptions.lenientExpandOpen()).get()
);
}
if (dummyDocuments) {
indexRandomForMultipleSlices(indicesArray);
}
}

/*
Expand All @@ -1694,7 +1693,7 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
* multiple slices based on segment count.
* @param indices the indices in which bogus documents should be ingested
* */
protected Set<List<String>> indexRandomForMultipleSlices(String... indices) throws InterruptedException {
protected void indexRandomForMultipleSlices(String... indices) throws InterruptedException {
Set<List<String>> bogusIds = new HashSet<>();
int refreshCount = randomIntBetween(2, 3);
for (String index : indices) {
Expand Down Expand Up @@ -1731,7 +1730,15 @@ protected Set<List<String>> indexRandomForMultipleSlices(String... indices) thro
refresh(index);
}
}
return bogusIds;
for (List<String> doc : bogusIds) {
assertEquals(
"failed to delete a dummy doc [" + doc.get(0) + "][" + doc.get(1) + "]",
DocWriteResponse.Result.DELETED,
client().prepareDelete(doc.get(0), doc.get(1)).setRouting(doc.get(1)).get().getResult()
);
}
// refresh is called to make sure the bogus docs doesn't affect the search results
refresh();
}

private final AtomicInteger dummmyDocIdGenerator = new AtomicInteger();
Expand Down

0 comments on commit 2bd709b

Please sign in to comment.