2017-04-21 12:51:14 -04:00
|
|
|
import org.elasticsearch.gradle.LoggedExec
|
|
|
|
import org.elasticsearch.gradle.VersionProperties
|
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets
|
|
|
|
import java.nio.file.Files
|
|
|
|
import java.util.stream.Stream
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
apply plugin: 'war'
|
|
|
|
apply plugin: 'elasticsearch.build'
|
|
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
|
2018-01-01 16:27:30 -05:00
|
|
|
final String wildflyVersion = '11.0.0.Final'
|
2017-04-21 12:51:14 -04:00
|
|
|
final String wildflyDir = "${buildDir}/wildfly"
|
|
|
|
final String wildflyInstall = "${buildDir}/wildfly/wildfly-${wildflyVersion}"
|
2018-01-01 16:27:30 -05:00
|
|
|
int managementPort
|
2017-04-21 12:51:14 -04:00
|
|
|
|
|
|
|
repositories {
|
|
|
|
// the Wildfly distribution is not available via a repository, so we fake an Ivy repository on top of the download site
|
|
|
|
ivy {
|
2017-04-23 11:38:16 -04:00
|
|
|
url "http://download.jboss.org"
|
2018-12-05 07:06:11 -05:00
|
|
|
patternLayout {
|
2017-04-21 12:51:14 -04:00
|
|
|
artifact 'wildfly/[revision]/[module]-[revision].[ext]'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configurations {
|
|
|
|
wildfly
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
providedCompile 'javax.enterprise:cdi-api:1.2'
|
|
|
|
providedCompile 'org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:1.0.0.Final'
|
|
|
|
providedCompile 'org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.0_spec:1.0.0.Final'
|
|
|
|
compile ('org.jboss.resteasy:resteasy-jackson2-provider:3.0.19.Final') {
|
|
|
|
exclude module: 'jackson-annotations'
|
|
|
|
exclude module: 'jackson-core'
|
|
|
|
exclude module: 'jackson-databind'
|
|
|
|
exclude module: 'jackson-jaxrs-json-provider'
|
|
|
|
}
|
|
|
|
compile "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
|
|
|
|
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
|
|
|
|
compile "com.fasterxml.jackson.core:jackson-databind:${versions.jackson}"
|
|
|
|
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:${versions.jackson}"
|
|
|
|
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:${versions.jackson}"
|
|
|
|
compile "com.fasterxml.jackson.module:jackson-module-jaxb-annotations:${versions.jackson}"
|
|
|
|
compile "org.apache.logging.log4j:log4j-api:${versions.log4j}"
|
|
|
|
compile "org.apache.logging.log4j:log4j-core:${versions.log4j}"
|
|
|
|
compile project(path: ':client:transport', configuration: 'runtime')
|
|
|
|
wildfly "org.jboss:wildfly:${wildflyVersion}@zip"
|
|
|
|
testCompile "org.elasticsearch.test:framework:${VersionProperties.elasticsearch}"
|
|
|
|
}
|
|
|
|
|
|
|
|
task unzipWildfly(type: Sync) {
|
|
|
|
into wildflyDir
|
|
|
|
from { zipTree(configurations.wildfly.singleFile) }
|
|
|
|
}
|
|
|
|
|
|
|
|
task deploy(type: Copy) {
|
|
|
|
dependsOn unzipWildfly, war
|
|
|
|
from war
|
|
|
|
into "${wildflyInstall}/standalone/deployments"
|
|
|
|
}
|
|
|
|
|
|
|
|
task writeElasticsearchProperties {
|
2018-08-13 14:08:10 -04:00
|
|
|
onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) }
|
2017-04-21 12:51:14 -04:00
|
|
|
dependsOn 'integTestCluster#wait', deploy
|
|
|
|
doLast {
|
2017-04-22 10:41:57 -04:00
|
|
|
final File elasticsearchProperties = file("${wildflyInstall}/standalone/configuration/elasticsearch.properties")
|
2017-04-21 12:51:14 -04:00
|
|
|
elasticsearchProperties.write(
|
|
|
|
[
|
|
|
|
"transport.uri=${-> integTest.getNodes().get(0).transportUri()}",
|
|
|
|
"cluster.name=${-> integTest.getNodes().get(0).clusterName}"
|
|
|
|
].join("\n"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// the default configuration ships with IPv6 disabled but our cluster could be bound to IPv6 if the host supports it
|
|
|
|
task enableIPv6 {
|
|
|
|
dependsOn unzipWildfly
|
|
|
|
doLast {
|
|
|
|
final File standaloneConf = file("${wildflyInstall}/bin/standalone.conf")
|
|
|
|
final List<String> lines =
|
|
|
|
Files.readAllLines(standaloneConf.toPath())
|
|
|
|
.collect { line -> line.replace("-Djava.net.preferIPv4Stack=true", "-Djava.net.preferIPv4Stack=false") }
|
|
|
|
standaloneConf.write(lines.join("\n"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task startWildfly {
|
|
|
|
dependsOn enableIPv6, writeElasticsearchProperties
|
|
|
|
doLast {
|
|
|
|
// we skip these tests on Windows so we do no need to worry about compatibility here
|
2018-01-01 16:27:30 -05:00
|
|
|
final ProcessBuilder wildfly = new ProcessBuilder(
|
|
|
|
"${wildflyInstall}/bin/standalone.sh",
|
|
|
|
"-Djboss.http.port=0",
|
|
|
|
"-Djboss.https.port=0",
|
|
|
|
"-Djboss.management.http.port=0")
|
|
|
|
final Process process = wildfly.start()
|
2017-04-21 12:51:14 -04:00
|
|
|
new BufferedReader(new InputStreamReader(process.getInputStream())).withReader { br ->
|
|
|
|
String line
|
2018-01-01 16:27:30 -05:00
|
|
|
int httpPort = 0
|
2017-04-21 12:51:14 -04:00
|
|
|
while ((line = br.readLine()) != null) {
|
2018-03-16 10:50:37 -04:00
|
|
|
logger.info(line)
|
2018-01-01 16:27:30 -05:00
|
|
|
if (line.matches('.*Undertow HTTP listener default listening on .*:\\d+$')) {
|
|
|
|
assert httpPort == 0
|
|
|
|
final int index = line.lastIndexOf(":")
|
|
|
|
assert index >= 0
|
|
|
|
httpPort = Integer.parseInt(line.substring(index + 1))
|
|
|
|
// set this system property so the test runner knows the port Wildfly is listening for HTTP requests on
|
2018-11-07 07:01:05 -05:00
|
|
|
integTestRunner.systemProperty("tests.jboss.root", "http://localhost:$httpPort/wildfly-$version/transport")
|
2018-01-01 16:27:30 -05:00
|
|
|
} else if (line.matches('.*Http management interface listening on http://.*:\\d+/management$')) {
|
2018-01-01 18:03:15 -05:00
|
|
|
assert managementPort == 0
|
2018-01-01 16:27:30 -05:00
|
|
|
final int colonIndex = line.lastIndexOf(":")
|
|
|
|
assert colonIndex >= 0
|
|
|
|
final int slashIndex = line.lastIndexOf("/")
|
|
|
|
assert slashIndex >= 0
|
|
|
|
managementPort = Integer.parseInt(line.substring(colonIndex + 1, slashIndex))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* As soon as we know the management port, we fork a process that will ensure the Wildfly process is killed if we
|
2018-01-01 16:29:53 -05:00
|
|
|
* teardown abnormally. We skip these tests on Windows so we do not need to worry about CLI compatibility here.
|
2018-01-01 16:27:30 -05:00
|
|
|
*/
|
|
|
|
final File script = new File(project.buildDir, "wildfly/wildfly.killer.sh")
|
|
|
|
script.setText(
|
|
|
|
["function shutdown {",
|
|
|
|
" ${wildflyInstall}/bin/jboss-cli.sh --controller=localhost:${-> managementPort} --connect command=shutdown",
|
|
|
|
"}",
|
|
|
|
"trap shutdown EXIT",
|
|
|
|
// will wait indefinitely for input, but we never pass input, and the pipe is only closed when the build dies
|
|
|
|
"read line\n"].join('\n'), 'UTF-8')
|
|
|
|
final ProcessBuilder killer = new ProcessBuilder("bash", script.absolutePath)
|
|
|
|
killer.start()
|
|
|
|
|
|
|
|
} else if (line.matches(".*WildFly Full \\d+\\.\\d+\\.\\d+\\.Final \\(WildFly Core \\d+\\.\\d+\\.\\d+\\.Final\\) started.*")) {
|
2017-04-21 12:51:14 -04:00
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2018-01-01 16:27:30 -05:00
|
|
|
|
|
|
|
assert httpPort > 0
|
|
|
|
assert managementPort > 0
|
2017-04-21 12:51:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task configureTransportClient(type: LoggedExec) {
|
|
|
|
dependsOn startWildfly
|
2017-04-22 10:41:57 -04:00
|
|
|
// we skip these tests on Windows so we do not need to worry about compatibility here
|
2017-04-21 12:51:14 -04:00
|
|
|
commandLine "${wildflyInstall}/bin/jboss-cli.sh",
|
2018-01-01 16:27:30 -05:00
|
|
|
"--controller=localhost:${-> managementPort}",
|
2017-04-21 12:51:14 -04:00
|
|
|
"--connect",
|
|
|
|
"--command=/system-property=elasticsearch.properties:add(value=\${jboss.server.config.dir}/elasticsearch.properties)"
|
|
|
|
}
|
|
|
|
|
|
|
|
task stopWildfly(type: LoggedExec) {
|
2018-01-01 16:29:53 -05:00
|
|
|
// we skip these tests on Windows so we do not need to worry about CLI compatibility here
|
2018-01-01 16:27:30 -05:00
|
|
|
commandLine "${wildflyInstall}/bin/jboss-cli.sh", "--controller=localhost:${-> managementPort}", "--connect", "command=shutdown"
|
2017-04-21 12:51:14 -04:00
|
|
|
}
|
|
|
|
|
2018-08-13 14:08:10 -04:00
|
|
|
if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
|
2017-04-21 12:51:14 -04:00
|
|
|
integTestRunner.dependsOn(configureTransportClient)
|
|
|
|
final TaskExecutionAdapter logDumpListener = new TaskExecutionAdapter() {
|
|
|
|
@Override
|
|
|
|
void afterExecute(final Task task, final TaskState state) {
|
|
|
|
if (state.failure != null) {
|
|
|
|
final File logFile = new File(wildflyInstall, "standalone/log/server.log")
|
|
|
|
println("\nWildfly server log (from ${logFile}):")
|
|
|
|
println('-----------------------------------------')
|
|
|
|
final Stream<String> stream = Files.lines(logFile.toPath(), StandardCharsets.UTF_8)
|
|
|
|
try {
|
|
|
|
for (String line : stream) {
|
|
|
|
println(line)
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
stream.close()
|
|
|
|
}
|
|
|
|
println('=========================================')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
integTestRunner.doFirst {
|
|
|
|
project.gradle.addListener(logDumpListener)
|
|
|
|
}
|
|
|
|
integTestRunner.doLast {
|
|
|
|
project.gradle.removeListener(logDumpListener)
|
|
|
|
}
|
|
|
|
integTestRunner.finalizedBy(stopWildfly)
|
|
|
|
} else {
|
|
|
|
integTest.enabled = false
|
|
|
|
}
|
|
|
|
|
|
|
|
check.dependsOn(integTest)
|
|
|
|
|
2018-12-19 01:25:20 -05:00
|
|
|
unitTest.enabled = false
|
2017-04-21 12:51:14 -04:00
|
|
|
|
|
|
|
dependencyLicenses.enabled = false
|
2017-12-26 04:51:47 -05:00
|
|
|
dependenciesInfo.enabled = false
|
2017-04-21 12:51:14 -04:00
|
|
|
|
|
|
|
thirdPartyAudit.enabled = false
|
2019-01-08 06:39:03 -05:00
|
|
|
|
|
|
|
|
|
|
|
testingConventions {
|
|
|
|
naming.clear()
|
|
|
|
// We only have one "special" integration test here to connect to wildfly
|
|
|
|
naming {
|
|
|
|
IT {
|
|
|
|
baseClass 'org.apache.lucene.util.LuceneTestCase'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|