2015-12-03 23:36:35 -08:00
|
|
|
import org.elasticsearch.gradle.MavenFilteringHack
|
2016-08-30 12:57:42 -04:00
|
|
|
import org.elasticsearch.gradle.test.NodeInfo
|
2019-04-04 21:44:03 +11:00
|
|
|
import org.elasticsearch.gradle.http.WaitForHttpResource
|
2015-11-25 00:13:59 -08:00
|
|
|
|
2017-01-04 14:27:53 -05:00
|
|
|
apply plugin: 'elasticsearch.standalone-rest-test'
|
2015-11-24 23:19:04 -05:00
|
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
|
|
|
|
dependencies {
|
2018-08-21 20:03:28 -04:00
|
|
|
testCompile "org.elasticsearch.plugin:x-pack-core:${version}"
|
2015-11-24 23:19:04 -05:00
|
|
|
}
|
|
|
|
|
2018-04-26 15:36:14 -07:00
|
|
|
String outputDir = "${buildDir}/generated-resources/${project.name}"
|
2016-04-12 09:19:07 -04:00
|
|
|
task copyXPackPluginProps(type: Copy) {
|
2018-01-26 21:48:30 -08:00
|
|
|
from project(xpackModule('core')).file('src/main/plugin-metadata')
|
|
|
|
from project(xpackModule('core')).tasks.pluginProperties
|
2016-04-12 09:19:07 -04:00
|
|
|
into outputDir
|
|
|
|
}
|
|
|
|
project.sourceSets.test.output.dir(outputDir, builtBy: copyXPackPluginProps)
|
|
|
|
|
2016-02-08 14:33:27 +01:00
|
|
|
// location of generated keystores and certificates
|
|
|
|
File keystoreDir = new File(project.buildDir, 'keystore')
|
2018-07-24 12:48:14 +03:00
|
|
|
File nodeKeystore = file("$keystoreDir/testnode.jks")
|
|
|
|
File nodeKey = file("$keystoreDir/testnode.pem")
|
|
|
|
File nodeCert = file("$keystoreDir/testnode.crt")
|
|
|
|
File clientKeyStore = file("$keystoreDir/testclient.jks")
|
|
|
|
File clientKey = file("$keystoreDir/testclient.pem")
|
|
|
|
File clientCert = file("$keystoreDir/testclient.crt")
|
2016-02-08 14:33:27 +01:00
|
|
|
|
2018-07-24 12:48:14 +03:00
|
|
|
// Add keystores to test classpath: it expects it there
|
|
|
|
task copyKeyCerts(type: Copy) {
|
|
|
|
from('./') {
|
|
|
|
include '*.crt', '*.pem', '*.jks'
|
2016-02-08 14:33:27 +01:00
|
|
|
}
|
2018-07-24 12:48:14 +03:00
|
|
|
into keystoreDir
|
2016-02-08 14:33:27 +01:00
|
|
|
}
|
|
|
|
// Add keystores to test classpath: it expects it there
|
|
|
|
sourceSets.test.resources.srcDir(keystoreDir)
|
2018-07-24 12:48:14 +03:00
|
|
|
processTestResources.dependsOn(copyKeyCerts)
|
2015-11-25 00:13:59 -08:00
|
|
|
|
2018-07-24 12:48:14 +03:00
|
|
|
integTestCluster.dependsOn(copyKeyCerts)
|
2017-09-14 12:18:54 -06:00
|
|
|
|
2018-01-19 23:30:17 -06:00
|
|
|
ext.pluginsCount = 0
|
2018-04-27 16:49:06 +02:00
|
|
|
project(':plugins').getChildProjects().each { pluginName, pluginProject ->
|
2015-12-03 23:36:35 -08:00
|
|
|
// need to get a non-decorated project object, so must re-lookup the project by path
|
2018-04-27 16:49:06 +02:00
|
|
|
integTestCluster.plugin(pluginProject.path)
|
2016-02-21 10:10:21 -08:00
|
|
|
pluginsCount += 1
|
2015-11-25 00:13:59 -08:00
|
|
|
}
|
2015-11-24 23:19:04 -05:00
|
|
|
|
2017-02-22 00:56:52 -08:00
|
|
|
integTestCluster {
|
2018-02-23 10:33:34 -05:00
|
|
|
setting 'xpack.monitoring.collection.interval', '1s'
|
2017-02-22 00:56:52 -08:00
|
|
|
setting 'xpack.monitoring.exporters._http.type', 'http'
|
|
|
|
setting 'xpack.monitoring.exporters._http.enabled', 'false'
|
|
|
|
setting 'xpack.monitoring.exporters._http.auth.username', 'monitoring_agent'
|
2017-06-29 15:27:57 -05:00
|
|
|
setting 'xpack.monitoring.exporters._http.auth.password', 'x-pack-test-password'
|
2017-12-05 12:07:04 +01:00
|
|
|
setting 'xpack.monitoring.exporters._http.ssl.verification_mode', 'full'
|
2019-01-14 14:06:22 -07:00
|
|
|
setting 'xpack.monitoring.exporters._http.ssl.certificate_authorities', 'testnode.crt'
|
2017-02-22 00:56:52 -08:00
|
|
|
|
2018-05-03 10:33:08 -06:00
|
|
|
setting 'xpack.license.self_generated.type', 'trial'
|
2018-03-21 21:09:44 -06:00
|
|
|
setting 'xpack.security.enabled', 'true'
|
2017-02-22 00:56:52 -08:00
|
|
|
setting 'xpack.security.http.ssl.enabled', 'true'
|
2018-07-24 12:48:14 +03:00
|
|
|
setting 'xpack.security.http.ssl.key', 'testnode.pem'
|
|
|
|
setting 'xpack.security.http.ssl.certificate', 'testnode.crt'
|
2019-01-14 14:06:22 -07:00
|
|
|
setting 'xpack.security.http.ssl.certificate_authorities', 'testnode.crt'
|
2018-07-24 12:48:14 +03:00
|
|
|
keystoreSetting 'xpack.security.http.ssl.secure_key_passphrase', 'testnode'
|
2017-02-22 00:56:52 -08:00
|
|
|
|
2018-08-02 13:05:11 -04:00
|
|
|
setting 'xpack.ilm.enabled', 'false'
|
2017-03-02 17:01:05 +00:00
|
|
|
setting 'xpack.ml.enabled', 'false'
|
2018-07-24 12:48:14 +03:00
|
|
|
// copy keystores, keys and certificates into config/
|
2017-02-22 00:56:52 -08:00
|
|
|
extraConfigFile nodeKeystore.name, nodeKeystore
|
2018-07-24 12:48:14 +03:00
|
|
|
extraConfigFile nodeKey.name, nodeKey
|
|
|
|
extraConfigFile nodeCert.name, nodeCert
|
2017-02-22 00:56:52 -08:00
|
|
|
extraConfigFile clientKeyStore.name, clientKeyStore
|
2018-07-24 12:48:14 +03:00
|
|
|
extraConfigFile clientKey.name, clientKey
|
|
|
|
extraConfigFile clientCert.name, clientCert
|
2017-02-22 00:56:52 -08:00
|
|
|
|
|
|
|
setupCommand 'setupTestUser',
|
2018-04-11 11:36:12 -04:00
|
|
|
'bin/elasticsearch-users', 'useradd', 'test_user', '-p', 'x-pack-test-password', '-r', 'superuser'
|
2017-02-22 00:56:52 -08:00
|
|
|
setupCommand 'setupMonitoringUser',
|
2018-04-11 11:36:12 -04:00
|
|
|
'bin/elasticsearch-users', 'useradd', 'monitoring_agent', '-p', 'x-pack-test-password', '-r', 'remote_monitoring_agent'
|
2017-02-22 00:56:52 -08:00
|
|
|
|
|
|
|
waitCondition = { NodeInfo node, AntBuilder ant ->
|
2019-04-04 21:44:03 +11:00
|
|
|
WaitForHttpResource http = new WaitForHttpResource("https", node.httpUri(), numNodes)
|
|
|
|
http.setTrustStoreFile(clientKeyStore)
|
|
|
|
http.setTrustStorePassword("testclient")
|
|
|
|
http.setUsername("test_user")
|
|
|
|
http.setPassword("x-pack-test-password")
|
|
|
|
return http.wait(5000)
|
2015-11-24 23:19:04 -05:00
|
|
|
}
|
2015-11-28 18:07:37 -08:00
|
|
|
}
|
2015-12-03 23:36:35 -08:00
|
|
|
|
|
|
|
ext.expansions = [
|
|
|
|
'expected.plugins.count': pluginsCount
|
|
|
|
]
|
|
|
|
|
|
|
|
processTestResources {
|
|
|
|
from(sourceSets.test.resources.srcDirs) {
|
2017-05-18 11:07:42 +10:00
|
|
|
include '**/*.yml'
|
2015-12-03 23:36:35 -08:00
|
|
|
inputs.properties(expansions)
|
|
|
|
MavenFilteringHack.filter(it, expansions)
|
|
|
|
}
|
2018-08-21 20:03:28 -04:00
|
|
|
}
|