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 8724fcd7bcfefb7c303282ee0c595a5cb1f2de88 Author: Benoit Tellier <[email protected]> AuthorDate: Fri Jun 7 14:39:36 2019 +0700 JAMES-2717 Enable parrallel inMemory testing in MPT IMAP Lucene tests InMemory mostly contributes the desired isolation. Time enhancement is achieved through the now possible parrallel test execution. Test time went (locally) from 7:06 to 3:19 --- mpt/impl/imap-mailbox/lucenesearch/pom.xml | 12 +++ .../lucenesearch/host/LuceneSearchHostSystem.java | 102 +++++++-------------- 2 files changed, 45 insertions(+), 69 deletions(-) diff --git a/mpt/impl/imap-mailbox/lucenesearch/pom.xml b/mpt/impl/imap-mailbox/lucenesearch/pom.xml index befdd90..16c444b 100644 --- a/mpt/impl/imap-mailbox/lucenesearch/pom.xml +++ b/mpt/impl/imap-mailbox/lucenesearch/pom.xml @@ -76,4 +76,16 @@ </dependency> </dependencies> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <reuseForks>true</reuseForks> + <forkCount>1C</forkCount> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java index b8358af..053aa1e 100644 --- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java +++ b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java @@ -19,10 +19,6 @@ package org.apache.james.mpt.imapmailbox.lucenesearch.host; -import java.io.File; -import java.io.IOException; - -import org.apache.commons.io.FileUtils; import org.apache.commons.lang.NotImplementedException; import org.apache.james.core.quota.QuotaCount; import org.apache.james.core.quota.QuotaSize; @@ -31,7 +27,6 @@ import org.apache.james.imap.encode.main.DefaultImapEncoderFactory; import org.apache.james.imap.main.DefaultImapDecoderFactory; import org.apache.james.imap.processor.main.DefaultImapProcessorFactory; import org.apache.james.mailbox.MailboxManager; -import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.SubscriptionManager; import org.apache.james.mailbox.inmemory.InMemoryId; import org.apache.james.mailbox.inmemory.InMemoryMailboxManager; @@ -44,87 +39,56 @@ import org.apache.james.metrics.logger.DefaultMetricFactory; import org.apache.james.mpt.api.ImapFeatures; import org.apache.james.mpt.api.ImapFeatures.Feature; import org.apache.james.mpt.host.JamesImapHostSystem; -import org.apache.lucene.store.FSDirectory; +import org.apache.lucene.store.RAMDirectory; import com.github.fge.lambdas.Throwing; -import com.google.common.io.Files; public class LuceneSearchHostSystem extends JamesImapHostSystem { - public static final String META_DATA_DIRECTORY = "target/user-meta-data"; private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT, Feature.MOD_SEQ_SEARCH); - - private File tempFile; private InMemoryMailboxManager mailboxManager; private LuceneMessageSearchIndex searchIndex; @Override public void beforeTest() throws Exception { super.beforeTest(); - this.tempFile = Files.createTempDir(); initFields(); } - @Override - public void afterTest() throws Exception { - tempFile.deleteOnExit(); - - resetUserMetaData(); - MailboxSession session = mailboxManager.createSystemSession("test"); - mailboxManager.startProcessingRequest(session); - mailboxManager.endProcessingRequest(session); - mailboxManager.logout(session, false); - } - - public void resetUserMetaData() throws Exception { - File dir = new File(META_DATA_DIRECTORY); - if (dir.exists()) { - FileUtils.deleteDirectory(dir); - } - dir.mkdirs(); - } - private void initFields() { - try { - FSDirectory fsDirectory = FSDirectory.open(tempFile); - - InMemoryIntegrationResources resources = InMemoryIntegrationResources.builder() - .authenticator(authenticator) - .authorizator(authorizator) - .inVmEventBus() - .defaultAnnotationLimits() - .defaultMessageParser() - .listeningSearchIndex(Throwing.function(preInstanciationStage -> new LuceneMessageSearchIndex( - preInstanciationStage.getMapperFactory(), new InMemoryId.Factory(), fsDirectory, - new InMemoryMessageId.Factory(), - preInstanciationStage.getSessionProvider()))) - .noPreDeletionHooks() - .storeQuotaManager() - .build(); - - mailboxManager = resources.getMailboxManager(); - - searchIndex = (LuceneMessageSearchIndex) resources.getSearchIndex(); - searchIndex.setEnableSuffixMatch(true); - SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mailboxManager.getMapperFactory()); - - ImapProcessor defaultImapProcessorFactory = - DefaultImapProcessorFactory.createDefaultProcessor( - mailboxManager, - resources.getMailboxManager().getEventBus(), - subscriptionManager, - new NoQuotaManager(), - resources.getDefaultUserQuotaRootResolver(), - new DefaultMetricFactory()); - - configure(new DefaultImapDecoderFactory().buildImapDecoder(), - new DefaultImapEncoderFactory().buildImapEncoder(), - defaultImapProcessorFactory); - - } catch (IOException e) { - throw new RuntimeException(e); - } + InMemoryIntegrationResources resources = InMemoryIntegrationResources.builder() + .authenticator(authenticator) + .authorizator(authorizator) + .inVmEventBus() + .defaultAnnotationLimits() + .defaultMessageParser() + .listeningSearchIndex(Throwing.function(preInstanciationStage -> new LuceneMessageSearchIndex( + preInstanciationStage.getMapperFactory(), new InMemoryId.Factory(), new RAMDirectory(), + new InMemoryMessageId.Factory(), + preInstanciationStage.getSessionProvider()))) + .noPreDeletionHooks() + .storeQuotaManager() + .build(); + + mailboxManager = resources.getMailboxManager(); + + searchIndex = (LuceneMessageSearchIndex) resources.getSearchIndex(); + searchIndex.setEnableSuffixMatch(true); + SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mailboxManager.getMapperFactory()); + + ImapProcessor defaultImapProcessorFactory = + DefaultImapProcessorFactory.createDefaultProcessor( + mailboxManager, + resources.getMailboxManager().getEventBus(), + subscriptionManager, + new NoQuotaManager(), + resources.getDefaultUserQuotaRootResolver(), + new DefaultMetricFactory()); + + configure(new DefaultImapDecoderFactory().buildImapDecoder(), + new DefaultImapEncoderFactory().buildImapEncoder(), + defaultImapProcessorFactory); } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
