Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed test cases for concurrent search #11119

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ public void testAvgMovavgDerivNPE() throws Exception {
}

refresh();
indexRandomForConcurrentSearch("movavg_npe");

SearchResponse response = client().prepareSearch("movavg_npe")
.addAggregation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,7 @@ public void testPredictWithNonEmptyBuckets() throws Exception {
.setSource(jsonBuilder().startObject().field(INTERVAL_FIELD, i).field(VALUE_FIELD2, 10).endObject())
);
}
indexRandomForConcurrentSearch("predict_non_empty");

bulkBuilder.get();
ensureSearchable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ private void buildRedIndex(int numShards) throws Exception {
client().prepareIndex("test").setId("" + i).setSource("field1", "value1").get();
}
refresh();
indexRandomForConcurrentSearch("test");

internalCluster().stopRandomDataNode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private void searchWhileCreatingIndex(boolean createIndex, int numberOfReplicas)
}
client().prepareIndex("test").setId(id).setSource("field", "test").get();
RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").get();
indexRandomForConcurrentSearch("test");
// at least one shard should be successful when refreshing
assertThat(refreshResponse.getSuccessfulShards(), greaterThanOrEqualTo(1));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {

@SuppressWarnings("unchecked")
public void testPlugin() throws Exception {
assumeFalse(
"Concurrent search case muted pending fix: https://github.com/opensearch-project/OpenSearch/issues/11112",
internalCluster().clusterService().getClusterSettings().get(CLUSTER_CONCURRENT_SEGMENT_SEARCH_SETTING)
);
client().admin()
.indices()
.prepareCreate("test")
Expand All @@ -119,6 +123,7 @@ public void testPlugin() throws Exception {
.actionGet();

client().admin().indices().prepareRefresh().get();
indexRandomForConcurrentSearch("test");

SearchResponse response = client().prepareSearch()
.setSource(new SearchSourceBuilder().ext(Collections.singletonList(new TermVectorsFetchBuilder("test"))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public void testScoreAccessWithinScript() throws Exception {
.get();
}
refresh();
indexRandomForConcurrentSearch("test");

Map<String, Object> params = new HashMap<>();
params.put("factor", randomIntBetween(2, 4));
Expand Down Expand Up @@ -368,6 +369,7 @@ public void testScoreRange() throws Exception {
}
flush();
refresh();
indexRandomForConcurrentSearch("test");
int iters = scaledRandomIntBetween(10, 20);
for (int i = 0; i < iters; ++i) {
SearchResponse searchResponse = client().prepareSearch()
Expand All @@ -390,6 +392,7 @@ public void testSeeds() throws Exception {
index("test", "type", "" + i, jsonBuilder().startObject().endObject());
}
flushAndRefresh();
indexRandomForConcurrentSearch("test");

assertNoFailures(
client().prepareSearch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public void testShapeRelations() throws Exception {

client().prepareIndex("shapes").setId("1").setSource(data, MediaTypeRegistry.JSON).get();
client().admin().indices().prepareRefresh().get();
indexRandomForConcurrentSearch("shapes");

// Point in polygon
SearchResponse result = client().prepareSearch()
Expand Down Expand Up @@ -427,6 +428,7 @@ public void testBulk() throws Exception {

client().admin().indices().prepareCreate("countries").setSettings(settings).setMapping(xContentBuilder).get();
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, xContentBuilder.contentType()).get();
indexRandomForConcurrentSearch("countries");

for (BulkItemResponse item : bulk.getItems()) {
assertFalse("unable to index data", item.isFailed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void testSimpleMoreLikeThis() throws Exception {
client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject()))
.actionGet();
client().admin().indices().refresh(refreshRequest()).actionGet();
indexRandomForConcurrentSearch("test");

logger.info("Running moreLikeThis");
SearchResponse response = client().prepareSearch()
Expand Down Expand Up @@ -155,6 +156,7 @@ public void testSimpleMoreLikeThisWithTypes() throws Exception {
client().index(indexRequest("test").id("2").source(jsonBuilder().startObject().field("text", "lucene release").endObject()))
.actionGet();
client().admin().indices().refresh(refreshRequest()).actionGet();
indexRandomForConcurrentSearch("test");

logger.info("Running moreLikeThis");
SearchResponse response = client().prepareSearch()
Expand Down Expand Up @@ -190,6 +192,7 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep
).actionGet();

client().admin().indices().refresh(refreshRequest()).actionGet();
indexRandomForConcurrentSearch("test");

SearchResponse searchResponse = client().prepareSearch()
.setQuery(
Expand Down Expand Up @@ -256,6 +259,7 @@ public void testMoreLikeThisWithAliases() throws Exception {
client().index(indexRequest("test").id("4").source(jsonBuilder().startObject().field("text", "opensearch release").endObject()))
.actionGet();
client().admin().indices().refresh(refreshRequest()).actionGet();
indexRandomForConcurrentSearch("test");

logger.info("Running moreLikeThis on index");
SearchResponse response = client().prepareSearch()
Expand Down Expand Up @@ -304,6 +308,7 @@ public void testMoreLikeThisWithAliasesInLikeDocuments() throws Exception {
client().index(indexRequest(indexName).id("3").source(jsonBuilder().startObject().field("text", "opensearch index").endObject()))
.actionGet();
refresh(indexName);
indexRandomForConcurrentSearch(indexName);

SearchResponse response = client().prepareSearch()
.setQuery(new MoreLikeThisQueryBuilder(null, new Item[] { new Item(aliasName, "1") }).minTermFreq(1).minDocFreq(1))
Expand All @@ -321,6 +326,7 @@ public void testMoreLikeThisIssue2197() throws Exception {
.get();
client().admin().indices().prepareRefresh("foo").get();
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
indexRandomForConcurrentSearch("foo");

SearchResponse response = client().prepareSearch()
.setQuery(new MoreLikeThisQueryBuilder(null, new Item[] { new Item("foo", "1") }))
Expand All @@ -344,6 +350,7 @@ public void testMoreLikeWithCustomRouting() throws Exception {
.setRouting("2")
.get();
client().admin().indices().prepareRefresh("foo").get();
indexRandomForConcurrentSearch("foo");

SearchResponse response = client().prepareSearch()
.setQuery(new MoreLikeThisQueryBuilder(null, new Item[] { new Item("foo", "1").routing("2") }))
Expand All @@ -368,6 +375,7 @@ public void testMoreLikeThisIssueRoutingNotSerialized() throws Exception {
.setRouting("4000")
.get();
client().admin().indices().prepareRefresh("foo").get();
indexRandomForConcurrentSearch("foo");
SearchResponse response = client().prepareSearch()
.setQuery(new MoreLikeThisQueryBuilder(null, new Item[] { new Item("foo", "1").routing("4000") }))
.get();
Expand Down Expand Up @@ -401,6 +409,7 @@ public void testNumericField() throws Exception {
.get();

refresh();
indexRandomForConcurrentSearch("test");

// Implicit list of fields -> ignore numeric fields
SearchResponse searchResponse = client().prepareSearch()
Expand Down Expand Up @@ -508,6 +517,7 @@ public void testMoreLikeThisWithFieldAlias() throws Exception {
index("test", "_doc", "1", "text", "lucene");
index("test", "_doc", "2", "text", "lucene release");
refresh();
indexRandomForConcurrentSearch("test");

Item item = new Item("test", "1");
QueryBuilder query = QueryBuilders.moreLikeThisQuery(new String[] { "alias" }, null, new Item[] { item })
Expand Down Expand Up @@ -548,6 +558,7 @@ public void testSimpleMoreLikeInclude() throws Exception {
.source(jsonBuilder().startObject().field("text", "Lucene has been ported to other programming languages").endObject())
).actionGet();
client().admin().indices().refresh(refreshRequest()).actionGet();
indexRandomForConcurrentSearch("test");

logger.info("Running More Like This with include true");
SearchResponse response = client().prepareSearch()
Expand Down Expand Up @@ -832,11 +843,12 @@ public void testSelectFields() throws IOException, ExecutionException, Interrupt
assertHitCount(response, 1);
}

public void testWithRouting() throws IOException {
public void testWithRouting() throws IOException, InterruptedException {
client().prepareIndex("index").setId("1").setRouting("3").setSource("text", "this is a document").get();
client().prepareIndex("index").setId("2").setRouting("1").setSource("text", "this is another document").get();
client().prepareIndex("index").setId("3").setRouting("4").setSource("text", "this is yet another document").get();
refresh("index");
indexRandomForConcurrentSearch("index");

Item item = new Item("index", "2").routing("1");
MoreLikeThisQueryBuilder moreLikeThisQueryBuilder = new MoreLikeThisQueryBuilder(
Expand Down
Loading