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)
This commit is contained in:
parent
f7cc570c4f
commit
9551cb3420
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue