james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [james-project] 02/14: JAMES-2717 Duplicate the embedded es components to the docker components
Date Thu, 09 May 2019 10:28:27 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 269eee48d1e847c659f2e36952547a682d36e49c
Author: Tran Tien Duc <dtran@linagora.com>
AuthorDate: Tue May 7 18:35:31 2019 +0700

    JAMES-2717 Duplicate the embedded es components to the docker components
---
 .../apache/james/DockerElasticSearchExtension.java | 21 +++++-------
 ...earchRule.java => DockerElasticSearchRule.java} | 28 ++++++----------
 .../test/java/org/apache/james/ESReporterTest.java |  6 ++--
 .../james/EmbeddedElasticSearchExtension.java      |  4 +--
 .../apache/james/EmbeddedElasticSearchRule.java    |  4 +--
 .../james/JamesServerWithRetryConnectionTest.java  | 13 +++-----
 ....java => TestDockerESMetricReporterModule.java} | 13 +++++---
 ...ule.java => TestDockerElasticSearchModule.java} | 39 +++++++++++++++++-----
 ...ava => TestEmbeddedESMetricReporterModule.java} |  2 +-
 ...e.java => TestEmbeddedElasticSearchModule.java} |  4 +--
 .../jmap/cassandra/cucumber/CassandraStepdefs.java |  8 ++---
 .../ReindexingWithEventDeadLettersTest.java        | 13 +++-----
 .../cucumber/awss3/RabbitMQAwsS3Stepdefs.java      | 11 +++---
 .../integration/CassandraJmapExtension.java        |  8 ++---
 14 files changed, 89 insertions(+), 85 deletions(-)

diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchExtension.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchExtension.java
index bfc755e..20f2747 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchExtension.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchExtension.java
@@ -19,31 +19,22 @@
 
 package org.apache.james;
 
+import org.apache.james.backends.es.DockerElasticSearch;
+import org.apache.james.backends.es.DockerElasticSearchSingleton;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
-import org.apache.james.util.Host;
-import org.apache.james.util.docker.DockerGenericContainer;
 import org.junit.jupiter.api.extension.ExtensionContext;
 
 import com.google.inject.Module;
 
 public class DockerElasticSearchExtension implements GuiceModuleTestExtension {
-    public static final int ELASTIC_SEARCH_PORT = 9300;
-    public static final int ELASTIC_SEARCH_HTTP_PORT = 9200;
-
-    private final DockerGenericContainer elasticSearchContainer;
-
-    public DockerElasticSearchExtension(DockerGenericContainer elasticSearchContainer) {
-        this.elasticSearchContainer = elasticSearchContainer;
-    }
 
     @Override
     public void beforeEach(ExtensionContext extensionContext) {
-        elasticSearchContainer.start();
+        getDockerES().start();
     }
 
     @Override
     public void afterEach(ExtensionContext extensionContext) {
-        elasticSearchContainer.stop();
     }
 
     @Override
@@ -54,7 +45,11 @@ public class DockerElasticSearchExtension implements GuiceModuleTestExtension
{
 
     private ElasticSearchConfiguration getElasticSearchConfigurationForDocker() {
         return ElasticSearchConfiguration.builder()
-            .addHost(Host.from(elasticSearchContainer.getHostIp(), elasticSearchContainer.getMappedPort(ELASTIC_SEARCH_PORT)))
+            .addHost(getDockerES().getTcpHost())
             .build();
     }
+
+    public DockerElasticSearch getDockerES() {
+        return DockerElasticSearchSingleton.INSTANCE;
+    }
 }
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
similarity index 64%
copy from server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
copy to server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
index 3c6848a..6287009 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/DockerElasticSearchRule.java
@@ -19,43 +19,35 @@
 
 package org.apache.james;
 
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.modules.TestElasticSearchModule;
-import org.elasticsearch.node.Node;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
+import org.apache.james.backends.es.DockerElasticSearch;
+import org.apache.james.backends.es.DockerElasticSearchSingleton;
+import org.apache.james.modules.TestDockerElasticSearchModule;
 import org.junit.runner.Description;
 import org.junit.runners.model.Statement;
 
 import com.google.inject.Module;
 
 
-public class EmbeddedElasticSearchRule implements GuiceModuleTestRule {
+public class DockerElasticSearchRule implements GuiceModuleTestRule {
 
-    private final TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private final EmbeddedElasticSearch embeddedElasticSearch = new EmbeddedElasticSearch(temporaryFolder);
-
-    private final RuleChain chain = RuleChain
-        .outerRule(temporaryFolder)
-        .around(embeddedElasticSearch);
+    private final DockerElasticSearch elasticSearch = DockerElasticSearchSingleton.INSTANCE;
 
     @Override
     public Statement apply(Statement base, Description description) {
-        return chain.apply(base, description);
+        return base;
     }
 
     @Override
     public void await() {
-        embeddedElasticSearch.awaitForElasticSearch();
+        elasticSearch.awaitForElasticSearch();
     }
 
-
     @Override
     public Module getModule() {
-        return new TestElasticSearchModule(embeddedElasticSearch);
+        return new TestDockerElasticSearchModule(elasticSearch);
     }
 
-    public Node getNode() {
-        return embeddedElasticSearch.getNode();
+    public DockerElasticSearch getDockerEs() {
+        return elasticSearch;
     }
 }
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
index 65392fd..f896e28 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/ESReporterTest.java
@@ -37,7 +37,7 @@ import org.apache.commons.net.imap.IMAPClient;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.modules.TestESMetricReporterModule;
+import org.apache.james.modules.TestEmbeddedESMetricReporterModule;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.modules.protocols.ImapGuiceProbe;
 import org.apache.james.utils.DataProbeImpl;
@@ -71,7 +71,7 @@ class ESReporterTest {
             .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
             .overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
             .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
-            .overrideWith(new TestESMetricReporterModule()))
+            .overrideWith(new TestEmbeddedESMetricReporterModule()))
         .build();
 
     private static final int DELAY_IN_MS = 100;
@@ -156,7 +156,7 @@ class ESReporterTest {
             return !Arrays.stream(client.prepareSearch()
                     .setQuery(QueryBuilders.matchAllQuery())
                     .get().getHits().getHits())
-                .filter(searchHit -> searchHit.getIndex().startsWith(TestESMetricReporterModule.METRICS_INDEX))
+                .filter(searchHit -> searchHit.getIndex().startsWith(TestEmbeddedESMetricReporterModule.METRICS_INDEX))
                 .collect(Collectors.toList())
                 .isEmpty();
         } catch (Exception e) {
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchExtension.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchExtension.java
index 743dbc3..a724c35 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchExtension.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchExtension.java
@@ -21,7 +21,7 @@ package org.apache.james;
 
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.junit.TemporaryFolderExtension;
-import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestEmbeddedElasticSearchModule;
 import org.junit.jupiter.api.extension.ExtensionContext;
 
 import com.google.inject.Module;
@@ -49,7 +49,7 @@ public class EmbeddedElasticSearchExtension implements GuiceModuleTestExtension
 
     @Override
     public Module getModule() {
-        return new TestElasticSearchModule(embeddedElasticSearch);
+        return new TestEmbeddedElasticSearchModule(embeddedElasticSearch);
     }
 
     @Override
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
index 3c6848a..b4c524f 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/EmbeddedElasticSearchRule.java
@@ -20,7 +20,7 @@
 package org.apache.james;
 
 import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestEmbeddedElasticSearchModule;
 import org.elasticsearch.node.Node;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TemporaryFolder;
@@ -52,7 +52,7 @@ public class EmbeddedElasticSearchRule implements GuiceModuleTestRule {
 
     @Override
     public Module getModule() {
-        return new TestElasticSearchModule(embeddedElasticSearch);
+        return new TestEmbeddedElasticSearchModule(embeddedElasticSearch);
     }
 
     public Node getNode() {
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
index 85263de..4f6745b 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesServerWithRetryConnectionTest.java
@@ -20,8 +20,6 @@
 package org.apache.james;
 
 import static org.apache.james.CassandraJamesServerMain.ALL_BUT_JMX_CASSANDRA_MODULE;
-import static org.apache.james.DockerElasticSearchExtension.ELASTIC_SEARCH_HTTP_PORT;
-import static org.apache.james.DockerElasticSearchExtension.ELASTIC_SEARCH_PORT;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.IOException;
@@ -39,8 +37,6 @@ import org.apache.james.mailbox.store.search.PDFTextExtractor;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.modules.protocols.ImapGuiceProbe;
 import org.apache.james.util.concurrent.NamedThreadFactory;
-import org.apache.james.util.docker.DockerGenericContainer;
-import org.apache.james.util.docker.Images;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -50,13 +46,12 @@ class JamesServerWithRetryConnectionTest {
     private static final int LIMIT_TO_10_MESSAGES = 10;
     private static final long WAITING_TIME = TimeUnit.MILLISECONDS.convert(10, TimeUnit.SECONDS);
 
-    private static DockerGenericContainer elasticSearchContainer = new DockerGenericContainer(Images.ELASTICSEARCH_2)
-        .withExposedPorts(ELASTIC_SEARCH_HTTP_PORT, ELASTIC_SEARCH_PORT);
     private static final DockerCassandraRule cassandraRule = new DockerCassandraRule();
+    private static final DockerElasticSearchExtension dockerElasticSearch = new DockerElasticSearchExtension();
 
     @RegisterExtension
     static JamesServerExtension testExtension = new JamesServerBuilder()
-        .extension(new DockerElasticSearchExtension(elasticSearchContainer))
+        .extension(dockerElasticSearch)
         .extension(new CassandraExtension(cassandraRule))
         .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
             .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
@@ -97,9 +92,9 @@ class JamesServerWithRetryConnectionTest {
 
     @Test
     void serverShouldRetryToConnectToElasticSearchWhenStartService(GuiceJamesServer server)
throws Exception {
-        elasticSearchContainer.pause();
+        dockerElasticSearch.getDockerES().pause();
 
-        waitToStartContainer(WAITING_TIME, elasticSearchContainer::unpause);
+        waitToStartContainer(WAITING_TIME, dockerElasticSearch.getDockerES()::unpause);
 
         assertThatServerStartCorrectly(server);
     }
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestESMetricReporterModule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestDockerESMetricReporterModule.java
similarity index 84%
copy from server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestESMetricReporterModule.java
copy to server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestDockerESMetricReporterModule.java
index 85808e0..3b9e438 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestESMetricReporterModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestDockerESMetricReporterModule.java
@@ -22,16 +22,21 @@ package org.apache.james.modules;
 import javax.inject.Singleton;
 
 import org.apache.james.metrics.es.ESReporterConfiguration;
+import org.apache.james.util.Host;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
 
-public class TestESMetricReporterModule extends AbstractModule {
+public class TestDockerESMetricReporterModule extends AbstractModule {
 
-    private static final String LOCALHOST = "localhost";
-    private static final int DEFAULT_ES_HTTP_PORT = 9200;
     public static final String METRICS_INDEX = "metrics";
 
+    private final Host esHttpHost;
+
+    public TestDockerESMetricReporterModule(Host esHttpHost) {
+        this.esHttpHost = esHttpHost;
+    }
+
     @Override
     protected void configure() {
     }
@@ -41,7 +46,7 @@ public class TestESMetricReporterModule extends AbstractModule {
     public ESReporterConfiguration provideConfiguration() {
         return ESReporterConfiguration.builder()
             .enabled()
-            .onHost(LOCALHOST, DEFAULT_ES_HTTP_PORT)
+            .onHost(esHttpHost.getHostName(), esHttpHost.getPort())
             .onIndex(METRICS_INDEX)
             .periodInSecond(1L)
             .build();
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestDockerElasticSearchModule.java
similarity index 59%
copy from server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
copy to server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestDockerElasticSearchModule.java
index 0ada1f6..10797a2 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestDockerElasticSearchModule.java
@@ -21,32 +21,53 @@ package org.apache.james.modules;
 
 import javax.inject.Singleton;
 
+import org.apache.james.CleanupTasksPerformer;
+import org.apache.james.backends.es.DockerElasticSearch;
 import org.apache.james.backends.es.ElasticSearchConfiguration;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.mailbox.elasticsearch.MailboxIndexCreationUtil;
 import org.elasticsearch.client.Client;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
+import com.google.inject.multibindings.Multibinder;
 
-public class TestElasticSearchModule extends AbstractModule {
+public class TestDockerElasticSearchModule extends AbstractModule {
 
-    private final EmbeddedElasticSearch embeddedElasticSearch;
+    private static class ESContainerCleanUp implements CleanupTasksPerformer.CleanupTask
{
 
-    public TestElasticSearchModule(EmbeddedElasticSearch embeddedElasticSearch) {
-        this.embeddedElasticSearch = embeddedElasticSearch;
+        private final DockerElasticSearch elasticSearch;
+
+        private ESContainerCleanUp(DockerElasticSearch elasticSearch) {
+            this.elasticSearch = elasticSearch;
+        }
+
+        @Override
+        public Result run() {
+            elasticSearch.cleanUpData();
+
+            return Result.COMPLETED;
+        }
+    }
+
+    private final DockerElasticSearch elasticSearch;
+
+    public TestDockerElasticSearchModule(DockerElasticSearch elasticSearch) {
+        this.elasticSearch = elasticSearch;
     }
 
     @Override
     protected void configure() {
-
+        Multibinder.newSetBinder(binder(), CleanupTasksPerformer.CleanupTask.class)
+            .addBinding()
+            .toInstance(new ESContainerCleanUp(elasticSearch));
     }
 
     @Provides
     @Singleton
     protected Client provideClientProvider() {
-        Client client = new TestingClientProvider(embeddedElasticSearch.getNode()).get();
-        return MailboxIndexCreationUtil.prepareDefaultClient(client, ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+        Client client = elasticSearch.clientProvider().get();
+        return MailboxIndexCreationUtil.prepareDefaultClient(client, ElasticSearchConfiguration.builder()
+            .addHost(elasticSearch.getTcpHost())
+            .build());
     }
 }
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestESMetricReporterModule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestEmbeddedESMetricReporterModule.java
similarity index 96%
rename from server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestESMetricReporterModule.java
rename to server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestEmbeddedESMetricReporterModule.java
index 85808e0..13284fa 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestESMetricReporterModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestEmbeddedESMetricReporterModule.java
@@ -26,7 +26,7 @@ import org.apache.james.metrics.es.ESReporterConfiguration;
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
 
-public class TestESMetricReporterModule extends AbstractModule {
+public class TestEmbeddedESMetricReporterModule extends AbstractModule {
 
     private static final String LOCALHOST = "localhost";
     private static final int DEFAULT_ES_HTTP_PORT = 9200;
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestEmbeddedElasticSearchModule.java
similarity index 92%
rename from server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
rename to server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestEmbeddedElasticSearchModule.java
index 0ada1f6..a0d4748 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestElasticSearchModule.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/TestEmbeddedElasticSearchModule.java
@@ -30,11 +30,11 @@ import org.elasticsearch.client.Client;
 import com.google.inject.AbstractModule;
 import com.google.inject.Provides;
 
-public class TestElasticSearchModule extends AbstractModule {
+public class TestEmbeddedElasticSearchModule extends AbstractModule {
 
     private final EmbeddedElasticSearch embeddedElasticSearch;
 
-    public TestElasticSearchModule(EmbeddedElasticSearch embeddedElasticSearch) {
+    public TestEmbeddedElasticSearchModule(EmbeddedElasticSearch embeddedElasticSearch) {
         this.embeddedElasticSearch = embeddedElasticSearch;
     }
 
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
index 4cb6304..7f770d6 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
@@ -36,8 +36,8 @@ import org.apache.james.jmap.methods.integration.cucumber.MainStepdefs;
 import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.modules.TestESMetricReporterModule;
-import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestEmbeddedESMetricReporterModule;
+import org.apache.james.modules.TestEmbeddedElasticSearchModule;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.server.CassandraTruncateTableTask;
 import org.apache.james.server.core.configuration.Configuration;
@@ -79,8 +79,8 @@ public class CassandraStepdefs {
         mainStepdefs.jmapServer = GuiceJamesServer.forConfiguration(configuration)
             .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
             .overrideWith(new TestJMAPServerModule(10))
-            .overrideWith(new TestESMetricReporterModule())
-            .overrideWith(new TestElasticSearchModule(embeddedElasticSearch))
+            .overrideWith(new TestEmbeddedESMetricReporterModule())
+            .overrideWith(new TestEmbeddedElasticSearchModule(embeddedElasticSearch))
             .overrideWith(cassandraServer.getModule())
             .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class))
             .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
diff --git a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/ReindexingWithEventDeadLettersTest.java
b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/ReindexingWithEventDeadLettersTest.java
index b1e2c85..c4385af 100644
--- a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/ReindexingWithEventDeadLettersTest.java
+++ b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/ReindexingWithEventDeadLettersTest.java
@@ -20,8 +20,6 @@
 package org.apache.james.jmap.rabbitmq;
 
 import static io.restassured.RestAssured.with;
-import static org.apache.james.DockerElasticSearchExtension.ELASTIC_SEARCH_HTTP_PORT;
-import static org.apache.james.DockerElasticSearchExtension.ELASTIC_SEARCH_PORT;
 import static org.apache.james.jmap.HttpJmapAuthentication.authenticateJamesUser;
 import static org.apache.james.jmap.JmapCommonRequests.getDraftId;
 import static org.apache.james.jmap.JmapCommonRequests.listMessageIdsForAccount;
@@ -47,8 +45,6 @@ import org.apache.james.modules.AwsS3BlobStoreExtension;
 import org.apache.james.modules.RabbitMQExtension;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.modules.objectstorage.PayloadCodecFactory;
-import org.apache.james.util.docker.DockerGenericContainer;
-import org.apache.james.util.docker.Images;
 import org.apache.james.utils.DataProbeImpl;
 import org.apache.james.utils.JmapGuiceProbe;
 import org.apache.james.utils.WebAdminGuiceProbe;
@@ -75,8 +71,7 @@ class ReindexingWithEventDeadLettersTest {
         .atMost(Duration.ONE_MINUTE)
         .await();
 
-    private static DockerGenericContainer elasticSearchContainer = new DockerGenericContainer(Images.ELASTICSEARCH_2)
-        .withExposedPorts(ELASTIC_SEARCH_HTTP_PORT, ELASTIC_SEARCH_PORT);
+    private static final DockerElasticSearchExtension dockerElasticSearch = new DockerElasticSearchExtension();
 
     private static final JamesServerBuilder.ServerProvider CONFIGURATION_BUILDER = configuration
-> GuiceJamesServer
             .forConfiguration(configuration)
@@ -88,7 +83,7 @@ class ReindexingWithEventDeadLettersTest {
 
     @RegisterExtension
     JamesServerExtension testExtension = new JamesServerBuilder()
-        .extension(new DockerElasticSearchExtension(elasticSearchContainer))
+        .extension(dockerElasticSearch)
         .extension(new CassandraExtension())
         .extension(new RabbitMQExtension())
         .extension(new AwsS3BlobStoreExtension(PayloadCodecFactory.AES256))
@@ -114,7 +109,7 @@ class ReindexingWithEventDeadLettersTest {
 
         aliceAccessToken = authenticateJamesUser(baseUri(jamesServer), ALICE, ALICE_PASSWORD);
 
-        elasticSearchContainer.pause();
+        dockerElasticSearch.getDockerES().pause();
         Thread.sleep(Duration.TEN_SECONDS.getValueInMS()); // Docker pause is asynchronous
and we found no way to poll for it
     }
 
@@ -152,7 +147,7 @@ class ReindexingWithEventDeadLettersTest {
     }
 
     private void unpauseElasticSearch() throws Exception {
-        elasticSearchContainer.unpause();
+        dockerElasticSearch.getDockerES().unpause();
         Thread.sleep(Duration.FIVE_SECONDS.getValueInMS()); // Docker unpause is asynchronous
and we found no way to poll for it
     }
 
diff --git a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/awss3/RabbitMQAwsS3Stepdefs.java
b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/awss3/RabbitMQAwsS3Stepdefs.java
index baf2f58..01d6747 100644
--- a/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/awss3/RabbitMQAwsS3Stepdefs.java
+++ b/server/protocols/jmap-integration-testing/rabbitmq-jmap-integration-testing/src/test/java/org/apache/james/jmap/rabbitmq/cucumber/awss3/RabbitMQAwsS3Stepdefs.java
@@ -20,6 +20,7 @@
 package org.apache.james.jmap.rabbitmq.cucumber.awss3;
 
 import java.util.Arrays;
+
 import javax.inject.Inject;
 
 import org.apache.activemq.store.PersistenceAdapter;
@@ -35,18 +36,18 @@ import org.apache.james.mailbox.cassandra.ids.CassandraMessageId;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
 import org.apache.james.modules.DockerRabbitMQRule;
-import org.apache.james.modules.TestESMetricReporterModule;
-import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestEmbeddedESMetricReporterModule;
+import org.apache.james.modules.TestEmbeddedElasticSearchModule;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.modules.TestRabbitMQModule;
 import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
 import org.apache.james.server.CassandraTruncateTableTask;
 import org.apache.james.server.core.configuration.Configuration;
-
 import org.junit.rules.TemporaryFolder;
 
 import com.github.fge.lambdas.runnable.ThrowingRunnable;
 import com.google.inject.multibindings.Multibinder;
+
 import cucumber.api.java.After;
 import cucumber.api.java.Before;
 import cucumber.runtime.java.guice.ScenarioScoped;
@@ -86,10 +87,10 @@ public class RabbitMQAwsS3Stepdefs {
         mainStepdefs.jmapServer = GuiceJamesServer.forConfiguration(configuration)
                 .combineWith(CassandraRabbitMQJamesServerMain.MODULES)
                 .overrideWith(new TestJMAPServerModule(JMAP_GET_MESSAGE_LIST_MAXIMUM_LIMIT))
-                .overrideWith(new TestESMetricReporterModule())
+                .overrideWith(new TestEmbeddedESMetricReporterModule())
                 .overrideWith(new TestRabbitMQModule(rabbitMQServer.dockerRabbitMQ()))
                 .overrideWith(swiftServer.getModule())
-                .overrideWith(new TestElasticSearchModule(embeddedElasticSearch))
+                .overrideWith(new TestEmbeddedElasticSearchModule(embeddedElasticSearch))
                 .overrideWith(cassandraServer.getModule())
                 .overrideWith(binder -> binder.bind(TextExtractor.class).to(DefaultTextExtractor.class))
                 .overrideWith((binder) -> binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
diff --git a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
index 3451c21..c89aea7 100644
--- a/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
+++ b/server/protocols/webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/CassandraJmapExtension.java
@@ -28,8 +28,8 @@ import org.apache.james.GuiceJamesServer;
 import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.search.PDFTextExtractor;
-import org.apache.james.modules.TestESMetricReporterModule;
-import org.apache.james.modules.TestElasticSearchModule;
+import org.apache.james.modules.TestEmbeddedESMetricReporterModule;
+import org.apache.james.modules.TestEmbeddedElasticSearchModule;
 import org.apache.james.modules.TestJMAPServerModule;
 import org.apache.james.server.core.configuration.Configuration;
 import org.apache.james.util.Runnables;
@@ -68,9 +68,9 @@ public class CassandraJmapExtension implements BeforeAllCallback, AfterAllCallba
         return GuiceJamesServer.forConfiguration(configuration)
                 .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE).overrideWith(binder -> binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
                 .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
-                .overrideWith(new TestESMetricReporterModule())
+                .overrideWith(new TestEmbeddedESMetricReporterModule())
                 .overrideWith(cassandra.getModule())
-                .overrideWith(new TestElasticSearchModule(elasticSearch))
+                .overrideWith(new TestEmbeddedElasticSearchModule(elasticSearch))
                 .overrideWith(binder -> binder.bind(WebAdminConfiguration.class).toInstance(WebAdminConfiguration.TEST_CONFIGURATION))
                 .overrideWith(new UnauthorizedModule())
                 .overrideWith((binder -> binder.bind(CleanupTasksPerformer.class).asEagerSingleton()));


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