2017-07-03 14:49:43 -04:00
|
|
|
import org.elasticsearch.gradle.test.RunTask
|
|
|
|
|
2017-06-19 15:19:54 -04:00
|
|
|
apply plugin: 'elasticsearch.build'
|
2017-07-07 10:32:23 -04:00
|
|
|
/* We don't use the 'application' plugin because it builds a zip and tgz which
|
|
|
|
* we don't want. */
|
2017-06-21 12:12:19 -04:00
|
|
|
|
|
|
|
description = 'Command line interface to Elasticsearch that speaks SQL'
|
2017-06-19 15:19:54 -04:00
|
|
|
|
|
|
|
dependencies {
|
2017-06-28 17:22:32 -04:00
|
|
|
compile "org.jline:jline:3.3.1"
|
2017-06-29 14:31:23 -04:00
|
|
|
compile project(':x-pack-elasticsearch:sql:net-client')
|
|
|
|
compile project(':x-pack-elasticsearch:sql:cli-proto')
|
2017-07-12 17:32:13 -04:00
|
|
|
compile project(':x-pack-elasticsearch:sql:shared-proto')
|
2017-06-19 15:19:54 -04:00
|
|
|
|
2017-07-12 17:32:13 -04:00
|
|
|
// Used by embedded sql instance
|
|
|
|
testCompile project(":x-pack-elasticsearch:transport-client")
|
|
|
|
testCompile project(path: ':x-pack-elasticsearch:plugin', configuration: 'testArtifacts') // NOCOMMIT remove this?
|
2017-06-29 14:31:23 -04:00
|
|
|
testCompile project(':x-pack-elasticsearch:sql:test-utils')
|
2017-07-03 14:49:43 -04:00
|
|
|
|
2017-06-28 17:22:32 -04:00
|
|
|
runtime "org.fusesource.jansi:jansi:1.16"
|
2017-07-03 14:01:29 -04:00
|
|
|
runtime "org.elasticsearch:jna:4.4.0-1"
|
2017-06-19 15:19:54 -04:00
|
|
|
}
|
|
|
|
|
2017-06-20 15:53:39 -04:00
|
|
|
dependencyLicenses {
|
|
|
|
mapping from: /cli-proto.*/, to: 'elasticsearch'
|
2017-07-12 17:32:13 -04:00
|
|
|
mapping from: /shared-proto.*/, to: 'elasticsearch'
|
|
|
|
mapping from: /net.*/, to: 'elasticsearch'
|
2017-06-20 15:53:39 -04:00
|
|
|
ignoreSha 'cli-proto'
|
2017-07-12 17:32:13 -04:00
|
|
|
ignoreSha 'shared-proto'
|
2017-06-20 15:53:39 -04:00
|
|
|
ignoreSha 'net-client'
|
|
|
|
}
|
|
|
|
|
2017-06-29 14:31:23 -04:00
|
|
|
forbiddenApisMain {
|
|
|
|
// does not depend on core, so only jdk and http signatures should be checked
|
|
|
|
signaturesURLs = [this.class.getResource('/forbidden/jdk-signatures.txt')]
|
|
|
|
}
|
|
|
|
|
2017-06-19 15:19:54 -04:00
|
|
|
jar {
|
2017-07-07 10:32:23 -04:00
|
|
|
// Bundle all dependencies into the jar.
|
|
|
|
from {
|
|
|
|
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
|
|
|
|
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
|
|
|
|
}
|
|
|
|
// Make the jar "executable" with `java -jar`
|
|
|
|
manifest {
|
|
|
|
attributes 'Main-Class': 'org.elasticsearch.xpack.sql.cli.Cli'
|
|
|
|
}
|
2017-06-19 15:19:54 -04:00
|
|
|
}
|
|
|
|
|
2017-06-20 15:08:50 -04:00
|
|
|
// Needed so we can launch graphviz if it is installed
|
|
|
|
project.compactProfile = 'full'
|
2017-06-21 15:03:08 -04:00
|
|
|
|
|
|
|
forbiddenApisTest {
|
|
|
|
//we are using jdk-internal instead of jdk-non-portable to allow for com.sun.net.httpserver.* usage
|
|
|
|
bundledSignatures -= 'jdk-non-portable'
|
|
|
|
bundledSignatures += 'jdk-internal'
|
|
|
|
}
|
|
|
|
|
|
|
|
thirdPartyAudit.excludes = [
|
|
|
|
'org.apache.sshd.client.SshClient',
|
|
|
|
'org.apache.sshd.client.auth.keyboard.UserInteraction',
|
|
|
|
'org.apache.sshd.client.channel.ChannelShell',
|
|
|
|
'org.apache.sshd.client.channel.ClientChannel',
|
|
|
|
'org.apache.sshd.client.channel.ClientChannelEvent',
|
|
|
|
'org.apache.sshd.client.future.AuthFuture',
|
|
|
|
'org.apache.sshd.client.future.ConnectFuture',
|
|
|
|
'org.apache.sshd.client.future.OpenFuture',
|
|
|
|
'org.apache.sshd.client.session.ClientSession',
|
|
|
|
'org.apache.sshd.common.Factory',
|
|
|
|
'org.apache.sshd.common.channel.PtyMode',
|
|
|
|
'org.apache.sshd.common.config.keys.FilePasswordProvider',
|
|
|
|
'org.apache.sshd.common.util.io.NoCloseInputStream',
|
|
|
|
'org.apache.sshd.common.util.io.NoCloseOutputStream',
|
|
|
|
'org.apache.sshd.server.Command',
|
|
|
|
'org.apache.sshd.server.Environment',
|
|
|
|
'org.apache.sshd.server.ExitCallback',
|
|
|
|
'org.apache.sshd.server.SessionAware',
|
|
|
|
'org.apache.sshd.server.Signal',
|
|
|
|
'org.apache.sshd.server.SshServer',
|
|
|
|
'org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider',
|
|
|
|
'org.apache.sshd.server.scp.ScpCommandFactory$Builder',
|
|
|
|
'org.apache.sshd.server.session.ServerSession',
|
|
|
|
'org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory$Builder',
|
|
|
|
'org.mozilla.universalchardet.UniversalDetector'
|
|
|
|
]
|
2017-07-03 14:49:43 -04:00
|
|
|
|
|
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
integTest.mustRunAfter test
|
|
|
|
|
|
|
|
integTestCluster {
|
|
|
|
distribution = 'zip' // NOCOMMIT make double sure we want all the modules
|
|
|
|
plugin project(':x-pack-elasticsearch:plugin').path
|
|
|
|
/* Get a "clean" test without the other x-pack features here and check them
|
|
|
|
* all together later on. */
|
|
|
|
setting 'xpack.security.enabled', 'false'
|
|
|
|
setting 'xpack.monitoring.enabled', 'false'
|
|
|
|
setting 'xpack.ml.enabled', 'false'
|
|
|
|
setting 'xpack.watcher.enabled', 'false'
|
|
|
|
}
|
|
|
|
|
|
|
|
task runServer(type: RunTask) {
|
2017-07-07 10:32:23 -04:00
|
|
|
distribution = 'zip'
|
2017-07-03 14:49:43 -04:00
|
|
|
plugin project(':x-pack-elasticsearch:plugin').path
|
2017-07-07 10:32:23 -04:00
|
|
|
// Daemonize Elasticsearch so we can run the cli application
|
|
|
|
daemonize = true
|
2017-07-03 14:49:43 -04:00
|
|
|
/* Get a "clean" test without the other x-pack features here and check them
|
|
|
|
* all together later on. */
|
|
|
|
setting 'xpack.security.enabled', 'false'
|
|
|
|
setting 'xpack.monitoring.enabled', 'false'
|
|
|
|
setting 'xpack.ml.enabled', 'false'
|
|
|
|
setting 'xpack.watcher.enabled', 'false'
|
2017-07-07 10:32:23 -04:00
|
|
|
}
|
|
|
|
task run {
|
|
|
|
/* We can't use JavaExec or Exec because neither support
|
|
|
|
* ProcessBuilder.Redirect.INHERIT which is required to get full tty-support.
|
|
|
|
*/
|
|
|
|
dependsOn jar, runServer
|
|
|
|
finalizedBy 'runServer#stop'
|
|
|
|
description = 'Run the CLI and an Elasticsearch instant for it to connect to'
|
|
|
|
doLast {
|
|
|
|
List command = [new File(project.javaHome, 'bin/java').absolutePath]
|
|
|
|
if ('true'.equals(System.getProperty('debug', 'false'))) {
|
|
|
|
command += '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000'
|
|
|
|
}
|
|
|
|
command += ['-jar', jar.archivePath.absolutePath]
|
|
|
|
logger.info("command: ${command}")
|
|
|
|
|
|
|
|
new ProcessBuilder(command)
|
|
|
|
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
|
|
|
|
.redirectInput(ProcessBuilder.Redirect.INHERIT)
|
|
|
|
.redirectError(ProcessBuilder.Redirect.INHERIT)
|
|
|
|
.start()
|
|
|
|
.waitFor()
|
|
|
|
}
|
2017-07-03 14:49:43 -04:00
|
|
|
}
|
Get jdbc tests passing
`gradle check -xforbiddenPatterns` now passes in jdbc.
This makes running the embedded HTTP server slightly more difficult,
you now have to add the following to your jvm arguments.
```
-ea -Dtests.rest.cluster=localhost:9200 -Dtests.embed.sql=true -Dtests.security.manager=false
```
Depending on your environment the embedded jdbc connection may give
spurious failures that look like:
```
org.elasticsearch.xpack.sql.jdbc.jdbc.JdbcException: RemoteTransportException[[node-0][127.0.0.1:9300][indices:data/read/search]]; nested: SearchPhaseExecutionException[]; nested: GeneralScriptException[Failed to compile inline script [( params.a0 > params.v0 ) && ( params.a1 > params.v1 )] using lang [painless]]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_per_minute] setting];
...
Caused by: Failed to execute phase [fetch],
..
Caused by: GeneralScriptException[Failed to compile inline script [( params.a0 > params.v0 ) && ( params.a1 > params.v1 )] using lang [painless]]; nested: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_per_minute] setting];
...
Caused by: CircuitBreakingException[[script] Too many dynamic script compilations within one minute, max: [15/min]; please use on-disk, indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_per_minute] setting]
```
`gradle check` works around this by setting `script.max_compilations_per_minute`
to `1000`.
Another change is that we no longer support loading the test data by
uncommenting some code. Instead we load the test data into Elaticsearch
before the first test and we deleted it after the last test. This is
so that tests that required different test data can interoperate with
eachother. The spec tests all use the same test data but the metadata
tests do not.
Original commit: elastic/x-pack-elasticsearch@8b8f684ac19d4dc2d2b7bdce05caa0f1693bd937
2017-07-05 13:38:17 -04:00
|
|
|
|
|
|
|
// Allow for com.sun.net.httpserver.* usage for testing
|
|
|
|
eclipse {
|
|
|
|
classpath.file {
|
|
|
|
whenMerged { cp ->
|
|
|
|
def con = entries.find { e ->
|
|
|
|
e.kind == "con" && e.toString().contains("org.eclipse.jdt.launching.JRE_CONTAINER")
|
|
|
|
}
|
|
|
|
con.accessRules.add(new org.gradle.plugins.ide.eclipse.model.AccessRule(
|
|
|
|
"accessible", "com/sun/net/httpserver/*"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
forbiddenApisTest {
|
|
|
|
bundledSignatures -= 'jdk-non-portable'
|
|
|
|
bundledSignatures += 'jdk-internal'
|
|
|
|
}
|