2017-09-14 17:57:28 -04:00
|
|
|
import org.elasticsearch.gradle.LoggedExec
|
2017-02-11 12:12:26 -05:00
|
|
|
import org.elasticsearch.gradle.MavenFilteringHack
|
|
|
|
import org.elasticsearch.gradle.test.NodeInfo
|
2016-11-21 04:52:55 -05:00
|
|
|
|
2016-09-29 06:03:14 -04:00
|
|
|
import java.nio.charset.StandardCharsets
|
|
|
|
import java.nio.file.Files
|
|
|
|
import java.nio.file.Path
|
|
|
|
import java.nio.file.StandardCopyOption
|
2018-01-20 00:30:17 -05:00
|
|
|
import org.elasticsearch.gradle.test.RunTask;
|
2016-07-25 20:09:54 -04:00
|
|
|
|
2018-01-20 00:30:17 -05:00
|
|
|
apply plugin: 'elasticsearch.es-meta-plugin'
|
2016-09-29 06:03:14 -04:00
|
|
|
|
2016-10-03 19:38:04 -04:00
|
|
|
archivesBaseName = 'x-pack' // for api jar
|
2016-09-29 06:03:14 -04:00
|
|
|
|
2018-01-20 00:30:17 -05:00
|
|
|
es_meta_plugin {
|
|
|
|
name = 'x-pack'
|
|
|
|
description = 'Elasticsearch Expanded Pack Plugin'
|
|
|
|
plugins = ['core', 'deprecation', 'graph', 'logstash',
|
2018-01-22 16:52:16 -05:00
|
|
|
'ml', 'monitoring', 'security', 'upgrade', 'watcher', 'sql']
|
2016-09-29 06:03:14 -04:00
|
|
|
}
|
|
|
|
|
2018-01-20 00:30:17 -05:00
|
|
|
dependencies {
|
2018-01-27 00:48:30 -05:00
|
|
|
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
2017-10-09 06:06:12 -04:00
|
|
|
}
|
|
|
|
|
2018-01-20 00:30:17 -05:00
|
|
|
// https://github.com/elastic/x-plugins/issues/724
|
|
|
|
configurations {
|
|
|
|
testArtifacts.extendsFrom testRuntime
|
2017-04-10 07:40:07 -04:00
|
|
|
}
|
|
|
|
|
2018-01-20 00:30:17 -05:00
|
|
|
task testJar(type: Jar) {
|
|
|
|
appendix 'test'
|
|
|
|
from sourceSets.test.output
|
2016-02-03 11:21:55 -05:00
|
|
|
}
|
2018-01-20 00:30:17 -05:00
|
|
|
artifacts {
|
|
|
|
testArtifacts testJar
|
2016-09-29 06:03:14 -04:00
|
|
|
}
|
|
|
|
|
2017-02-22 03:56:52 -05:00
|
|
|
integTestRunner {
|
2018-01-23 01:58:34 -05:00
|
|
|
/*
|
|
|
|
* We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each
|
|
|
|
* other if we allow them to set the number of available processors as it's set-once in Netty.
|
|
|
|
*/
|
|
|
|
systemProperty 'es.set.netty.runtime.available.processors', 'false'
|
|
|
|
|
|
|
|
|
2016-09-29 06:03:14 -04:00
|
|
|
// TODO: fix this rest test to not depend on a hardcoded port!
|
2017-09-19 19:56:11 -04:00
|
|
|
def blacklist = ['getting_started/10_monitor_cluster_health/*']
|
|
|
|
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"))
|
|
|
|
if (!snapshot) {
|
|
|
|
// these tests attempt to install basic/internal licenses signed against the dev/public.key
|
|
|
|
// Since there is no infrastructure in place (anytime soon) to generate licenses using the production
|
|
|
|
// private key, these tests are whitelisted in non-snapshot test runs
|
|
|
|
blacklist.addAll(['xpack/15_basic/*', 'license/20_put_license/*'])
|
|
|
|
}
|
|
|
|
systemProperty 'tests.rest.blacklist', blacklist.join(',')
|
2017-02-22 03:56:52 -05:00
|
|
|
}
|
|
|
|
|
2017-09-14 17:57:28 -04:00
|
|
|
// location of generated keystores and certificates
|
|
|
|
File keystoreDir = new File(project.buildDir, 'keystore')
|
|
|
|
|
|
|
|
// Generate the node's keystore
|
|
|
|
File nodeKeystore = new File(keystoreDir, 'test-node.jks')
|
|
|
|
task createNodeKeyStore(type: LoggedExec) {
|
|
|
|
doFirst {
|
|
|
|
if (nodeKeystore.parentFile.exists() == false) {
|
|
|
|
nodeKeystore.parentFile.mkdirs()
|
|
|
|
}
|
|
|
|
if (nodeKeystore.exists()) {
|
|
|
|
delete nodeKeystore
|
|
|
|
}
|
|
|
|
}
|
2018-01-16 13:45:42 -05:00
|
|
|
executable = new File(project.runtimeJavaHome, 'bin/keytool')
|
2017-09-14 17:57:28 -04:00
|
|
|
standardInput = new ByteArrayInputStream('FirstName LastName\nUnit\nOrganization\nCity\nState\nNL\nyes\n\n'.getBytes('UTF-8'))
|
|
|
|
args '-genkey',
|
|
|
|
'-alias', 'test-node',
|
|
|
|
'-keystore', nodeKeystore,
|
|
|
|
'-keyalg', 'RSA',
|
|
|
|
'-keysize', '2048',
|
|
|
|
'-validity', '712',
|
|
|
|
'-dname', 'CN=smoke-test-plugins-ssl',
|
|
|
|
'-keypass', 'keypass',
|
|
|
|
'-storepass', 'keypass'
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add keystores to test classpath: it expects it there
|
|
|
|
sourceSets.test.resources.srcDir(keystoreDir)
|
|
|
|
processTestResources.dependsOn(createNodeKeyStore)
|
|
|
|
|
2017-02-22 03:56:52 -05:00
|
|
|
integTestCluster {
|
2017-09-14 17:57:28 -04:00
|
|
|
dependsOn createNodeKeyStore
|
2017-02-22 03:56:52 -05:00
|
|
|
setting 'xpack.ml.enabled', 'true'
|
2017-04-20 12:18:11 -04:00
|
|
|
setting 'logger.org.elasticsearch.xpack.ml.datafeed', 'TRACE'
|
2017-04-04 08:44:40 -04:00
|
|
|
// Integration tests are supposed to enable/disable exporters before/after each test
|
|
|
|
setting 'xpack.monitoring.exporters._local.type', 'local'
|
|
|
|
setting 'xpack.monitoring.exporters._local.enabled', 'false'
|
|
|
|
setting 'xpack.monitoring.collection.interval', '-1'
|
2017-08-23 06:21:30 -04:00
|
|
|
setting 'xpack.security.authc.token.enabled', 'true'
|
2017-09-14 17:57:28 -04:00
|
|
|
setting 'xpack.security.transport.ssl.enabled', 'true'
|
|
|
|
setting 'xpack.security.transport.ssl.keystore.path', nodeKeystore.name
|
|
|
|
setting 'xpack.security.transport.ssl.verification_mode', 'certificate'
|
2017-11-22 10:35:18 -05:00
|
|
|
setting 'xpack.security.audit.enabled', 'true'
|
2017-07-14 17:41:42 -04:00
|
|
|
keystoreSetting 'bootstrap.password', 'x-pack-test-password'
|
2017-09-14 17:57:28 -04:00
|
|
|
keystoreSetting 'xpack.security.transport.ssl.keystore.secure_password', 'keypass'
|
2017-05-11 14:23:55 -04:00
|
|
|
distribution = 'zip' // this is important since we use the reindex module in ML
|
2017-04-04 08:44:40 -04:00
|
|
|
|
2017-07-13 20:59:50 -04:00
|
|
|
setupCommand 'setupTestUser', 'bin/x-pack/users', 'useradd', 'x_pack_rest_user', '-p', 'x-pack-test-password', '-r', 'superuser'
|
|
|
|
|
2017-09-14 17:57:28 -04:00
|
|
|
extraConfigFile nodeKeystore.name, nodeKeystore
|
|
|
|
|
2017-02-22 03:56:52 -05:00
|
|
|
waitCondition = { NodeInfo node, AntBuilder ant ->
|
|
|
|
File tmpFile = new File(node.cwd, 'wait.success')
|
2017-06-29 16:27:57 -04:00
|
|
|
|
2017-02-22 03:56:52 -05:00
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
// we use custom wait logic here as the elastic user is not available immediately and ant.get will fail when a 401 is returned
|
|
|
|
HttpURLConnection httpURLConnection = null;
|
|
|
|
try {
|
2017-03-15 13:23:26 -04:00
|
|
|
httpURLConnection = (HttpURLConnection) new URL("http://${node.httpUri()}/_cluster/health?wait_for_nodes=${numNodes}&wait_for_status=yellow").openConnection();
|
2017-02-22 03:56:52 -05:00
|
|
|
httpURLConnection.setRequestProperty("Authorization", "Basic " +
|
2017-07-13 20:59:50 -04:00
|
|
|
Base64.getEncoder().encodeToString("x_pack_rest_user:x-pack-test-password".getBytes(StandardCharsets.UTF_8)));
|
2017-02-22 03:56:52 -05:00
|
|
|
httpURLConnection.setRequestMethod("GET");
|
|
|
|
httpURLConnection.connect();
|
|
|
|
if (httpURLConnection.getResponseCode() == 200) {
|
|
|
|
tmpFile.withWriter StandardCharsets.UTF_8.name(), {
|
|
|
|
it.write(httpURLConnection.getInputStream().getText(StandardCharsets.UTF_8.name()))
|
2016-09-29 06:03:14 -04:00
|
|
|
}
|
|
|
|
}
|
2017-02-22 03:56:52 -05:00
|
|
|
} catch (Exception e) {
|
|
|
|
if (i == 9) {
|
|
|
|
logger.error("final attempt of calling cluster health failed", e)
|
|
|
|
} else {
|
|
|
|
logger.debug("failed to call cluster health", e)
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
if (httpURLConnection != null) {
|
|
|
|
httpURLConnection.disconnect();
|
|
|
|
}
|
2016-09-29 06:03:14 -04:00
|
|
|
}
|
2017-02-22 03:56:52 -05:00
|
|
|
|
|
|
|
// did not start, so wait a bit before trying again
|
|
|
|
Thread.sleep(500L);
|
|
|
|
}
|
|
|
|
return tmpFile.exists()
|
2016-09-29 06:03:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-05 11:45:17 -05:00
|
|
|
run {
|
2017-02-08 11:58:57 -05:00
|
|
|
setting 'xpack.ml.enabled', 'true'
|
2017-01-05 11:45:17 -05:00
|
|
|
setting 'xpack.graph.enabled', 'true'
|
|
|
|
setting 'xpack.security.enabled', 'true'
|
|
|
|
setting 'xpack.monitoring.enabled', 'true'
|
|
|
|
setting 'xpack.watcher.enabled', 'true'
|
2018-01-22 16:52:16 -05:00
|
|
|
setting 'xpack.sql.enabled', 'true'
|
2017-07-14 17:41:42 -04:00
|
|
|
keystoreSetting 'bootstrap.password', 'password'
|
2017-01-05 11:45:17 -05:00
|
|
|
}
|