james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [5/5] james-project git commit: JAMES-2524 Upgrade to testcontainers 1.9.0
Date Fri, 28 Sep 2018 02:10:46 GMT
JAMES-2524 Upgrade to testcontainers 1.9.0

Rely on new feature allowing to specifiy rate limiter for retry strategies

Default is one call per second, leading to slow container startup


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

Branch: refs/heads/master
Commit: e4f13e47f5ecc42796b0931dec3fdbb70ee41938
Parents: 80bcd2f
Author: Benoit Tellier <btellier@linagora.com>
Authored: Wed Sep 26 12:56:38 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Sep 28 09:08:22 2018 +0700

----------------------------------------------------------------------
 .../james/backend/rabbitmq/DockerRabbitMQ.java  |  3 +-
 .../james/mailbox/tika/TikaContainer.java       |  3 +-
 pom.xml                                         |  2 +-
 server/blob/blob-objectstorage/pom.xml          |  5 +++
 .../DockerSwiftTempAuthExtension.java           |  5 ++-
 .../apache/james/DockerElasticSearchRule.java   |  5 ++-
 .../apache/james/metric/es/ESReporterTest.java  |  5 ++-
 .../james/user/ldap/LdapGenericContainer.java   |  3 +-
 .../mailets/AmqpForwardAttachmentTest.java      |  6 +++-
 .../transport/mailets/ContactExtractorTest.java |  5 ++-
 .../mailets/ICSAttachmentWorkflowTest.java      |  5 ++-
 .../transport/mailets/SpamAssassinTest.java     |  3 +-
 .../org/apache/james/jmap/ContainerTest.java    |  5 ++-
 .../apache/james/util/docker/RateLimiters.java  | 32 ++++++++++++++++++++
 .../java/org/apache/james/utils/FakeSmtp.java   |  4 ++-
 15 files changed, 78 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/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 9dfac4e..386d812 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
@@ -26,6 +26,7 @@ import java.util.UUID;
 import com.rabbitmq.client.Address;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testcontainers.DockerClientFactory;
@@ -67,7 +68,7 @@ public class DockerRabbitMQ {
                 .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))
+                    .withStrategy(Wait.forHttp("").forPort(DEFAULT_RABBITMQ_ADMIN_PORT).withRateLimiter(RateLimiters.DEFAULT))
                     .withStrategy(RabbitMQWaitStrategy.withDefaultTimeout(this)))
                 .withLogConsumer(frame -> LOGGER.debug(frame.getUtf8String()))
                 .withCreateContainerCmdModifier(cmd -> cmd.getHostConfig()

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainer.java
----------------------------------------------------------------------
diff --git a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainer.java b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainer.java
index c2f23dc..ae015e0 100644
--- a/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainer.java
+++ b/mailbox/tika/src/test/java/org/apache/james/mailbox/tika/TikaContainer.java
@@ -22,6 +22,7 @@ import java.time.Duration;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.junit.rules.ExternalResource;
 import org.testcontainers.containers.wait.strategy.Wait;
@@ -38,7 +39,7 @@ public class TikaContainer extends ExternalResource {
     public TikaContainer() {
         tika = new SwarmGenericContainer(Images.TIKA)
                 .withExposedPorts(DEFAULT_TIKA_PORT)
-                .waitingFor(Wait.forHttp("/tika"))
+                .waitingFor(Wait.forHttp("/tika").withRateLimiter(RateLimiters.DEFAULT))
                 .withStartupTimeout(Duration.ofSeconds(30));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 79669fc..0b0b457 100644
--- a/pom.xml
+++ b/pom.xml
@@ -633,7 +633,7 @@
         <jackson.version>2.9.6</jackson.version>
         <jetty.version>9.4.7.v20170914</jetty.version>
         <metrics.version>3.2.6</metrics.version>
-        <testcontainers.version>1.8.3</testcontainers.version>
+        <testcontainers.version>1.9.0</testcontainers.version>
         <assertj.version>3.3.0</assertj.version>
         <es.version>2.2.1</es.version>
         <es-reporter.version>2.2.0</es-reporter.version>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/blob/blob-objectstorage/pom.xml
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/pom.xml b/server/blob/blob-objectstorage/pom.xml
index f86eb67..8e4eb44 100644
--- a/server/blob/blob-objectstorage/pom.xml
+++ b/server/blob/blob-objectstorage/pom.xml
@@ -52,6 +52,11 @@
             <artifactId>james-server-util</artifactId>
         </dependency>
         <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
----------------------------------------------------------------------
diff --git a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
index 4d2c716..b442bbe 100644
--- a/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
+++ b/server/blob/blob-objectstorage/src/test/java/org/apache/james/blob/objectstorage/DockerSwiftTempAuthExtension.java
@@ -21,6 +21,7 @@ package org.apache.james.blob.objectstorage;
 
 import java.net.URI;
 
+import org.apache.james.util.docker.RateLimiters;
 import org.junit.jupiter.api.extension.AfterAllCallback;
 import org.junit.jupiter.api.extension.BeforeAllCallback;
 import org.junit.jupiter.api.extension.ExtensionContext;
@@ -28,12 +29,14 @@ import org.junit.jupiter.api.extension.ParameterContext;
 import org.junit.jupiter.api.extension.ParameterResolutionException;
 import org.junit.jupiter.api.extension.ParameterResolver;
 import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
 class DockerSwiftTempAuthExtension implements ParameterResolver, BeforeAllCallback, AfterAllCallback
{
     public static final int SWIFT_PORT = 8080;
     private static GenericContainer<?> swiftContainer =
         new GenericContainer<>("bouncestorage/swift-aio:ea10837d")
-            .withExposedPorts(SWIFT_PORT);
+            .withExposedPorts(SWIFT_PORT)
+            .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
     private DockerSwift dockerSwift;
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
index 06653c7..ff56488 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
@@ -23,9 +23,11 @@ import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.modules.mailbox.ElasticSearchConfiguration;
 import org.apache.james.util.Host;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
 import com.google.inject.Module;
 
@@ -42,7 +44,8 @@ public class DockerElasticSearchRule implements GuiceModuleTestRule {
     }
 
     private SwarmGenericContainer elasticSearchContainer = new SwarmGenericContainer(Images.ELASTICSEARCH)
-        .withExposedPorts(ELASTIC_SEARCH_HTTP_PORT, ELASTIC_SEARCH_PORT);
+        .withExposedPorts(ELASTIC_SEARCH_HTTP_PORT, ELASTIC_SEARCH_PORT)
+        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
 
     @Override
     public Statement apply(Statement base, Description description) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
----------------------------------------------------------------------
diff --git a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
index bd85668..3cc32fb 100644
--- a/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
+++ b/server/container/metrics/metrics-es-reporter/src/test/java/org/apache/james/metric/es/ESReporterTest.java
@@ -32,6 +32,7 @@ import org.apache.james.metrics.dropwizard.DropWizardMetricFactory;
 import org.apache.james.metrics.es.ESMetricReporter;
 import org.apache.james.metrics.es.ESReporterConfiguration;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.awaitility.Duration;
 import org.elasticsearch.client.Client;
@@ -40,6 +41,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
 import com.codahale.metrics.MetricRegistry;
 
@@ -55,7 +57,8 @@ public class ESReporterTest {
     @Rule
     public SwarmGenericContainer esContainer = new SwarmGenericContainer(Images.ELASTICSEARCH)
         .withAffinityToContainer()
-        .withExposedPorts(ES_HTTP_PORT, ES_APPLICATIVE_PORT);
+        .withExposedPorts(ES_HTTP_PORT, ES_APPLICATIVE_PORT)
+        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
 
     private ClientProvider clientProvider;
     private ESMetricReporter esMetricReporter;

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
index 74e62d9..6f53a13 100644
--- a/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
+++ b/server/data/data-ldap-integration-testing/src/test/java/org/apache/james/user/ldap/LdapGenericContainer.java
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.james.user.ldap;
 
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.junit.rules.ExternalResource;
 import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
@@ -68,7 +69,7 @@ public class LdapGenericContainer extends ExternalResource {
                 .withEnv("SLAPD_PASSWORD", password)
                 .withEnv("SLAPD_CONFIG_PASSWORD", password)
                 .withExposedPorts(LdapGenericContainer.DEFAULT_LDAP_PORT)
-                .waitingFor(new HostPortWaitStrategy());
+                .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
index babe313..d23d8c1 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
@@ -40,6 +40,7 @@ import org.apache.james.probe.DataProbe;
 import org.apache.james.transport.mailets.amqp.AmqpRule;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.IMAPMessageReader;
@@ -51,6 +52,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
 public class AmqpForwardAttachmentTest {
     private static final String FROM = "fromUser@" + DEFAULT_DOMAIN;
@@ -63,7 +65,9 @@ public class AmqpForwardAttachmentTest {
     private static final byte[] TEST_ATTACHMENT_CONTENT = "Test attachment content".getBytes(StandardCharsets.UTF_8);
 
     public SwarmGenericContainer rabbitMqContainer = new SwarmGenericContainer(Images.RABBITMQ)
-            .withAffinityToContainer();
+        .withAffinityToContainer()
+        .waitingFor(new HostPortWaitStrategy()
+            .withRateLimiter(RateLimiters.DEFAULT));
 
     public TemporaryFolder temporaryFolder = new TemporaryFolder();
     public AmqpRule amqpRule = new AmqpRule(rabbitMqContainer, EXCHANGE_NAME, ROUTING_KEY);

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
index 1211bc8..1674987 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ContactExtractorTest.java
@@ -40,6 +40,7 @@ import org.apache.james.transport.mailets.amqp.AmqpRule;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.transport.matchers.SMTPAuthSuccessful;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.IMAPMessageReader;
@@ -51,6 +52,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
 public class ContactExtractorTest {
     public static final String SENDER = "sender@" + DEFAULT_DOMAIN;
@@ -63,7 +65,8 @@ public class ContactExtractorTest {
     public static final String EXCHANGE = "collector:email";
     public static final String ROUTING_KEY = "";
 
-    public SwarmGenericContainer rabbit = new SwarmGenericContainer(Images.RABBITMQ);
+    public SwarmGenericContainer rabbit = new SwarmGenericContainer(Images.RABBITMQ)
+        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
     public AmqpRule amqpRule = new AmqpRule(rabbit, EXCHANGE, ROUTING_KEY);
     public TemporaryFolder folder = new TemporaryFolder();
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
index f121228..8355034 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
@@ -45,6 +45,7 @@ import org.apache.james.transport.mailets.amqp.AmqpRule;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.util.MimeMessageUtil;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.IMAPMessageReader;
@@ -56,6 +57,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy;
 
 import com.google.common.collect.ImmutableList;
 import com.jayway.jsonpath.Configuration;
@@ -428,7 +430,8 @@ public class ICSAttachmentWorkflowTest {
 
     @ClassRule
     public static SwarmGenericContainer rabbitMqContainer = new SwarmGenericContainer(Images.RABBITMQ)
-            .withAffinityToContainer();
+        .withAffinityToContainer()
+        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));;
     @Rule
     public TemporaryFolder temporaryFolder = new TemporaryFolder();
     @Rule

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
index a97bcb6..94b6c7c 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/SpamAssassinTest.java
@@ -41,6 +41,7 @@ import org.apache.james.modules.protocols.SmtpGuiceProbe;
 import org.apache.james.spamassassin.SpamAssassinResult;
 import org.apache.james.transport.matchers.All;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.IMAPMessageReader;
@@ -61,7 +62,7 @@ public class SpamAssassinTest {
     public static SwarmGenericContainer spamAssassinContainer = new SwarmGenericContainer(Images.SPAMASSASSIN)
         .withExposedPorts(783)
         .withAffinityToContainer()
-        .waitingFor(new HostPortWaitStrategy());
+        .waitingFor(new HostPortWaitStrategy().withRateLimiter(RateLimiters.DEFAULT));
     @Rule
     public TemporaryFolder temporaryFolder = new TemporaryFolder();
     @Rule

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
index 6e3d02b..bd7057a 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/ContainerTest.java
@@ -27,6 +27,7 @@ import org.apache.http.client.fluent.Request;
 import org.apache.http.client.fluent.Response;
 import org.apache.http.client.utils.URIBuilder;
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.junit.Rule;
 import org.junit.Test;
@@ -38,7 +39,9 @@ public class ContainerTest {
     public SwarmGenericContainer container = new SwarmGenericContainer(Images.NGINX)
         .withAffinityToContainer()
         .withExposedPorts(80)
-        .waitingFor(new HttpWaitStrategy().forStatusCode(200));
+        .waitingFor(new HttpWaitStrategy()
+            .forStatusCode(200)
+            .withRateLimiter(RateLimiters.DEFAULT));
 
     @Test
     public void containerShouldBeReachableOnExposedPort() throws IOException, URISyntaxException
{

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/testing/src/main/java/org/apache/james/util/docker/RateLimiters.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/util/docker/RateLimiters.java b/server/testing/src/main/java/org/apache/james/util/docker/RateLimiters.java
new file mode 100644
index 0000000..d75730e
--- /dev/null
+++ b/server/testing/src/main/java/org/apache/james/util/docker/RateLimiters.java
@@ -0,0 +1,32 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.util.docker;
+
+import java.util.concurrent.TimeUnit;
+
+import org.rnorth.ducttape.ratelimits.RateLimiter;
+import org.rnorth.ducttape.ratelimits.RateLimiterBuilder;
+
+public interface RateLimiters {
+    RateLimiter DEFAULT = RateLimiterBuilder.newBuilder()
+        .withRate(20, TimeUnit.SECONDS)
+        .withConstantThroughput()
+        .build();
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e4f13e47/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java b/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
index 51685dd..7a3246e 100644
--- a/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
+++ b/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
@@ -27,6 +27,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.function.Function;
 
 import org.apache.james.util.docker.Images;
+import org.apache.james.util.docker.RateLimiters;
 import org.apache.james.util.docker.SwarmGenericContainer;
 import org.awaitility.core.ConditionFactory;
 import org.junit.rules.TestRule;
@@ -53,7 +54,8 @@ public class FakeSmtp implements TestRule {
     private static SwarmGenericContainer fakeSmtpContainer() {
         return new SwarmGenericContainer(Images.FAKE_SMTP)
             .withAffinityToContainer()
-            .waitingFor(new HostPortWaitStrategy());
+            .waitingFor(new HostPortWaitStrategy()
+            .withRateLimiter(RateLimiters.DEFAULT));
     }
 
     private static final int SMTP_PORT = 25;


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