-
Notifications
You must be signed in to change notification settings - Fork 36
AD opendistro 1.6 support #87
Changes from all commits
67945bd
f6dd325
468e40f
48f5cd6
176f943
0fdcfb1
7f84e12
e9d4a46
40cc15b
7fcb93d
b541442
92094ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ | |
buildscript { | ||
ext { | ||
es_group = "org.elasticsearch" | ||
es_version = '7.4.2' | ||
es_distribution = 'oss-zip' | ||
es_version = '7.6.1' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url "https://plugins.gradle.org/m2/" } | ||
|
@@ -31,8 +31,9 @@ buildscript { | |
} | ||
|
||
plugins { | ||
id 'nebula.ospackage' version "5.3.0" | ||
id 'nebula.ospackage' version "8.2.0" apply false | ||
id "com.diffplug.gradle.spotless" version "3.26.1" | ||
id 'java-library' | ||
} | ||
|
||
repositories { | ||
|
@@ -42,13 +43,8 @@ repositories { | |
} | ||
|
||
ext { | ||
opendistroVersion = '1.4.0' | ||
opendistroVersion = '1.6.0' | ||
isSnapshot = "true" == System.getProperty("build.snapshot", "true") | ||
if (System.properties['os.name'].toLowerCase().contains('windows')) { | ||
job_scheduler_plugin_zip = "file:///${fileTree("src/test/resources/job-scheduler").getSingleFile().absolutePath}" | ||
} else { | ||
job_scheduler_plugin_zip = "file://${fileTree("src/test/resources/job-scheduler").getSingleFile().absolutePath}" | ||
} | ||
} | ||
|
||
version = "${opendistroVersion}.0" | ||
|
@@ -120,80 +116,6 @@ thirdPartyAudit.enabled = false | |
// See package README.md for details on using these tasks. | ||
def _numNodes = findProperty('numNodes') as Integer ?: 1 | ||
|
||
def getSeedHosts = { int num -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we remove the following, which is used to start and stop a multi-node cluster? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was added to to provide hack to install job scheduler plugin on the test clusters. With ES 7.5 onwards Elasticsearch provided a way to install dependent plugins on test cluster. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to know. Could you keep runSingleNode and stopMultiNode (line 165~196 in the old version) so that I can start node one by one and kill all nodes? Need them for fault tolerance tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created issue to add this back #90 |
||
def _localhost = "127.0.0.1:" | ||
def _startPort = 9300 | ||
|
||
def _seed_hosts = new StringBuilder() | ||
_seed_hosts.append("[") | ||
|
||
(0..< num).each { i -> | ||
if (i>0) { | ||
_seed_hosts.append(", ") | ||
} | ||
def _host = "\"" + _localhost + (_startPort + i) + "\"" | ||
_seed_hosts.append(_host) | ||
} | ||
|
||
_seed_hosts.append("]") | ||
_seed_hosts | ||
} | ||
|
||
tasks.create(name : "runMultiNode", type: org.elasticsearch.gradle.test.RunTask) { | ||
daemonize = true | ||
numNodes = _numNodes | ||
// this has to be false otherwise ClusterFormationTasks.groovy will set discovery.seed_providers to file | ||
autoSetHostsProvider = false | ||
setting 'http.port', '9200-9300' | ||
setting 'transport.port', '9300-9400' | ||
setting 'discovery.seed_hosts', getSeedHosts(numNodes) | ||
clusterName = 'multi-node-run' | ||
plugin project.path | ||
distribution = es_distribution | ||
// Temporary until job-scheduler is published to Maven | ||
setupCommand('installPlugin', 'bin/elasticsearch-plugin', 'install', job_scheduler_plugin_zip) | ||
} | ||
|
||
tasks.create(name: "startMultiNode") { | ||
if (_numNodes == 1) { | ||
dependsOn "runMultiNode#start" | ||
} else { | ||
(0..<_numNodes).each { n -> dependsOn "runMultiNode#node${n}.start" } | ||
} | ||
} | ||
|
||
tasks.create(name : "runSingleNode", type: org.elasticsearch.gradle.test.RunTask) { | ||
daemonize = true | ||
numNodes = 3 | ||
// this has to be false otherwise ClusterFormationTasks.groovy will set discovery.seed_providers to file | ||
autoSetHostsProvider = false | ||
// this has to be false otherwise ClusterFormationTasks.groovy will set cluster.initial_master_nodes to all 3 nodes | ||
autoSetInitialMasterNodes = false | ||
setting 'http.port', '9200-9300' | ||
setting 'transport.port', '9300-9400' | ||
setting 'discovery.seed_hosts', getSeedHosts(numNodes) | ||
setting 'node.master', true | ||
setting 'node.data', true | ||
setting 'node.ingest', true | ||
// since we want to start one node at a time, we have to provide the node we are going to start first | ||
setting 'cluster.initial_master_nodes', "[\"node-0\"]" | ||
clusterName = 'multi-node-run' | ||
plugin project.path | ||
distribution = es_distribution | ||
} | ||
|
||
(0..2).each { i -> | ||
tasks.create(name: "startSingleNode$i") { | ||
dependsOn "runSingleNode#node${i}.start" | ||
} | ||
} | ||
|
||
task stopMultiNode(type: Exec) { | ||
commandLine "bash", "-c", "kill -9 \$(ps aux | grep lastic | grep -v grep | grep -v stopMultiNode | awk '{print \$2}')" | ||
sleep(1000) | ||
dependsOn "clean" | ||
} | ||
|
||
def es_tmp_dir = rootProject.file('build/private/es_tmp').absoluteFile | ||
es_tmp_dir.mkdirs() | ||
|
||
|
@@ -202,30 +124,57 @@ test { | |
systemProperty 'tests.security.manager', 'false' | ||
} | ||
|
||
integTestRunner { | ||
systemProperty 'tests.security.manager', 'false' | ||
systemProperty 'java.io.tmpdir', es_tmp_dir.absolutePath | ||
systemProperty 'tests.locale', 'en' | ||
// Tell the test JVM if the cluster JVM is running under a debugger so that tests can use longer timeouts for | ||
// requests. The 'doFirst' delays reading the debug setting on the cluster till execution time. | ||
doFirst { systemProperty 'cluster.debug', integTestCluster.debug } | ||
|
||
// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable | ||
if (System.getProperty("test.debug") != null) { | ||
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' | ||
integTest { | ||
runner { | ||
systemProperty 'tests.security.manager', 'false' | ||
systemProperty 'java.io.tmpdir', es_tmp_dir.absolutePath | ||
// The 'doFirst' delays till execution time. | ||
doFirst { | ||
// Tell the test JVM if the cluster JVM is running under a debugger so that tests can | ||
// use longer timeouts for requests. | ||
def isDebuggingCluster = getDebug() || System.getProperty("test.debug") != null | ||
systemProperty 'cluster.debug', isDebuggingCluster | ||
// Set number of nodes system property to be used in tests | ||
systemProperty 'cluster.number_of_nodes', "${_numNodes}" | ||
// There seems to be an issue when running multi node run or integ tasks with unicast_hosts | ||
// not being written, the waitForAllConditions ensures it's written | ||
getClusters().forEach { cluster -> | ||
cluster.waitForAllConditions() | ||
} | ||
} | ||
|
||
// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable | ||
if (System.getProperty("test.debug") != null) { | ||
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' | ||
} | ||
} | ||
} | ||
|
||
integTestCluster { | ||
distribution = es_distribution | ||
// Temporary until job-scheduler is published to Maven | ||
setupCommand('installPlugin', 'bin/elasticsearch-plugin', 'install', job_scheduler_plugin_zip) | ||
testClusters.integTest { | ||
testDistribution = "OSS" | ||
// Cluster shrink exception thrown if we try to set numberOfNodes to 1, so only apply if > 1 | ||
if (_numNodes > 1) numberOfNodes = _numNodes | ||
// When running integration tests it doesn't forward the --debug-jvm to the cluster anymore | ||
// i.e. we have to use a custom property to flag when we want to debug elasticsearch JVM | ||
// since we also support multi node integration tests we increase debugPort per node | ||
if (System.getProperty("es.debug") != null) { | ||
def debugPort = 5005 | ||
nodes.forEach { node -> | ||
node.jvmArgs("-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=*:${debugPort}") | ||
debugPort += 1 | ||
} | ||
} | ||
plugin(fileTree("src/test/resources/job-scheduler").getSingleFile()) | ||
} | ||
|
||
run { | ||
distribution = es_distribution | ||
// Temporary until job-scheduler is published to Maven | ||
setupCommand('installPlugin', 'bin/elasticsearch-plugin', 'install', job_scheduler_plugin_zip) | ||
doFirst { | ||
// There seems to be an issue when running multi node run or integ tasks with unicast_hosts | ||
// not being written, the waitForAllConditions ensures it's written | ||
getClusters().forEach { cluster -> | ||
cluster.waitForAllConditions() | ||
} | ||
} | ||
} | ||
|
||
evaluationDependsOnChildren() | ||
|
@@ -255,23 +204,17 @@ List<String> jacocoExclusions = [ | |
'com.amazon.opendistroforelasticsearch.ad.common.exception.AnomalyDetectionException', | ||
'com.amazon.opendistroforelasticsearch.ad.util.ClientUtil', | ||
|
||
'com.amazon.opendistroforelasticsearch.ad.ml.*', | ||
'com.amazon.opendistroforelasticsearch.ad.feature.*', | ||
'com.amazon.opendistroforelasticsearch.ad.dataprocessor.*', | ||
'com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorRunner', | ||
'com.amazon.opendistroforelasticsearch.ad.resthandler.RestGetAnomalyResultAction', | ||
'com.amazon.opendistroforelasticsearch.ad.metrics.MetricFactory', | ||
'com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.ForwardAction', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.ForwardTransportAction', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorAction', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorRequest', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorResponse', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorTransportAction', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.ADStatsAction', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.CronRequest', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.DeleteDetectorAction', | ||
'com.amazon.opendistroforelasticsearch.ad.util.ParseUtils' | ||
'com.amazon.opendistroforelasticsearch.ad.transport.CronTransportAction', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.CronRequest', | ||
'com.amazon.opendistroforelasticsearch.ad.transport.ADStatsAction', | ||
'com.amazon.opendistroforelasticsearch.ad.AnomalyDetectorRunner', | ||
'com.amazon.opendistroforelasticsearch.ad.indices.AnomalyDetectionIndices', | ||
'com.amazon.opendistroforelasticsearch.ad.util.ParseUtils', | ||
] | ||
|
||
jacocoTestCoverageVerification { | ||
|
@@ -300,8 +243,9 @@ check.dependsOn jacocoTestCoverageVerification | |
jacocoTestCoverageVerification.dependsOn jacocoTestReport | ||
|
||
dependencies { | ||
compile "org.elasticsearch:elasticsearch:${es_version}" | ||
compileOnly "org.elasticsearch.plugin:elasticsearch-scripting-painless-spi:${versions.elasticsearch}" | ||
compileOnly "com.amazon.opendistroforelasticsearch:opendistro-job-scheduler-spi:1.4.0.0" | ||
compileOnly "com.amazon.opendistroforelasticsearch:opendistro-job-scheduler-spi:1.6.0.0" | ||
compile group: 'com.google.guava', name: 'guava', version:'15.0' | ||
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1' | ||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5' | ||
|
@@ -331,29 +275,6 @@ apply plugin: 'nebula.ospackage' | |
|
||
// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name | ||
afterEvaluate { | ||
project.tasks.getByName("run#installOpendistroAnomalyDetectorPlugin").dependsOn("run#installPlugin") | ||
project.tasks.getByName("run#installPlugin").dependsOn.remove(project.tasks.getByName("run#installOpendistroAnomalyDetectorPlugin")) | ||
project.tasks.getByName("run#installPlugin").dependsOn("run#copyPlugins") | ||
project.tasks.getByName("run#start").dependsOn.remove(project.tasks.getByName("run#installPlugin")) | ||
project.tasks.getByName("run#start").dependsOn("run#installOpendistroAnomalyDetectorPlugin") | ||
|
||
if (_numNodes == 1) { | ||
project.tasks.getByName("runMultiNode#installOpendistroAnomalyDetectorPlugin").dependsOn("runMultiNode#installPlugin") | ||
project.tasks.getByName("runMultiNode#installPlugin").dependsOn.remove(project.tasks.getByName("runMultiNode#installOpendistroAnomalyDetectorPlugin")) | ||
project.tasks.getByName("runMultiNode#installPlugin").dependsOn("runMultiNode#copyPlugins") | ||
project.tasks.getByName("runMultiNode#start").dependsOn.remove(project.tasks.getByName("runMultiNode#installPlugin")) | ||
project.tasks.getByName("runMultiNode#start").dependsOn("runMultiNode#installOpendistroAnomalyDetectorPlugin") | ||
} else { | ||
(0..<_numNodes).each { | ||
n -> | ||
project.tasks.getByName("runMultiNode#node${n}.installOpendistroAnomalyDetectorPlugin").dependsOn("runMultiNode#node${n}.installPlugin") | ||
project.tasks.getByName("runMultiNode#node${n}.installPlugin").dependsOn.remove(project.tasks.getByName("runMultiNode#node${n}.installOpendistroAnomalyDetectorPlugin")) | ||
project.tasks.getByName("runMultiNode#node${n}.installPlugin").dependsOn("runMultiNode#node${n}.copyPlugins") | ||
project.tasks.getByName("runMultiNode#node${n}.start").dependsOn.remove(project.tasks.getByName("runMultiNode#node${n}.installPlugin")) | ||
project.tasks.getByName("runMultiNode#node${n}.start").dependsOn("runMultiNode#node${n}.installOpendistroAnomalyDetectorPlugin") | ||
} | ||
} | ||
|
||
ospackage { | ||
packageName = "${name}" | ||
release = isSnapshot ? "0.1" : '1' | ||
|
@@ -401,16 +322,6 @@ afterEvaluate { | |
} | ||
} | ||
|
||
tasks.whenTaskAdded { task -> | ||
if (task.name == "integTestCluster#wait") { | ||
project.tasks.getByName("integTestCluster#installOpendistroAnomalyDetectorPlugin").dependsOn("integTestCluster#installPlugin") | ||
project.tasks.getByName("integTestCluster#installPlugin").dependsOn.remove(project.tasks.getByName("integTestCluster#installOpendistroAnomalyDetectorPlugin")) | ||
project.tasks.getByName("integTestCluster#installPlugin").dependsOn("integTestCluster#copyPlugins") | ||
project.tasks.getByName("integTestCluster#start").dependsOn.remove(project.tasks.getByName("integTestCluster#installPlugin")) | ||
project.tasks.getByName("integTestCluster#start").dependsOn("integTestCluster#installOpendistroAnomalyDetectorPlugin") | ||
} | ||
} | ||
|
||
spotless { | ||
java { | ||
eclipse().configFile rootProject.file('.eclipseformat.xml') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After removing these lines, can we build on both windows and Linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we were installing using
setupCommand
where we used absolute path for file which was different for windows. Now we just need to passfiletree
.Example:-
plugin(fileTree("src/test/resources/job-scheduler").getSingleFile())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great