Skip to content

Commit

Permalink
Add indexRandomForConcurrentSearch method to tests: (opensearch-proje…
Browse files Browse the repository at this point in the history
…ct#11118)

* IndexStatsIT.java
* SearchTimeoutIT.java
* NaNSortingIT.java
* NestedIT.java
* RangeIT.java

Signed-off-by: Jay Deng <jayd0104@gmail.com>
  • Loading branch information
jed326 authored and Jay Deng committed Nov 14, 2023
1 parent c2b5587 commit 0539713
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private Settings.Builder settingsBuilder() {
return Settings.builder().put(indexSettings());
}

public void testFieldDataStats() {
public void testFieldDataStats() throws InterruptedException {
assertAcked(
client().admin()
.indices()
Expand All @@ -182,6 +182,7 @@ public void testFieldDataStats() {
client().prepareIndex("test").setId("1").setSource("field", "value1", "field2", "value1").execute().actionGet();
client().prepareIndex("test").setId("2").setSource("field", "value2", "field2", "value2").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
indexRandomForConcurrentSearch("test");

NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
assertThat(
Expand Down Expand Up @@ -305,6 +306,7 @@ public void testClearAllCaches() throws Exception {
client().prepareIndex("test").setId("1").setSource("field", "value1").execute().actionGet();
client().prepareIndex("test").setId("2").setSource("field", "value2").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
indexRandomForConcurrentSearch("test");

NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
assertThat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void testSimpleTimeout() throws Exception {
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value").get();
}
refresh("test");
indexRandomForConcurrentSearch("test");

SearchResponse searchResponse = client().prepareSearch("test")
.setTimeout(new TimeValue(5, TimeUnit.MILLISECONDS))
Expand All @@ -104,12 +105,11 @@ public void testSimpleTimeout() throws Exception {
}

public void testSimpleDoesNotTimeout() throws Exception {
final int numDocs = 10;
final int numDocs = 9;
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value").get();
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();
}
refresh("test");

indexRandomForConcurrentSearch("test");
SearchResponse searchResponse = client().prepareSearch("test")
.setTimeout(new TimeValue(10000, TimeUnit.SECONDS))
.setQuery(scriptQuery(new Script(ScriptType.INLINE, "mockscript", SCRIPT_NAME, Collections.emptyMap())))
Expand All @@ -122,7 +122,7 @@ public void testSimpleDoesNotTimeout() throws Exception {

public void testPartialResultsIntolerantTimeout() throws Exception {
client().prepareIndex("test").setId("1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get();

indexRandomForConcurrentSearch("test");
OpenSearchException ex = expectThrows(
OpenSearchException.class,
() -> client().prepareSearch("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public void setupSuiteScopeCluster() throws Exception {
client().prepareIndex("idx").setSource(source.endObject()).get();
}
refresh();
indexRandomForMultipleSlices("idx");
ensureSearchable();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public void setupSuiteScopeCluster() throws Exception {
)
);
indexRandom(true, builders);
indexRandomForMultipleSlices("idx");
ensureSearchable();
}

Expand Down Expand Up @@ -354,6 +355,7 @@ public void testNestedAsSubAggregation() throws Exception {
}

public void testNestNestedAggs() throws Exception {
indexRandomForConcurrentSearch("idx_nested_nested_aggs");
SearchResponse response = client().prepareSearch("idx_nested_nested_aggs")
.addAggregation(
nested("level1", "nested1").subAggregation(
Expand Down Expand Up @@ -607,6 +609,7 @@ public void testNestedSameDocIdProcessedMultipleTime() throws Exception {
)
.get();
refresh();
indexRandomForConcurrentSearch("idx4");

SearchResponse response = client().prepareSearch("idx4")
.addAggregation(
Expand Down Expand Up @@ -782,6 +785,7 @@ public void testFilterAggInsideNestedAgg() throws Exception {
)
.get();
refresh();
indexRandomForConcurrentSearch("classes");

SearchResponse response = client().prepareSearch("classes")
.addAggregation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public void setupSuiteScopeCluster() throws Exception {
builders.add(client().prepareIndex("new_index").setSource(Collections.emptyMap()));

indexRandom(true, builders);
indexRandomForMultipleSlices("idx", "old_index", "new_index");
ensureSearchable();
}

Expand Down Expand Up @@ -917,6 +918,7 @@ public void testOverlappingRanges() throws Exception {
}

public void testEmptyAggregation() throws Exception {
indexRandomForConcurrentSearch("empty_bucket_idx");
SearchResponse searchResponse = client().prepareSearch("empty_bucket_idx")
.setQuery(matchAllQuery())
.addAggregation(
Expand Down

0 comments on commit 0539713

Please sign in to comment.