From 9551cb342069f50f259a5e48eef889b292e5bfd3 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Sat, 14 Nov 2020 16:37:46 +0200 Subject: [PATCH] EQL: small improvements to the testing base class Extract request settings into dedicated methods for easier adjustments (cherry picked from commit 4f93591cc561c7f8ff7c2f070dd1180f209810b7) (cherry picked from commit ff7e8427345c304f5a37612c870b48555484b692) --- .../test/eql/BaseEqlSpecTestCase.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) 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 e5df212de0e..c363f1c067c 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 @@ -112,14 +112,16 @@ public abstract class BaseEqlSpecTestCase extends ESRestTestCase { protected EqlSearchResponse runQuery(String index, String query) throws Exception { EqlSearchRequest request = new EqlSearchRequest(index, query); + + request.eventCategoryField(eventCategory()); + request.timestampField(timestamp()); String tiebreaker = tiebreaker(); if (tiebreaker != null) { request.tiebreakerField(tiebreaker()); } - // some queries return more than 10 results - request.size(50); - request.fetchSize(randomIntBetween(2, 50)); - request.resultPosition(randomBoolean() ? "head" : "tail"); + request.size(requestSize()); + request.fetchSize(requestFetchSize()); + request.resultPosition(requestResultPosition()); return runRequest(eqlClient(), request); } @@ -199,9 +201,30 @@ public abstract class BaseEqlSpecTestCase extends ESRestTestCase { return builder.build(); } - protected TimeValue timeout() { - return TimeValue.timeValueSeconds(10); + protected String timestamp() { + return "@timestamp"; + }; + + private String eventCategory() { + return "event.category"; } protected abstract String tiebreaker(); + + protected int requestSize() { + // some queries return more than 10 results + return 50; + } + + protected int requestFetchSize() { + return randomIntBetween(2, requestSize()); + } + + protected String requestResultPosition() { + return randomBoolean() ? "head" : "tail"; + } + + protected TimeValue timeout() { + return TimeValue.timeValueSeconds(10); + } }