You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/05/10 11:30:21 UTC
[james-project] 08/17: JAMES-2717 Replace embedded ES in
ElasticSearchHostSystem
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 f213b55b49ed7ceb5007cf6a26d028f81828981d
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed May 8 16:43:28 2019 +0700
JAMES-2717 Replace embedded ES in ElasticSearchHostSystem
---
mpt/impl/imap-mailbox/elasticsearch/pom.xml | 11 ++++++++
.../host/ElasticSearchHostSystem.java | 30 ++++++++++------------
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/mpt/impl/imap-mailbox/elasticsearch/pom.xml b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
index 0262778..be52a11 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/pom.xml
+++ b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
@@ -77,8 +77,19 @@
<artifactId>apache-james-mpt-imapmailbox-core</artifactId>
</dependency>
<dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 4bdb966..c882ebb 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -19,18 +19,15 @@
package org.apache.james.mpt.imapmailbox.elasticsearch.host;
-import java.nio.file.Files;
-import java.nio.file.Path;
import java.time.ZoneId;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.NotImplementedException;
+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.backends.es.ElasticSearchIndexer;
-import org.apache.james.backends.es.EmbeddedElasticSearch;
-import org.apache.james.backends.es.utils.TestingClientProvider;
import org.apache.james.core.quota.QuotaCount;
import org.apache.james.core.quota.QuotaSize;
import org.apache.james.imap.api.process.ImapProcessor;
@@ -65,30 +62,29 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
Feature.MOD_SEQ_SEARCH);
- private EmbeddedElasticSearch embeddedElasticSearch;
- private Path tempDirectory;
+ private DockerElasticSearch dockerElasticSearch;
private StoreMailboxManager mailboxManager;
-
@Override
public void beforeTest() throws Exception {
super.beforeTest();
- this.tempDirectory = Files.createTempDirectory("elasticsearch");
- this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory);
- embeddedElasticSearch.before();
+ this.dockerElasticSearch = DockerElasticSearchSingleton.INSTANCE;
+ dockerElasticSearch.start();
initFields();
}
@Override
- public void afterTest() throws Exception {
- embeddedElasticSearch.after();
- FileUtils.deleteDirectory(tempDirectory.toFile());
+ public void afterTest() {
+ dockerElasticSearch.cleanUpData();
}
private void initFields() {
Client client = MailboxIndexCreationUtil.prepareDefaultClient(
- new TestingClientProvider(embeddedElasticSearch.getNode()).get(),
- ElasticSearchConfiguration.DEFAULT_CONFIGURATION);
+ dockerElasticSearch.clientProvider().get(),
+ ElasticSearchConfiguration.builder()
+ .addHost(dockerElasticSearch.getTcpHost())
+ .build());
+
InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
ThreadFactory threadFactory = NamedThreadFactory.withClassName(getClass());
@@ -145,6 +141,6 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
@Override
protected void await() {
- embeddedElasticSearch.awaitForElasticSearch();
+ dockerElasticSearch.awaitForElasticSearch();
}
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org