forked from opendistro-for-elasticsearch/asynchronous-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
210 lines (184 loc) · 8.08 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
buildscript {
ext {
es_version = '7.10.2'
distribution = 'oss-zip'
es_group = "org.elasticsearch"
opendistroVersion = '1.13.0'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath "${es_group}.gradle:build-tools:${es_version}"
classpath "org.jacoco:org.jacoco.agent:0.8.5"
}
}
//****************************************************************************/
// Build configurations
//****************************************************************************/
plugins {
id 'nebula.ospackage' version "8.3.0"
}
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
apply plugin: 'elasticsearch.esplugin'
apply plugin: 'elasticsearch.testclusters'
apply plugin: 'elasticsearch.rest-test'
checkstyle {
toolVersion = '8.24'
configFile file("checkstyle/checkstyle.xml")
}
def usingRemoteCluster = System.properties.containsKey('tests.rest.cluster') || System.properties.containsKey('tests.cluster')
def usingMultiNode = project.properties.containsKey('numNodes')
// Only apply jacoco test coverage if we are running a local single node cluster
if (!usingRemoteCluster) {
if (!usingMultiNode) {
apply from: 'build-tools/plugin-coverage.gradle'
}
}
ext {
projectSubstitutions = [:]
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
}
group 'com.amazon.opendistroforelasticsearch'
version = "${opendistroVersion}.1"
sourceCompatibility = 1.9
repositories {
mavenCentral()
}
dependencies {
testCompile ('junit:junit:4.12') {
exclude group: 'org.hamcrest'
}
testCompile group: "org.codelibs.elasticsearch.module", name: "lang-painless", version: "${es_version}"
testCompile "org.elasticsearch.plugin:reindex-client:${es_version}"
testCompile "org.elasticsearch.test:framework:${es_version}"
compileOnly "org.elasticsearch.plugin:transport-netty4-client:${es_version}"
compileOnly "org.elasticsearch:elasticsearch:${es_version}"
compile "com.amazon.opendistroforelasticsearch:common-utils:${opendistroVersion}.0"
configurations.all {
resolutionStrategy {
force "com.puppycrawl.tools:checkstyle:${project.checkstyle.toolVersion}"
}
}
}
compileTestJava {
classpath = classpath.filter{ File file ->
!file.name.equals( "hamcrest-core-1.3.jar" )
}
}
check.dependsOn jacocoTestReport
esplugin {
name 'opendistro-asynchronous-search'
description 'Provides support for asynchronous search'
classname 'com.amazon.opendistroforelasticsearch.search.asynchronous.plugin.AsynchronousSearchPlugin'
}
tasks.named("integTest").configure {
it.dependsOn(project.tasks.named("bundlePlugin"))
}
//TODO enable license headers
licenseHeaders.enabled = false
dependencyLicenses.enabled = false
thirdPartyAudit.enabled = false
validateNebulaPom.enabled = false
loggerUsageCheck.enabled = false
def es_tmp_dir = rootProject.file('build/private/es_tmp').absoluteFile
es_tmp_dir.mkdirs()
def securityEnabled = System.getProperty("security", "false") == "true"
afterEvaluate {
testClusters.integTest.nodes.each { node ->
def plugins = node.plugins
def firstPlugin = plugins.get(0)
plugins.remove(0)
plugins.add(firstPlugin)
if (securityEnabled) {
node.extraConfigFile("kirk.pem", file("src/test/resources/security/kirk.pem"))
node.extraConfigFile("kirk-key.pem", file("src/test/resources/security/kirk-key.pem"))
node.extraConfigFile("esnode.pem", file("src/test/resources/security/esnode.pem"))
node.extraConfigFile("esnode-key.pem", file("src/test/resources/security/esnode-key.pem"))
node.extraConfigFile("root-ca.pem", file("src/test/resources/security/root-ca.pem"))
node.setting("opendistro_security.ssl.transport.pemcert_filepath", "esnode.pem")
node.setting("opendistro_security.ssl.transport.pemkey_filepath", "esnode-key.pem")
node.setting("opendistro_security.ssl.transport.pemtrustedcas_filepath", "root-ca.pem")
node.setting("opendistro_security.ssl.transport.enforce_hostname_verification", "false")
node.setting("opendistro_security.ssl.http.enabled", "true")
node.setting("opendistro_security.ssl.http.pemcert_filepath", "esnode.pem")
node.setting("opendistro_security.ssl.http.pemkey_filepath", "esnode-key.pem")
node.setting("opendistro_security.ssl.http.pemtrustedcas_filepath", "root-ca.pem")
node.setting("opendistro_security.allow_unsafe_democertificates", "true")
node.setting("opendistro_security.allow_default_init_securityindex", "true")
node.setting("opendistro_security.authcz.admin_dn", "CN=kirk,OU=client,O=client,L=test,C=de")
node.setting("opendistro_security.audit.type", "internal_elasticsearch")
node.setting("opendistro_security.enable_snapshot_restore_privilege", "true")
node.setting("opendistro_security.check_snapshot_restore_write_privileges", "true")
node.setting("opendistro_security.restapi.roles_enabled", "[\"all_access\", \"security_rest_api_access\"]")
}
}
}
test {
systemProperty 'tests.security.manager', 'false'
systemProperty 'es.set.netty.runtime.available.processors', 'false'
}
File repo = file("$buildDir/testclusters/repo")
def _numNodes = findProperty('numNodes') as Integer ?: 1
testClusters.integTest {
testDistribution = "OSS"
plugin(project.tasks.bundlePlugin.archiveFile)
// 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
}
}
nodes.each { node ->
def plugins = node.plugins
def firstPlugin = plugins.get(0)
plugins.remove(0)
plugins.add(firstPlugin)
}
}
integTest {
systemProperty 'tests.security.manager', 'false'
systemProperty 'java.io.tmpdir', es_tmp_dir.absolutePath
systemProperty 'buildDir', buildDir.path
systemProperty "https", System.getProperty("https", securityEnabled.toString())
systemProperty "user", System.getProperty("user", "admin")
systemProperty "password", System.getProperty("password", "admin")
// 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', getDebug()
// 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 -Dcluster.debug option makes the cluster debuggable; this makes the tests debuggable
if (System.getProperty("test.debug") != null) {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=8000'
}
}
run {
useCluster project.testClusters.integTest
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()
}
}
}
apply from: 'build-tools/pkgbuild.gradle'