james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [3/4] james-project git commit: ask DockerRabbitMQ to wait for the service to be ready after restarts
Date Mon, 01 Oct 2018 02:05:30 GMT
ask DockerRabbitMQ to wait for the service to be ready after restarts


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/43a73fee
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/43a73fee
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/43a73fee

Branch: refs/heads/master
Commit: 43a73fee31f3130c9f38a7460a04f98221839bf4
Parents: ffa94df
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Fri Sep 28 16:22:26 2018 +0200
Committer: Matthieu Baechler <matthieu@apache.org>
Committed: Fri Sep 28 16:22:26 2018 +0200

----------------------------------------------------------------------
 .../rabbitmq/DockerClusterRabbitMQExtension.java      |  5 +++++
 .../apache/james/backend/rabbitmq/DockerRabbitMQ.java | 14 +++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/43a73fee/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerClusterRabbitMQExtension.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerClusterRabbitMQExtension.java
b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerClusterRabbitMQExtension.java
index 79ba173..e95fcb6 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerClusterRabbitMQExtension.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerClusterRabbitMQExtension.java
@@ -71,6 +71,11 @@ public class DockerClusterRabbitMQExtension implements BeforeEachCallback,
After
             Throwing.runnable(rabbitMQ3::startApp));
 
         cluster = new DockerRabbitMQCluster(rabbitMQ1, rabbitMQ2, rabbitMQ3);
+
+        Runnables.runParallel(
+            rabbitMQ1::waitForReadyness,
+            rabbitMQ2::waitForReadyness,
+            rabbitMQ3::waitForReadyness);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/43a73fee/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
----------------------------------------------------------------------
diff --git a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
index 386d812..36eb2ac 100644
--- a/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
+++ b/backends-common/rabbitmq/src/test/java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java
@@ -67,9 +67,7 @@ public class DockerRabbitMQ {
                 .withCreateContainerCmdModifier(cmd -> cmd.withName(hostName.orElse(randomName())))
                 .withCreateContainerCmdModifier(cmd -> cmd.withHostName(hostName.orElse(DEFAULT_RABBIT_NODE)))
                 .withExposedPorts(DEFAULT_RABBITMQ_PORT, DEFAULT_RABBITMQ_ADMIN_PORT)
-                .waitingFor(new WaitAllStrategy()
-                    .withStrategy(Wait.forHttp("").forPort(DEFAULT_RABBITMQ_ADMIN_PORT).withRateLimiter(RateLimiters.DEFAULT))
-                    .withStrategy(RabbitMQWaitStrategy.withDefaultTimeout(this)))
+                .waitingFor(waitStrategy())
                 .withLogConsumer(frame -> LOGGER.debug(frame.getUtf8String()))
                 .withCreateContainerCmdModifier(cmd -> cmd.getHostConfig()
                     .withTmpFs(ImmutableMap.of("/var/lib/rabbitmq/mnesia", "rw,noexec,nosuid,size=100m")));
@@ -79,6 +77,12 @@ public class DockerRabbitMQ {
         this.nodeName = nodeName;
     }
 
+    private WaitAllStrategy waitStrategy() {
+        return new WaitAllStrategy()
+            .withStrategy(Wait.forHttp("").forPort(DEFAULT_RABBITMQ_ADMIN_PORT).withRateLimiter(RateLimiters.DEFAULT))
+            .withStrategy(RabbitMQWaitStrategy.withDefaultTimeout(this));
+    }
+
     private String randomName() {
         return UUID.randomUUID().toString();
     }
@@ -170,6 +174,10 @@ public class DockerRabbitMQ {
         startApp();
     }
 
+    public void waitForReadyness() {
+        waitStrategy().waitUntilReady(container);
+    }
+
     public Address address() {
         return new Address(getHostIp(), getPort());
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message