Skip to content

Commit f15f432

Browse files
Lukas Wegmannelasticmachine
Lukas Wegmann
andauthored
SQL: stabilize SqlSearchPageTimeoutIT (#79928) (#79991)
#79360 introduced a [flaky test](https://gradle-enterprise.elastic.co/scans/tests?search.relativeStartTime=P7D&search.timeZoneId=Europe/Zurich&tests.container=org.elasticsearch.xpack.sql.action.SqlSearchPageTimeoutIT&tests.sortField=FAILED&tests.test=testSearchContextIsCleanedUpAfterPageTimeoutForHitsQueries&tests.unstableOnly=true). Increasing the page timeout used in the initial query should ensure that line 44 should always see the search context (I suspect that it has been removed before `getNumberOfSearchContexts()` reads the search contexts). I've run the test with a 1000 iterations locally on both master and 7.16 and it didn't fail. Co-authored-by: Elastic Machine <[email protected]>
1 parent 7466023 commit f15f432

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/SqlSearchPageTimeoutIT.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.elasticsearch.search.SearchService;
1717

1818
import java.util.Arrays;
19-
import java.util.concurrent.TimeUnit;
2019

2120
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
2221
import static org.hamcrest.Matchers.contains;
@@ -28,24 +27,22 @@ public class SqlSearchPageTimeoutIT extends AbstractSqlIntegTestCase {
2827
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
2928
Settings.Builder settings = Settings.builder().put(super.nodeSettings(nodeOrdinal, otherSettings));
3029
// use static low keepAlive interval to ensure obsolete search contexts are pruned soon enough
31-
settings.put(SearchService.KEEPALIVE_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(200));
30+
settings.put(SearchService.KEEPALIVE_INTERVAL_SETTING.getKey(), TimeValue.timeValueMillis(100));
3231
return settings.build();
3332
}
3433

35-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/pull/79928")
3634
public void testSearchContextIsCleanedUpAfterPageTimeoutForHitsQueries() throws Exception {
3735
setupTestIndex();
3836

3937
SqlQueryResponse response = new SqlQueryRequestBuilder(client(), SqlQueryAction.INSTANCE).query("SELECT field FROM test")
4038
.fetchSize(1)
41-
.pageTimeout(TimeValue.timeValueMillis(100))
39+
.pageTimeout(TimeValue.timeValueMillis(500))
4240
.get();
4341

44-
assertEquals(1, response.size());
4542
assertTrue(response.hasCursor());
4643
assertEquals(1, getNumberOfSearchContexts());
4744

48-
assertBusy(() -> assertEquals(0, getNumberOfSearchContexts()), 3, TimeUnit.SECONDS);
45+
assertBusy(() -> assertEquals(0, getNumberOfSearchContexts()));
4946

5047
SearchPhaseExecutionException exception = expectThrows(
5148
SearchPhaseExecutionException.class,
@@ -60,7 +57,7 @@ public void testNoSearchContextForAggregationQueries() throws InterruptedExcepti
6057

6158
SqlQueryResponse response = new SqlQueryRequestBuilder(client(), SqlQueryAction.INSTANCE).query(
6259
"SELECT COUNT(*) FROM test GROUP BY field"
63-
).fetchSize(1).pageTimeout(TimeValue.timeValueMillis(100)).get();
60+
).fetchSize(1).pageTimeout(TimeValue.timeValueMillis(500)).get();
6461

6562
assertEquals(1, response.size());
6663
assertTrue(response.hasCursor());

0 commit comments

Comments
 (0)