polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject zest-java git commit: index-elastic: assembly with provided client & tests speedup
Date Sun, 20 Nov 2016 10:45:55 GMT
Repository: zest-java
Updated Branches:
  refs/heads/develop 0cd5a1508 -> d1029354d


index-elastic: assembly with provided client & tests speedup

Introduce an assembly where the Elasticsearch Client is provided from
outside of the Application.

Starting with Elasticsearch 5, startup is way slower.
Use the new assembly in tests to start an embedded local node per test
class and use an index per test method, paying startup cost once per
test class only. Went down from ~4min to ~1min locally.


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/d1029354
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/d1029354
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/d1029354

Branch: refs/heads/develop
Commit: d1029354dc4b9f4b7d7ff759e3632b33674d76c5
Parents: 0cd5a15
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Sun Nov 20 11:45:35 2016 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Sun Nov 20 11:45:35 2016 +0100

----------------------------------------------------------------------
 .../src/docs/index-elasticsearch.txt            |  34 ++++-
 .../assembly/ESClientIndexQueryAssembler.java   |  57 ++++++++
 .../client/ESClientIndexQueryService.java       |  30 +++++
 .../elasticsearch/client/ESClientSupport.java   |  53 ++++++++
 .../index/elasticsearch/client/package.html     |  24 ++++
 .../internal/AbstractElasticSearchSupport.java  |   9 +-
 .../elasticsearch/DocumentationSupport.java     |  17 ++-
 .../index/elasticsearch/ESEmbeddedRule.java     | 134 +++++++++++++++++++
 .../ElasticSearchComplexQueryTest.java          |  23 ++--
 .../elasticsearch/ElasticSearchFinderTest.java  |  17 ++-
 .../ElasticSearchQueryMultimoduleTest.java      |   6 +-
 .../elasticsearch/ElasticSearchQueryTest.java   |  36 +++--
 .../index/elasticsearch/ElasticSearchTest.java  |  20 ++-
 .../index/elasticsearch/ImmenseTermTest.java    |  17 ++-
 14 files changed, 442 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt b/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt
index 51fdb99..307d327 100644
--- a/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt
+++ b/extensions/indexing-elasticsearch/src/docs/index-elasticsearch.txt
@@ -32,10 +32,11 @@ http://lucene.apache.org/[Apache Lucene].
 
 WARNING: ElasticSearch Index/Query do not support ComplexQueries from the Query API, ie.
queries by "example value".
 
-Two modes of operation are supported:
+Three modes of operation are supported:
 
-- local filesystem ;
-- clustered.
+- embedded local only filesystem based node ;
+- managed cluster client ;
+- with a provided client.
 
 In any case, Lucene hard limits apply.
 See the https://lucene.apache.org/core/6_1_0/core/org/apache/lucene/codecs/lucene60/package-summary.html#Limitations[Lucene
File Format]
@@ -99,3 +100,30 @@ tag=config
 
 Again, all configuration properties are defaulted meaning that you can use ElasticSearch
Index/Query service without
 configuration.
+
+== Using a provided client ==
+
+=== Assembly ===
+
+Assembly is done using the provided Assembler:
+
+[snippet,java]
+----
+source=extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
+tag=client
+----
+
+
+=== Configuration ===
+
+Here are the configuration properties for the ElasticSearch Index/Query service using a provided
client.
+Note that the `clusterName` is ignored as this is managed by the client.
+
+[snippet,java]
+----
+source=extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/ElasticSearchConfiguration.java
+tag=client
+----
+
+Again, all configuration properties are defaulted meaning that you can use ElasticSearch
Index/Query service without
+configuration.

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClientIndexQueryAssembler.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClientIndexQueryAssembler.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClientIndexQueryAssembler.java
new file mode 100644
index 0000000..87d8b28
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/assembly/ESClientIndexQueryAssembler.java
@@ -0,0 +1,57 @@
+/*
+ *  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.zest.index.elasticsearch.assembly;
+
+import org.apache.zest.api.value.ValueSerialization;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.index.elasticsearch.ElasticSearchConfiguration;
+import org.apache.zest.index.elasticsearch.client.ESClientIndexQueryService;
+import org.apache.zest.index.elasticsearch.internal.AbstractElasticSearchAssembler;
+import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
+import org.elasticsearch.client.Client;
+
+public class ESClientIndexQueryAssembler
+    extends AbstractElasticSearchAssembler<ESClientIndexQueryAssembler>
+{
+    private final Client client;
+
+    public ESClientIndexQueryAssembler( final Client client )
+    {
+        this.client = client;
+    }
+
+    @Override
+    public void assemble( final ModuleAssembly module ) throws AssemblyException
+    {
+        module.services( ESClientIndexQueryService.class )
+              .identifiedBy( identity() )
+              .setMetaInfo( client )
+              .visibleIn( visibility() )
+              .instantiateOnStartup();
+
+        module.services( OrgJsonValueSerializationService.class )
+              .taggedWith( ValueSerialization.Formats.JSON );
+
+        if( hasConfig() )
+        {
+            configModule().entities( ElasticSearchConfiguration.class )
+                          .visibleIn( configVisibility() );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientIndexQueryService.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientIndexQueryService.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientIndexQueryService.java
new file mode 100644
index 0000000..bb1a740
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientIndexQueryService.java
@@ -0,0 +1,30 @@
+/*
+ *  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.zest.index.elasticsearch.client;
+
+import org.apache.zest.api.mixin.Mixins;
+import org.apache.zest.api.service.ServiceComposite;
+import org.apache.zest.index.elasticsearch.ElasticSearchFinder;
+import org.apache.zest.index.elasticsearch.ElasticSearchIndexer;
+import org.apache.zest.index.elasticsearch.ElasticSearchSupport;
+
+@Mixins( ESClientSupport.class )
+public interface ESClientIndexQueryService
+    extends ElasticSearchIndexer, ElasticSearchFinder, ElasticSearchSupport, ServiceComposite
+{
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientSupport.java
new file mode 100644
index 0000000..0399d97
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/ESClientSupport.java
@@ -0,0 +1,53 @@
+/*
+ *  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.zest.index.elasticsearch.client;
+
+import org.apache.zest.api.configuration.Configuration;
+import org.apache.zest.api.injection.scope.This;
+import org.apache.zest.api.injection.scope.Uses;
+import org.apache.zest.api.service.ServiceDescriptor;
+import org.apache.zest.index.elasticsearch.ElasticSearchConfiguration;
+import org.apache.zest.index.elasticsearch.internal.AbstractElasticSearchSupport;
+import org.elasticsearch.client.Client;
+
+public class ESClientSupport extends AbstractElasticSearchSupport
+{
+    @This
+    private Configuration<ElasticSearchConfiguration> configuration;
+
+    @Uses
+    private ServiceDescriptor descriptor;
+
+    @Override
+    protected void activateElasticSearch() throws Exception
+    {
+        configuration.refresh();
+        ElasticSearchConfiguration config = configuration.get();
+
+        index = config.index().get() == null ? DEFAULT_INDEX_NAME : config.index().get();
+        indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
+
+        client = descriptor.metaInfo( Client.class );
+    }
+
+    @Override
+    protected void passivateClient()
+    {
+        client = null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/package.html
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/package.html
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/package.html
new file mode 100644
index 0000000..cfb999e
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/client/package.html
@@ -0,0 +1,24 @@
+<!--
+  ~  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.
+  ~
+  ~
+  -->
+<html>
+    <body>
+        <h2>ElasticSearch Index/Query Client Support.</h2>
+    </body>
+</html>

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
index 569127b..74fd270 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
@@ -110,13 +110,18 @@ public abstract class AbstractElasticSearchSupport
     public final void passivateService()
         throws Exception
     {
-        client.close();
-        client = null;
+        passivateClient();
         index = null;
         indexNonAggregatedAssociations = false;
         passivateElasticSearch();
     }
 
+    protected void passivateClient()
+    {
+        client.close();
+        client = null;
+    }
+
     protected void passivateElasticSearch()
         throws Exception
     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
index c76e22e..4a34cee 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
@@ -23,8 +23,10 @@ import org.apache.zest.api.common.Visibility;
 import org.apache.zest.bootstrap.Assembler;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.index.elasticsearch.assembly.ESClusterIndexQueryAssembler;
 import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.elasticsearch.client.Client;
 
 public class DocumentationSupport
     implements Assembler
@@ -37,11 +39,22 @@ public class DocumentationSupport
         Visibility configVisibility = Visibility.module;
 
         // START SNIPPET: filesystem
-        new ESFilesystemIndexQueryAssembler().withConfig( configModule, configVisibility
).assemble( module );
+        new ESFilesystemIndexQueryAssembler()
+            .withConfig( configModule, configVisibility )
+            .assemble( module );
         // END SNIPPET: filesystem
 
         // START SNIPPET: cluster
-        new ESClusterIndexQueryAssembler().withConfig( configModule, configVisibility ).assemble(
module );
+        new ESClusterIndexQueryAssembler()
+            .withConfig( configModule, configVisibility )
+            .assemble( module );
         // END SNIPPET: cluster
+
+        Client client = null;
+        // START SNIPPET: client
+        new ESClientIndexQueryAssembler( client )
+            .withConfig( configModule, configVisibility )
+            .assemble( module );
+        // END SNIPPET: client
     }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ESEmbeddedRule.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ESEmbeddedRule.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ESEmbeddedRule.java
new file mode 100644
index 0000000..f9ad80d
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ESEmbeddedRule.java
@@ -0,0 +1,134 @@
+/*
+ *  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.zest.index.elasticsearch;
+
+import java.util.Locale;
+import org.apache.zest.api.activation.ActivationException;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.api.structure.Application;
+import org.apache.zest.api.structure.Module;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.bootstrap.SingletonAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
+import org.apache.zest.library.fileconfig.FileConfigurationOverride;
+import org.apache.zest.test.EntityTestAssembler;
+import org.elasticsearch.client.Client;
+import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+/**
+ * Embedded Elasticsearch JUnit Rule.
+ *
+ * Starting from Elasticsearch 5, startup is way slower.
+ * Reuse an embedded instance across tests.
+ */
+public class ESEmbeddedRule implements TestRule
+{
+    private final TemporaryFolder tmpDir;
+    private Client client;
+
+    public ESEmbeddedRule( TemporaryFolder tmpDir )
+    {
+        this.tmpDir = tmpDir;
+    }
+
+    public Client client()
+    {
+        client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
+        return client;
+    }
+
+    public String indexName( String className, String methodName )
+    {
+        String indexName = className;
+        if( methodName != null )
+        {
+            indexName += '-' + methodName;
+        }
+        return indexName.toLowerCase( Locale.US );
+    }
+
+    @Override
+    public Statement apply( final Statement base, final Description description )
+    {
+        return new Statement()
+        {
+            @Override
+            public void evaluate() throws Throwable
+            {
+                String name = indexName( description.getClassName(), description.getMethodName()
);
+                SingletonAssembler assembler = activateEmbeddedElasticsearch( name );
+                Application application = assembler.application();
+                client = findClient( assembler.module() );
+                try
+                {
+                    base.evaluate();
+                }
+                finally
+                {
+                    application.passivate();
+                    client.close();
+                    client = null;
+                }
+            }
+        };
+    }
+
+    private SingletonAssembler activateEmbeddedElasticsearch( final String name )
+    {
+        try
+        {
+            return new SingletonAssembler()
+            {
+                @Override
+                public void assemble( final ModuleAssembly module ) throws AssemblyException
+                {
+                    module.layer().application().setName( name );
+                    ModuleAssembly config = module.layer().module( "config" );
+                    new EntityTestAssembler().assemble( config );
+                    new EntityTestAssembler().assemble( module );
+                    new FileConfigurationAssembler()
+                        .withOverride( new FileConfigurationOverride().withConventionalRoot(
tmpDir.getRoot() ) )
+                        .assemble( module );
+                    new ESFilesystemIndexQueryAssembler()
+                        .identifiedBy( name )
+                        .withConfig( config, Visibility.layer )
+                        .assemble( module );
+                }
+            };
+        }
+        catch( ActivationException | AssemblyException ex )
+        {
+            throw new RuntimeException( "Embedded Elasticsearch Rule - Failed to activate",
ex );
+        }
+    }
+
+    private Client findClient( Module module )
+    {
+        Client client = module.serviceFinder().findService( ElasticSearchSupport.class ).get().client();
+        if( client == null )
+        {
+            throw new IllegalStateException( "Embedded Elasticsearch Rule - Failed to find
client" );
+        }
+        return client;
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
index 8e8577b..d8a6ec4 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
@@ -20,15 +20,17 @@ package org.apache.zest.index.elasticsearch;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.test.EntityTestAssembler;
 import org.apache.zest.test.indexing.AbstractComplexQueryTest;
 import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
 
@@ -36,6 +38,15 @@ import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
 public class ElasticSearchComplexQueryTest
     extends AbstractComplexQueryTest
 {
+    @ClassRule
+    public static final TemporaryFolder ELASTIC_SEARCH_DIR = new TemporaryFolder();
+
+    @ClassRule
+    public static final ESEmbeddedRule ELASTIC_SEARCH = new ESEmbeddedRule( ELASTIC_SEARCH_DIR
);
+
+    @Rule
+    public final TestName testName = new TestName();
+
     @Rule
     public TemporaryFolder tmpDir = new TemporaryFolder();
 
@@ -56,10 +67,12 @@ public class ElasticSearchComplexQueryTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler()
+        new ESClientIndexQueryAssembler( ELASTIC_SEARCH.client() )
             .withConfig( config, Visibility.layer )
             .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.index().set( ELASTIC_SEARCH.indexName( ElasticSearchQueryTest.class.getName(),
+                                                        testName.getMethodName() ) );
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
@@ -67,10 +80,4 @@ public class ElasticSearchComplexQueryTest
             .withOverride( new FileConfigurationOverride().withConventionalRoot( tmpDir.getRoot()
) )
             .assemble( module );
     }
-
-    @Override
-    public void showNetwork()
-    {
-        // IndexExporter not supported by ElasticSearch
-    }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
index c85ebc7..c68fdf3 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
@@ -20,20 +20,31 @@ package org.apache.zest.index.elasticsearch;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.test.EntityTestAssembler;
 import org.apache.zest.test.indexing.AbstractEntityFinderTest;
 import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
 
 public class ElasticSearchFinderTest
     extends AbstractEntityFinderTest
 {
+    @ClassRule
+    public static final TemporaryFolder ELASTIC_SEARCH_DIR = new TemporaryFolder();
+
+    @ClassRule
+    public static final ESEmbeddedRule ELASTIC_SEARCH = new ESEmbeddedRule( ELASTIC_SEARCH_DIR
);
+
+    @Rule
+    public final TestName testName = new TestName();
+
     @Rule
     public TemporaryFolder tmpDir = new TemporaryFolder();
 
@@ -54,10 +65,12 @@ public class ElasticSearchFinderTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler()
+        new ESClientIndexQueryAssembler( ELASTIC_SEARCH.client() )
             .withConfig( config, Visibility.layer )
             .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.index().set( ELASTIC_SEARCH.indexName( ElasticSearchQueryTest.class.getName(),
+                                                        testName.getMethodName() ) );
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
index 0840f35..699af70 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
@@ -24,7 +24,7 @@ import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
 import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.bootstrap.unitofwork.DefaultUnitOfWorkAssembler;
-import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.test.EntityTestAssembler;
@@ -49,11 +49,13 @@ public class ElasticSearchQueryMultimoduleTest extends ElasticSearchQueryTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler()
+        new ESClientIndexQueryAssembler( ELASTIC_SEARCH.client() )
             .withConfig( config, Visibility.application )
             .visibleIn( Visibility.layer )
             .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.index().set( ELASTIC_SEARCH.indexName( ElasticSearchQueryTest.class.getName(),
+                                                        testName.getMethodName() ) );
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
index 25c9091..dfc9bab 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
@@ -24,22 +24,23 @@ import java.io.IOException;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.spi.query.EntityFinderException;
 import org.apache.zest.test.EntityTestAssembler;
 import org.apache.zest.test.indexing.AbstractQueryTest;
+import org.apache.zest.test.util.NotYetImplemented;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
 
-public class ElasticSearchQueryTest
-    extends AbstractQueryTest
+public class ElasticSearchQueryTest extends AbstractQueryTest
 {
     @BeforeClass
     public static void beforeClass_IBMJDK()
@@ -47,6 +48,15 @@ public class ElasticSearchQueryTest
         assumeNoIbmJdk();
     }
 
+    @ClassRule
+    public static final TemporaryFolder ELASTIC_SEARCH_DIR = new TemporaryFolder();
+
+    @ClassRule
+    public static final ESEmbeddedRule ELASTIC_SEARCH = new ESEmbeddedRule( ELASTIC_SEARCH_DIR
);
+
+    @Rule
+    public final TestName testName = new TestName();
+
     @Rule
     public TemporaryFolder tmpDir = new TemporaryFolder();
 
@@ -61,8 +71,12 @@ public class ElasticSearchQueryTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().withConfig( config, Visibility.layer ).assemble(
module );
+        new ESClientIndexQueryAssembler( ELASTIC_SEARCH.client() )
+            .withConfig( config, Visibility.layer )
+            .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.index().set( ELASTIC_SEARCH.indexName( ElasticSearchQueryTest.class.getName(),
+                                                        testName.getMethodName() ) );
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
@@ -71,8 +85,8 @@ public class ElasticSearchQueryTest
             .assemble( module );
     }
 
+    @NotYetImplemented( reason = "IndexExporter service not implemented" )
     @Test
-    @Ignore( "IndexExporter not supported by ElasticSearch Indexing" )
     @Override
     public void showNetwork()
         throws IOException
@@ -80,8 +94,8 @@ public class ElasticSearchQueryTest
         super.showNetwork();
     }
 
+    @NotYetImplemented( reason = "oneOf() Query Expression not implemented" )
     @Test
-    @Ignore( "oneOf() Query Expression not supported by ElasticSearch Indexing" )
     @Override
     public void script23()
         throws EntityFinderException
@@ -89,11 +103,11 @@ public class ElasticSearchQueryTest
         super.script23();
     }
 
-    @Test
-    @Ignore(
-         "ElasticSearch perform automatic TimeZone resolution when querying on dates, this
test assert that the "
-         + "underlying Index/Query engine do not."
+    @NotYetImplemented(
+        reason = "ElasticSearch perform automatic TimeZone resolution when querying on dates,
"
+                 + "this test assert that the underlying Index/Query engine do not."
     )
+    @Test
     @Override
     public void script42_DateTime()
     {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
index 4a2050c..425d79d 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
@@ -33,15 +33,17 @@ import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.api.unitofwork.UnitOfWorkCompletionException;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
 import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import static org.apache.zest.api.query.QueryExpressions.eq;
 import static org.apache.zest.api.query.QueryExpressions.ne;
@@ -60,6 +62,15 @@ public class ElasticSearchTest
         assumeNoIbmJdk();
     }
 
+    @ClassRule
+    public static final TemporaryFolder ELASTIC_SEARCH_DIR = new TemporaryFolder();
+
+    @ClassRule
+    public static final ESEmbeddedRule ELASTIC_SEARCH = new ESEmbeddedRule( ELASTIC_SEARCH_DIR
);
+
+    @Rule
+    public final TestName testName = new TestName();
+
     @Rule
     public TemporaryFolder tmpDir = new TemporaryFolder();
 
@@ -123,9 +134,12 @@ public class ElasticSearchTest
         new EntityTestAssembler().assemble( module );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().withConfig( config, Visibility.layer )
-                                             .assemble( module );
+        new ESClientIndexQueryAssembler( ELASTIC_SEARCH.client() )
+            .withConfig( config, Visibility.layer )
+            .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.index().set( ELASTIC_SEARCH.indexName( ElasticSearchQueryTest.class.getName(),
+                                                        testName.getMethodName() ) );
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig

http://git-wip-us.apache.org/repos/asf/zest-java/blob/d1029354/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
index 04b9f6e..195916e 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
@@ -31,15 +31,17 @@ import org.apache.zest.api.query.Query;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.index.elasticsearch.assembly.ESClientIndexQueryAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationAssembler;
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
 import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.TestName;
 
 import static org.apache.zest.api.query.QueryExpressions.eq;
 import static org.apache.zest.api.query.QueryExpressions.templateFor;
@@ -55,6 +57,15 @@ import static org.junit.Assert.assertThat;
 public class ImmenseTermTest
     extends AbstractZestTest
 {
+    @ClassRule
+    public static final TemporaryFolder ELASTIC_SEARCH_DIR = new TemporaryFolder();
+
+    @ClassRule
+    public static final ESEmbeddedRule ELASTIC_SEARCH = new ESEmbeddedRule( ELASTIC_SEARCH_DIR
);
+
+    @Rule
+    public final TestName testName = new TestName();
+
     @Rule
     public TemporaryFolder tmpDir = new TemporaryFolder();
 
@@ -96,10 +107,12 @@ public class ImmenseTermTest
         new EntityTestAssembler().assemble( module );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler()
+        new ESClientIndexQueryAssembler( ELASTIC_SEARCH.client() )
             .withConfig( config, Visibility.layer )
             .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.index().set( ELASTIC_SEARCH.indexName( ElasticSearchQueryTest.class.getName(),
+                                                        testName.getMethodName() ) );
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig


Mime
View raw message