Skip to content

Commit 79875ce

Browse files
committed
Initial EQL rest API implementation (elastic#49768)
1 parent 10a16d1 commit 79875ce

File tree

18 files changed

+1661
-3
lines changed

18 files changed

+1661
-3
lines changed

x-pack/plugin/eql/build.gradle

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,36 @@ dependencies {
2222
}
2323
compile "org.antlr:antlr4-runtime:4.5.3"
2424
testCompile project(':test:framework')
25+
compileOnly project(path: xpackModule('core'), configuration: 'default')
2526
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
2627
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts')
2728
testCompile project(path: ':modules:reindex', configuration: 'runtime')
2829
testCompile project(path: ':modules:parent-join', configuration: 'runtime')
2930
testCompile project(path: ':modules:analysis-common', configuration: 'runtime')
3031
}
3132

32-
// disable integration tests for now
3333
integTest.enabled = false
34+
testingConventions.enabled = false
35+
36+
// Instead we create a separate task to run the tests based on ESIntegTestCase
37+
task internalClusterTest(type: Test) {
38+
description = '🌈🌈🌈🦄 Welcome to fantasy integration tests land! 🦄🌈🌈🌈'
39+
mustRunAfter test
40+
41+
include '**/*IT.class'
42+
systemProperty 'es.set.netty.runtime.available.processors', 'false'
43+
}
44+
45+
check.dependsOn internalClusterTest
46+
47+
// add all sub-projects of the qa sub-project
48+
gradle.projectsEvaluated {
49+
project.subprojects
50+
.find { it.path == project.path + ":qa" }
51+
.subprojects
52+
.findAll { it.path.startsWith(project.path + ":qa") }
53+
.each { check.dependsOn it.check }
54+
}
3455

3556
/**********************************************
3657
* EQL Parser regeneration *

x-pack/plugin/eql/qa/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import org.elasticsearch.gradle.test.RestIntegTestTask
2+
3+
apply plugin: 'elasticsearch.build'
4+
test.enabled = false
5+
6+
dependencies {
7+
compile project(':test:framework')
8+
}
9+
10+
subprojects {
11+
project.tasks.withType(RestIntegTestTask) {
12+
final File xPackResources = new File(xpackProject('plugin').projectDir, 'src/test/resources')
13+
project.copyRestSpec.from(xPackResources) {
14+
include 'rest-api-spec/api/**'
15+
}
16+
}
17+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apply plugin: 'elasticsearch.build'
2+
test.enabled = false
3+
4+
dependencies {
5+
compile project(':test:framework')
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.test.eql;
7+
8+
import org.elasticsearch.test.rest.ESRestTestCase;
9+
10+
public abstract class CommonEqlRestTestCase extends ESRestTestCase {
11+
// TODO: add common tests here
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apply plugin: 'elasticsearch.testclusters'
2+
apply plugin: 'elasticsearch.standalone-rest-test'
3+
apply plugin: 'elasticsearch.rest-test'
4+
5+
dependencies {
6+
testCompile project(path: xpackModule('eql'), configuration: 'runtime')
7+
testCompile project(path: xpackModule('eql:qa:common'), configuration: 'runtime')
8+
}
9+
10+
testClusters.integTest {
11+
testDistribution = 'DEFAULT'
12+
setting 'xpack.license.self_generated.type', 'basic'
13+
setting 'xpack.monitoring.collection.enabled', 'true'
14+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.eql;
8+
9+
import org.elasticsearch.test.eql.CommonEqlRestTestCase;
10+
11+
public class EqlIT extends CommonEqlRestTestCase {
12+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.eql;
8+
9+
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
10+
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
11+
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
12+
13+
public class EqlRestIT extends ESClientYamlSuiteTestCase {
14+
15+
public EqlRestIT(final ClientYamlTestCandidate testCandidate) {
16+
super(testCandidate);
17+
}
18+
19+
@ParametersFactory
20+
public static Iterable<Object[]> parameters() throws Exception {
21+
return ESClientYamlSuiteTestCase.createParameters();
22+
}
23+
24+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
setup:
3+
- do:
4+
bulk:
5+
refresh: true
6+
body:
7+
- index:
8+
_index: eql_test
9+
_id: 1
10+
- str: test1
11+
int: 1
12+
13+
---
14+
# Testing round-trip and the basic shape of the response
15+
# Currently not implemented or wired and always returns empty result.
16+
# TODO: define more test once everything is wired up
17+
"Execute some EQL.":
18+
- do:
19+
eql.search:
20+
index: eql_test
21+
body:
22+
rule: "process where user = 'SYSTEM'"
23+
24+
- match: {timed_out: false}
25+
- match: {took: 0}
26+
- match: {hits.total.value: 0}
27+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.xpack.eql.action;
7+
8+
import org.elasticsearch.action.ActionType;
9+
10+
public class EqlSearchAction extends ActionType<EqlSearchResponse> {
11+
public static final EqlSearchAction INSTANCE = new EqlSearchAction();
12+
public static final String NAME = "indices:data/read/eql";
13+
14+
private EqlSearchAction() {
15+
super(NAME, EqlSearchResponse::new);
16+
}
17+
}

0 commit comments

Comments
 (0)