Skip to content

Commit 4f93591

Browse files
committed
EQL: small improvements to the testing base class
Extract request settings into dedicated methods for easier adjustments
1 parent 20210cc commit 4f93591

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/BaseEqlSpecTestCase.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@ else if (hits.sequences() != null) {
112112

113113
protected EqlSearchResponse runQuery(String index, String query) throws Exception {
114114
EqlSearchRequest request = new EqlSearchRequest(index, query);
115+
116+
request.eventCategoryField(eventCategory());
117+
request.timestampField(timestamp());
115118
String tiebreaker = tiebreaker();
116119
if (tiebreaker != null) {
117120
request.tiebreakerField(tiebreaker());
118121
}
119-
// some queries return more than 10 results
120-
request.size(50);
121-
request.fetchSize(randomIntBetween(2, 50));
122-
request.resultPosition(randomBoolean() ? "head" : "tail");
122+
request.size(requestSize());
123+
request.fetchSize(requestFetchSize());
124+
request.resultPosition(requestResultPosition());
123125
return runRequest(eqlClient(), request);
124126
}
125127

@@ -199,9 +201,30 @@ protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOE
199201
return builder.build();
200202
}
201203

202-
protected TimeValue timeout() {
203-
return TimeValue.timeValueSeconds(10);
204+
protected String timestamp() {
205+
return "@timestamp";
206+
};
207+
208+
private String eventCategory() {
209+
return "event.category";
204210
}
205211

206212
protected abstract String tiebreaker();
213+
214+
protected int requestSize() {
215+
// some queries return more than 10 results
216+
return 50;
217+
}
218+
219+
protected int requestFetchSize() {
220+
return randomIntBetween(2, requestSize());
221+
}
222+
223+
protected String requestResultPosition() {
224+
return randomBoolean() ? "head" : "tail";
225+
}
226+
227+
protected TimeValue timeout() {
228+
return TimeValue.timeValueSeconds(10);
229+
}
207230
}

0 commit comments

Comments
 (0)