diff --git a/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/BaseEqlSpecTestCase.java b/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/BaseEqlSpecTestCase.java index 64b7c6792dc..f49b13791f5 100644 --- a/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/BaseEqlSpecTestCase.java +++ b/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/BaseEqlSpecTestCase.java @@ -6,10 +6,13 @@ package org.elasticsearch.test.eql; +import org.apache.http.HttpHost; import org.elasticsearch.client.EqlClient; import org.elasticsearch.client.Request; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.ResponseException; +import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.eql.EqlSearchRequest; import org.elasticsearch.client.eql.EqlSearchResponse; @@ -18,6 +21,8 @@ import org.elasticsearch.client.eql.EqlSearchResponse.Hits; import org.elasticsearch.client.eql.EqlSearchResponse.Sequence; import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.LoggerMessageFormat; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.test.rest.ESRestTestCase; import org.junit.AfterClass; import org.junit.Before; @@ -106,7 +111,10 @@ public abstract class BaseEqlSpecTestCase extends ESRestTestCase { protected EqlSearchResponse runQuery(String index, String query) throws Exception { EqlSearchRequest request = new EqlSearchRequest(index, query); - request.tiebreakerField("event.sequence"); + String tiebreaker = tiebreaker(); + if (tiebreaker != null) { + request.tiebreakerField(tiebreaker()); + } // some queries return more than 10 results request.size(50); request.fetchSize(randomIntBetween(2, 50)); @@ -136,7 +144,7 @@ public abstract class BaseEqlSpecTestCase extends ESRestTestCase { final int len = events.size(); final long[] ids = new long[len]; for (int i = 0; i < len; i++) { - Object field = events.get(i).sourceAsMap().get(sequenceField()); + Object field = events.get(i).sourceAsMap().get(tiebreaker()); ids[i] = ((Number) field).longValue(); } return ids; @@ -167,5 +175,24 @@ public abstract class BaseEqlSpecTestCase extends ESRestTestCase { return true; } - protected abstract String sequenceField(); + @Override + protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOException { + RestClientBuilder builder = RestClient.builder(hosts); + configureClient(builder, settings); + + int timeout = Math.toIntExact(timeout().millis()); + builder.setRequestConfigCallback( + requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(timeout) + .setConnectionRequestTimeout(timeout) + .setSocketTimeout(timeout) + ); + builder.setStrictDeprecationMode(true); + return builder.build(); + } + + protected TimeValue timeout() { + return TimeValue.timeValueSeconds(10); + } + + protected abstract String tiebreaker(); } diff --git a/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlExtraSpecTestCase.java b/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlExtraSpecTestCase.java index f023bf7a502..53ccdf3e85f 100644 --- a/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlExtraSpecTestCase.java +++ b/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlExtraSpecTestCase.java @@ -25,7 +25,7 @@ public abstract class EqlExtraSpecTestCase extends BaseEqlSpecTestCase { } @Override - protected String sequenceField() { + protected String tiebreaker() { return "sequence"; } } diff --git a/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlSpecTestCase.java b/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlSpecTestCase.java index 922b722e78d..9c8e9d2bcf6 100644 --- a/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlSpecTestCase.java +++ b/x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/EqlSpecTestCase.java @@ -47,7 +47,7 @@ public abstract class EqlSpecTestCase extends BaseEqlSpecTestCase { } @Override - protected String sequenceField() { + protected String tiebreaker() { return "serial_event_id"; }