Skip to content

Commit

Permalink
check slices and update slices
Browse files Browse the repository at this point in the history
Signed-off-by: Neetika Singhal <[email protected]>
  • Loading branch information
neetikasinghal authored and Jay Deng committed Sep 28, 2023
1 parent d656e3d commit 7dabb05
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ LeafSlice[] slicesInternal(List<LeafReaderContext> leaves, int targetMaxSlice) {
leafSlices = MaxTargetSliceSupplier.getSlices(leaves, targetMaxSlice);
logger.debug("Slice count using max target slice supplier [{}]", leafSlices.length);
}
logger.info("The length of the leaf slices is [{}]", leafSlices.length);
if (leafSlices.length == 1) {
logger.info("The length of the leaf slices is 1");
throw new RuntimeException("The length of the leaf slices is 1");
}
return leafSlices;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,9 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
}
}
assertThat(actualErrors, emptyIterable());

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 @@ -1659,6 +1662,27 @@ public void indexRandom(boolean forceRefresh, boolean dummyDocuments, boolean ma
}
}

/*
* This method ingests bogus documents for the given indices such that multiple slices
* are formed. This is greatly useful for testing with the concurrent search use-case.
* */
public Set<List<String>> indexRandomForMultipleSlices(String... indices) {
Set<List<String>> bogusIds = new HashSet<>();
for (String index : indices) {
int slices = 2;
int numDocs = getNumShards(index).totalNumShards * slices;
while (slices-- > 0) {
for (int i = 0; i < numDocs; i++) {
String id = "bogus_doc_" + randomRealisticUnicodeOfLength(between(1, 10)) + dummmyDocIdGenerator.incrementAndGet();
client().prepareIndex().setIndex(index).setId(id).setSource("{}", MediaTypeRegistry.JSON).setRouting(id).get();
bogusIds.add(Arrays.asList(index, id));
}
refresh();
}
}
return bogusIds;
}

private final AtomicInteger dummmyDocIdGenerator = new AtomicInteger();

/** Disables an index block for the specified index */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.junit.After;
import org.junit.Before;

import static org.opensearch.search.SearchService.CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING;

/**
* Base class for running the tests with parameterization of the dynamic settings
* For any class that wants to use parameterization, use @ParametersFactory to generate
Expand Down Expand Up @@ -44,4 +46,10 @@ public void afterTests() {
dynamicSettings.keySet().forEach(settingsToUnset::putNull);
client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settingsToUnset).get();
}

public void indexRandomForConcurrentSearch(String... indices) {
if (dynamicSettings.get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING.getKey()).equals("true")) {
indexRandomForMultipleSlices(indices);
}
}
}

0 comments on commit 7dabb05

Please sign in to comment.