james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [james-project] 02/09: JAMES-2786 unpause RabbitMQ container after each test to avoid next tests failure
Date Fri, 14 Jun 2019 16:32:53 GMT
This is an automated email from the ASF dual-hosted git repository.

matthieu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7220b4e66b166fe455d3955951348ac8553676a1
Author: Matthieu Baechler <matthieu@apache.org>
AuthorDate: Fri Jun 7 15:42:55 2019 +0200

    JAMES-2786 unpause RabbitMQ container after each test to avoid next tests failure
---
 .../java/org/apache/james/backend/rabbitmq/DockerRabbitMQ.java    | 8 +++++++-
 .../org/apache/james/mailbox/events/RabbitMQEventBusTest.java     | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)

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 9843fd3..fa278a8 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
@@ -25,6 +25,7 @@ import java.net.URISyntaxException;
 import java.time.Duration;
 import java.util.Optional;
 import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.util.docker.Images;
@@ -66,6 +67,7 @@ public class DockerRabbitMQ {
     private final String nodeName;
     private final String rabbitHostName;
     private final String hostNameSuffix;
+    private final AtomicBoolean paused;
 
     public static DockerRabbitMQ withCookieAndHostName(String hostNamePrefix, String clusterIdentity,
String erlangCookie, Network network) {
         return new DockerRabbitMQ(Optional.ofNullable(hostNamePrefix), Optional.ofNullable(clusterIdentity),
Optional.ofNullable(erlangCookie), Optional.of(network));
@@ -77,6 +79,7 @@ public class DockerRabbitMQ {
 
     @SuppressWarnings("resource")
     private DockerRabbitMQ(Optional<String> hostNamePrefix, Optional<String>
clusterIdentity, Optional<String> erlangCookie, Optional<Network> net) {
+        paused = new AtomicBoolean(false);
         this.hostNameSuffix = clusterIdentity.orElse(UUID.randomUUID().toString());
         this.rabbitHostName = hostName(hostNamePrefix);
         this.container = new GenericContainer<>(Images.RABBITMQ)
@@ -237,10 +240,13 @@ public class DockerRabbitMQ {
 
     public void pause() {
         DockerClientFactory.instance().client().pauseContainerCmd(container.getContainerId()).exec();
+        paused.set(true);
     }
 
     public void unpause() {
-        DockerClientFactory.instance().client().unpauseContainerCmd(container.getContainerId()).exec();
+        if (paused.compareAndSet(true, false)) {
+            DockerClientFactory.instance().client().unpauseContainerCmd(container.getContainerId()).exec();
+        }
     }
 
     public RabbitMQConnectionFactory createRabbitConnectionFactory() throws URISyntaxException
{
diff --git a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
index 49f0f15..66ae6d3 100644
--- a/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
+++ b/mailbox/event/event-rabbitmq/src/test/java/org/apache/james/mailbox/events/RabbitMQEventBusTest.java
@@ -299,6 +299,11 @@ class RabbitMQEventBusTest implements GroupContract.SingleEventBusGroupContract,
             rabbitManagementAPI = rabbitMQExtension.managementAPI();
         }
 
+        @AfterEach
+        void tearDown() {
+            rabbitMQExtension.getRabbitMQ().unpause();
+        }
+
         @Nested
         class SingleEventBus {
 


---------------------------------------------------------------------
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