diff --git a/README.md b/README.md index b914c317..d7109cda 100644 --- a/README.md +++ b/README.md @@ -218,6 +218,15 @@ node('master') { } ``` +## Building and Testing + +Integration tests live in `ui-tests` using [Jenkins ATH](https://github.com/jenkinsci/acceptance-test-harness) and some will use Docker for the queue service. + +When running Docker by default tests will use the Docker daemon ip and ports exposed. To use `localhost` and forwarded ports instead set the system property `-Ddocker.portforward=true`. + +To [run with different browsers](https://github.com/jenkinsci/acceptance-test-harness/blob/master/docs/BROWSER.md) the environment variable `BROWSER` can be set, ie. `BROWSER=firefox` + + ## Change Log #### Version 1.1.18 (April 23, 2020) diff --git a/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/AmqMessagingPluginWithFailoverIntegrationTest.java b/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/AmqMessagingPluginWithFailoverIntegrationTest.java index 8de306f5..d318c538 100644 --- a/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/AmqMessagingPluginWithFailoverIntegrationTest.java +++ b/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/AmqMessagingPluginWithFailoverIntegrationTest.java @@ -9,8 +9,7 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.concurrent.ThreadLocalRandom; import com.redhat.jenkins.plugins.ci.integration.docker.fixtures.ActiveMQContainer; import org.jenkinsci.test.acceptance.docker.Docker; @@ -66,8 +65,11 @@ public class AmqMessagingPluginWithFailoverIntegrationTest extends AbstractJUnit @Before public void setUp() throws Exception { Plugin plugin = jenkins.getPlugin("dumpling"); assertNotNull(plugin); + // add a random number to the port without exceeding 65535 + // so the port stays the same after container restart + int rand = ThreadLocalRandom.current().nextInt(1, 65535-61616); + amq1 = docker1.starter().withPortOffset(rand).start(); - amq1 = docker1.get(); jenkins.configure(); elasticSleep(5000); GlobalCIConfiguration ciPluginConfig = new GlobalCIConfiguration(jenkins.getConfigPage()); diff --git a/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/docker/fixtures/ActiveMQContainer.java b/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/docker/fixtures/ActiveMQContainer.java index b499eff5..8d9e89fb 100644 --- a/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/docker/fixtures/ActiveMQContainer.java +++ b/ui-tests/src/test/java/com/redhat/jenkins/plugins/ci/integration/docker/fixtures/ActiveMQContainer.java @@ -33,6 +33,11 @@ public class ActiveMQContainer extends DockerContainer { public String getBroker() throws IOException { + // using localhost and port forwarding + if ("true".equalsIgnoreCase(System.getProperty("docker.portforward"))) { + return String.format("tcp://%s:%d", ipBound(61616), port(61616)); + } + // using docker daemon ip String ip = getIpAddress(); if (ip == null || ip.equals("")) { JsonNode binding = inspect().get("HostConfig").get("PortBindings").get("61616/tcp").get(0);