Skip to content

Commit

Permalink
Add indexRandomForConcurrentSearch method to tests:
Browse files Browse the repository at this point in the history
* IndexStatsIT.java
* SearchTimeoutIT.java
* NaNSortingIT.java

Signed-off-by: Jay Deng <jayd0104@gmail.com>
  • Loading branch information
jed326 authored and Jay Deng committed Nov 6, 2023
1 parent 1782b90 commit b8a4165
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 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 @@ -92,6 +92,7 @@ public void testSimpleTimeout() throws Exception {
for (int i = 0; i < numDocs; i++) {
client().prepareIndex("test").setId(Integer.toString(i)).setSource("field", "value").get();
}
indexRandomForConcurrentSearch("test");
refresh("test");

SearchResponse searchResponse = client().prepareSearch("test")
Expand All @@ -104,11 +105,10 @@ 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");

SearchResponse searchResponse = client().prepareSearch("test")
.setTimeout(new TimeValue(10000, TimeUnit.SECONDS))
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 @@ -171,6 +171,7 @@ public void setupSuiteScopeCluster() throws Exception {
}
client().prepareIndex("idx").setSource(source.endObject()).get();
}
indexRandomForMultipleSlices("idx");
refresh();
ensureSearchable();
}
Expand Down

0 comments on commit b8a4165

Please sign in to comment.