Skip to content

Commit

Permalink
User container host in Jenkins to deploy and test
Browse files Browse the repository at this point in the history
  • Loading branch information
kifj committed Mar 22, 2024
1 parent 6cfe430 commit 742fd61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ node {

stage('Run IT test') {
withMaven(maven: 'Maven-3.9', mavenSettingsConfig: mavenSetting) {
sh "mvn -Parq-remote verify -Darquillian.useMappedPorts=false"
sh "mvn -Parq-remote verify -Darquillian.useContainerHost=true"
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/test/java/x1/arquillian/Containers.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,16 @@ public List<GenericContainer<?>> instances() {
public void configureAfterStart(ContainerRegistry registry) {
var arquillianContainer = registry.getContainers().iterator().next();
var containerConfiguration = arquillianContainer.getContainerConfiguration();
if (Boolean.valueOf(System.getProperty("arquillian.useMappedPorts", "true"))) {
containerConfiguration.property("managementPort", Integer.toString(wildfly.getMappedPort(9990)));

// if we would run the test as client, we would need to access the servlet from the host
// same in Windows we can not access the container network directly
var protocolConfiguration = arquillianContainer.getProtocolConfiguration(new ProtocolDescription("Servlet 5.0"));
protocolConfiguration.property("port", Integer.toString(wildfly.getMappedPort(8080)));
protocolConfiguration.property("host", System.getProperty("DOCKER_HOST", wildfly.getHost()));
} else {
if (Boolean.valueOf(System.getProperty("arquillian.useContainerHost", "false"))) {
containerConfiguration.property("managementAddress", wildfly.getHost());
containerConfiguration.property("managementPort", Integer.toString(wildfly.getMappedPort(9990)));
}
containerConfiguration.property("managementPort", Integer.toString(wildfly.getMappedPort(9990)));

// if we would run the test as client, we would need to access the servlet from the host
// same in Windows we can not access the container network directly
var protocolConfiguration = arquillianContainer.getProtocolConfiguration(new ProtocolDescription("Servlet 5.0"));
protocolConfiguration.property("port", Integer.toString(wildfly.getMappedPort(8080)));
protocolConfiguration.property("host", System.getProperty("DOCKER_HOST", wildfly.getHost()));
}

@Override
Expand Down

0 comments on commit 742fd61

Please sign in to comment.