Skip to content

Commit

Permalink
Fix IndexStatsIT SearchTimeoutIT
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Deng <[email protected]>
  • Loading branch information
jed326 authored and Jay Deng committed Sep 28, 2023
1 parent 7dabb05 commit 5e44272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public void testFieldDataStats() {
ensureGreen();
client().prepareIndex("test").setId("1").setSource("field", "value1", "field2", "value1").execute().actionGet();
client().prepareIndex("test").setId("2").setSource("field", "value2", "field2", "value2").execute().actionGet();
indexRandomForConcurrentSearch("test");
client().admin().indices().prepareRefresh().execute().actionGet();

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

NodesStatsResponse nodesStats = client().admin().cluster().prepareNodesStats("data:true").setIndices(true).execute().actionGet();
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,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();
refresh("test");
}
refresh("test");

SearchResponse searchResponse = client().prepareSearch("test")
.setTimeout(new TimeValue(10000, TimeUnit.SECONDS))
Expand All @@ -122,6 +123,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,
Expand Down

0 comments on commit 5e44272

Please sign in to comment.