From 742fd613285a0dbf030e0d9c79dff6584389c6e0 Mon Sep 17 00:00:00 2001 From: Johannes Beck Date: Fri, 22 Mar 2024 18:56:45 +0100 Subject: [PATCH] User container host in Jenkins to deploy and test --- Jenkinsfile | 2 +- src/test/java/x1/arquillian/Containers.java | 18 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 636a9f9b..307a7b65 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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" } } diff --git a/src/test/java/x1/arquillian/Containers.java b/src/test/java/x1/arquillian/Containers.java index f11de36e..0cf1406b 100644 --- a/src/test/java/x1/arquillian/Containers.java +++ b/src/test/java/x1/arquillian/Containers.java @@ -42,18 +42,16 @@ public List> 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