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
) (#11161)

(cherry picked from commit 2bd709b)

Signed-off-by: Neetika Singhal <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 7ff594c commit 7606cbc
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://github.com/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://github.com/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://github.com/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://github.com/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 @@ -1705,10 +1705,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 @@ -1724,6 +1720,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 @@ -1732,7 +1731,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 @@ -1769,7 +1768,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 7606cbc

Please sign in to comment.