-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Wildfly integration test #24147
Merged
Merged
Add Wildfly integration test #24147
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c7ca50e
Add Wildfly integration test
jasontedor b09dd20
Dump Wildfly server logs on test failure
jasontedor 7912235
Add Log4j configuration file
jasontedor d7efafb
Cleanup
jasontedor 06cc105
Remove unused import
jasontedor 15394b4
Fix ordering
jasontedor f8a3f72
Add a proper package for test
jasontedor 2c800ce
Add comments about Windows
jasontedor b0cef6a
Merge branch 'master' into wildfly
jasontedor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
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' | ||
|
||
final String wildflyVersion = '10.0.0.Final' | ||
final String wildflyDir = "${buildDir}/wildfly" | ||
final String wildflyInstall = "${buildDir}/wildfly/wildfly-${wildflyVersion}" | ||
// TODO: use ephemeral ports | ||
final int portOffset = 30000 | ||
final int managementPort = 9990 + portOffset | ||
// we skip these tests on Windows so we do no need to worry about compatibility here | ||
final String stopWildflyCommand = "${wildflyInstall}/bin/jboss-cli.sh --controller=localhost:${managementPort} --connect command=:shutdown" | ||
|
||
repositories { | ||
mavenCentral() | ||
// the Wildfly distribution is not available via a repository, so we fake an Ivy repository on top of the download site | ||
ivy { | ||
url "http://download.jboss.org" | ||
layout 'pattern', { | ||
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 { | ||
onlyIf { !Os.isFamily(Os.FAMILY_WINDOWS) } | ||
dependsOn 'integTestCluster#wait', deploy | ||
doLast { | ||
final File elasticsearchProperties = | ||
file("${wildflyInstall}/standalone/configuration/elasticsearch.properties") | ||
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 | ||
doFirst { | ||
// we skip these tests on Windows so we do no need to worry about compatibility here | ||
final File script = new File(project.buildDir, "wildfly/wildfly.killer.sh") | ||
script.setText( | ||
["function shutdown {", | ||
" ${stopWildflyCommand}", | ||
"}", | ||
"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"].join('\n'), 'UTF-8') | ||
final ProcessBuilder pb = new ProcessBuilder("bash", script.absolutePath) | ||
pb.start() | ||
} | ||
doLast { | ||
// we skip these tests on Windows so we do no need to worry about compatibility here | ||
final ProcessBuilder pb = | ||
new ProcessBuilder("${wildflyInstall}/bin/standalone.sh", "-Djboss.socket.binding.port-offset=${portOffset}") | ||
final Process process = pb.start() | ||
new BufferedReader(new InputStreamReader(process.getInputStream())).withReader { br -> | ||
String line | ||
while ((line = br.readLine()) != null) { | ||
if (line.matches(".*WildFly Full \\d+\\.\\d+\\.\\d+\\.Final \\(WildFly Core \\d+\\.\\d+\\.\\d+\\.Final\\) started.*")) { | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
task configureTransportClient(type: LoggedExec) { | ||
dependsOn startWildfly | ||
// we skip these tests on Windows so we do no need to worry about compatibility here | ||
commandLine "${wildflyInstall}/bin/jboss-cli.sh", | ||
"--controller=localhost:${managementPort}", | ||
"--connect", | ||
"--command=/system-property=elasticsearch.properties:add(value=\${jboss.server.config.dir}/elasticsearch.properties)" | ||
} | ||
|
||
task stopWildfly(type: LoggedExec) { | ||
commandLine stopWildflyCommand.split(' ') | ||
} | ||
|
||
if (!Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
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) | ||
|
||
test.enabled = false | ||
|
||
dependencyLicenses.enabled = false | ||
|
||
thirdPartyAudit.enabled = false |
87 changes: 87 additions & 0 deletions
87
qa/wildfly/src/main/java/org/elasticsearch/wildfly/model/Employee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.elasticsearch.wildfly.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import java.util.List; | ||
|
||
@Consumes(MediaType.APPLICATION_JSON) | ||
public class Employee { | ||
|
||
@JsonProperty(value = "first_name") | ||
private String firstName; | ||
|
||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
@JsonProperty(value = "last_name") | ||
private String lastName; | ||
|
||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
@JsonProperty(value = "age") | ||
private int age; | ||
|
||
public int getAge() { | ||
return age; | ||
} | ||
|
||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
|
||
@JsonProperty(value = "about") | ||
private String about; | ||
|
||
public String getAbout() { | ||
return about; | ||
} | ||
|
||
public void setAbout(String about) { | ||
this.about = about; | ||
} | ||
|
||
@JsonProperty(value = "interests") | ||
private List<String> interests; | ||
|
||
public List<String> getInterests() { | ||
return interests; | ||
} | ||
|
||
public void setInterests(List<String> interests) { | ||
this.interests = interests; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
qa/wildfly/src/main/java/org/elasticsearch/wildfly/transport/TransportClientActivator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.elasticsearch.wildfly.transport; | ||
|
||
import javax.ws.rs.ApplicationPath; | ||
import javax.ws.rs.core.Application; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
@ApplicationPath("/transport") | ||
public class TransportClientActivator extends Application { | ||
|
||
@Override | ||
public Set<Class<?>> getClasses() { | ||
return Collections.singleton(TransportClientEmployeeResource.class); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a qa test should have any of these tasks at all. Why isn't this using the standalone-rest-test plugin like other qa tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it defines a test source set and so does war and thus there's a conflict. Maybe you can show me a better way out of that situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with @rjernst. We are going to create an examples directory and we can move the generation of the war to a subproject there. This test subproject can depend on that artifact. That will enable this subproject to depend apply standalone-rest-test. This will be done a follow-up.