2015-11-25 03:13:59 -05:00
|
|
|
import org.elasticsearch.gradle.LoggedExec
|
2015-12-04 02:36:35 -05:00
|
|
|
import org.elasticsearch.gradle.MavenFilteringHack
|
2015-11-25 03:13:59 -05:00
|
|
|
|
2015-11-24 23:19:04 -05:00
|
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
|
|
|
|
dependencies {
|
2015-11-25 18:28:45 -05:00
|
|
|
testCompile project(path: ':x-plugins:elasticsearch:x-pack', configuration: 'runtime')
|
2015-11-24 23:19:04 -05:00
|
|
|
}
|
|
|
|
|
2015-11-25 03:13:59 -05:00
|
|
|
// location of keystore and files to generate it
|
2015-11-24 23:19:04 -05:00
|
|
|
File keystore = new File(project.buildDir, 'keystore/test-node.jks')
|
|
|
|
|
2015-11-25 03:13:59 -05:00
|
|
|
// generate the keystore
|
|
|
|
task createKey(type: LoggedExec) {
|
|
|
|
doFirst {
|
|
|
|
project.delete(keystore.parentFile)
|
|
|
|
keystore.parentFile.mkdirs()
|
2015-11-24 23:19:04 -05:00
|
|
|
}
|
2015-12-14 22:48:56 -05:00
|
|
|
String subjectAlternateNames = 'san=dns:localhost,ip:127.0.0.1'
|
|
|
|
// some machines have a different name for ipv6 loopback,
|
2015-12-15 01:04:37 -05:00
|
|
|
// at least on ubuntu its ip6-localhost. other machines, like windows,
|
|
|
|
// won't resolve it back to any hostname at all. Try to setup ipv6 to
|
|
|
|
// work in all cases.
|
2015-12-14 22:48:56 -05:00
|
|
|
try {
|
|
|
|
String localhost6 = InetAddress.getByName("::1").getCanonicalHostName()
|
|
|
|
if (!localhost6.equals("localhost")) {
|
2015-12-15 01:04:37 -05:00
|
|
|
if (localhost6.startsWith("0")) {
|
|
|
|
subjectAlternateNames += ",ip:" + localhost6
|
|
|
|
} else {
|
|
|
|
subjectAlternateNames += ",dns:" + localhost6
|
|
|
|
}
|
2015-12-14 22:48:56 -05:00
|
|
|
}
|
|
|
|
} catch (UnknownHostException ok) {
|
|
|
|
// e.g. no ipv6 support
|
|
|
|
}
|
2015-11-25 03:13:59 -05:00
|
|
|
executable = 'keytool'
|
|
|
|
standardInput = new ByteArrayInputStream('FirstName LastName\nUnit\nOrganization\nCity\nState\nNL\nyes\n\n'.getBytes('UTF-8'))
|
|
|
|
args '-genkey',
|
|
|
|
'-alias', 'test-node',
|
|
|
|
'-keystore', keystore,
|
|
|
|
'-keyalg', 'RSA',
|
|
|
|
'-keysize', '2048',
|
|
|
|
'-validity', '712',
|
2015-12-14 22:48:56 -05:00
|
|
|
'-ext', subjectAlternateNames,
|
2015-11-25 03:13:59 -05:00
|
|
|
'-storepass', 'keypass'
|
2015-11-24 23:19:04 -05:00
|
|
|
}
|
|
|
|
|
2015-11-25 03:13:59 -05:00
|
|
|
// add keystore to test classpath: it expects it there
|
|
|
|
sourceSets.test.resources.srcDir(keystore.parentFile)
|
2015-11-30 09:28:16 -05:00
|
|
|
processTestResources.dependsOn(createKey)
|
2015-11-25 03:13:59 -05:00
|
|
|
|
2015-12-04 14:52:31 -05:00
|
|
|
ext.pluginsCount = 1 // we install xpack explicitly
|
2015-12-04 02:36:35 -05:00
|
|
|
project.rootProject.subprojects.findAll { it.path.startsWith(':plugins:') }.each { subproj ->
|
|
|
|
// need to get a non-decorated project object, so must re-lookup the project by path
|
|
|
|
integTest.cluster.plugin(subproj.name, project(subproj.path))
|
|
|
|
pluginsCount += 1
|
2015-11-25 03:13:59 -05:00
|
|
|
}
|
2015-11-24 23:19:04 -05:00
|
|
|
|
|
|
|
integTest {
|
|
|
|
cluster {
|
2015-11-25 03:13:59 -05:00
|
|
|
systemProperty 'es.marvel.agent.exporter.es.ssl.truststore.path', keystore.name
|
2015-11-24 23:19:04 -05:00
|
|
|
systemProperty 'es.marvel.agent.exporter.es.ssl.truststore.password', 'keypass'
|
|
|
|
systemProperty 'es.shield.transport.ssl', 'true'
|
|
|
|
systemProperty 'es.shield.http.ssl', 'true'
|
2015-11-25 03:13:59 -05:00
|
|
|
systemProperty 'es.shield.ssl.keystore.path', keystore.name
|
2015-11-24 23:19:04 -05:00
|
|
|
systemProperty 'es.shield.ssl.keystore.password', 'keypass'
|
2015-11-25 18:28:45 -05:00
|
|
|
plugin 'x-pack', project(':x-plugins:elasticsearch:x-pack')
|
2015-11-24 23:19:04 -05:00
|
|
|
|
|
|
|
// copy keystore into config/
|
2015-11-25 03:13:59 -05:00
|
|
|
extraConfigFile keystore.name, keystore
|
2015-11-24 23:19:04 -05:00
|
|
|
setupCommand 'setupTestUser',
|
2015-12-01 09:57:01 -05:00
|
|
|
'bin/x-pack/esusers', 'useradd', 'test_user', '-p', 'changeme', '-r', 'admin'
|
2015-11-24 23:19:04 -05:00
|
|
|
setupCommand 'setupMarvelUser',
|
2015-12-01 09:57:01 -05:00
|
|
|
'bin/x-pack/esusers', 'useradd', 'marvel_export', '-p', 'changeme', '-r', 'marvel_agent'
|
2015-11-24 23:19:04 -05:00
|
|
|
waitCondition = { node, ant ->
|
|
|
|
// we just return true, doing an https check is tricky here
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
2015-11-28 21:07:37 -05:00
|
|
|
}
|
2015-12-04 02:36:35 -05:00
|
|
|
|
|
|
|
ext.expansions = [
|
|
|
|
'expected.plugins.count': pluginsCount
|
|
|
|
]
|
|
|
|
|
|
|
|
processTestResources {
|
|
|
|
from(sourceSets.test.resources.srcDirs) {
|
|
|
|
include '**/*.yaml'
|
|
|
|
inputs.properties(expansions)
|
|
|
|
MavenFilteringHack.filter(it, expansions)
|
|
|
|
}
|
|
|
|
}
|