Repository: incubator-unomi
Updated Branches:
  refs/heads/master a027ad33d -> ed5604f7f


UNOMI-72 Use custom cluster name for ElasticSearch when running integration 
tests.

Signed-off-by: Serge Huber <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/ed5604f7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/ed5604f7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/ed5604f7

Branch: refs/heads/master
Commit: ed5604f7f548de3034b6d03bfe14759d6b3ae23d
Parents: a027ad3
Author: Serge Huber <[email protected]>
Authored: Wed Nov 8 14:58:58 2017 +0100
Committer: Serge Huber <[email protected]>
Committed: Wed Nov 8 14:58:58 2017 +0100

----------------------------------------------------------------------
 itests/pom.xml                                       |  2 +-
 .../test/java/org/apache/unomi/itests/BaseIT.java    |  1 +
 .../ElasticSearchPersistenceServiceImpl.java         | 15 +++++++++++----
 3 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/ed5604f7/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index b94af56..ffddcc2 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -159,7 +159,7 @@
                 <!-- REPLACE THE FOLLOWING WITH THE PLUGIN VERSION YOU NEED -->
                 <version>5.7</version>
                 <configuration>
-                    <clusterName>contextElasticSearch</clusterName>
+                    <clusterName>contextElasticSearchITests</clusterName>
                     <transportPort>9500</transportPort>
                     <httpPort>9400</httpPort>
                     <version>${elasticsearch.version}</version>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/ed5604f7/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java 
b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
index 3f88d01..4c4a845 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -113,6 +113,7 @@ public abstract class BaseIT {
 //                
systemProperty("org.osgi.service.http.port").value(HTTP_PORT),
                 
systemProperty("org.ops4j.pax.exam.rbc.rmi.port").value("1199"),
                 
systemProperty("org.apache.unomi.itests.elasticsearch.transport.port").value("9500"),
+                
systemProperty("org.apache.unomi.itests.elasticsearch.cluster.name").value("contextElasticSearchITests"),
                 
systemProperty("org.apache.unomi.itests.elasticsearch.http.port").value("9400"),
                 systemProperty("unomi.autoStart").value("true"),
                 features(karafPaxWebRepo, "shell"),

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/ed5604f7/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
 
b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
index 5f119a4..933724e 100644
--- 
a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
+++ 
b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java
@@ -248,7 +248,6 @@ public class ElasticSearchPersistenceServiceImpl implements 
PersistenceService,
         // on startup
         new InClassLoaderExecute<Object>() {
             public Object execute(Object... args) throws Exception {
-                logger.info("Connecting to ElasticSearch persistence backend 
using cluster name " + clusterName + " and index name " + indexName + "...");
 
                 bulkProcessorConcurrentRequests = 
System.getProperty(BULK_PROCESSOR_CONCURRENT_REQUESTS, 
bulkProcessorConcurrentRequests);
                 bulkProcessorBulkActions = 
System.getProperty(BULK_PROCESSOR_BULK_ACTIONS, bulkProcessorBulkActions);
@@ -256,15 +255,23 @@ public class ElasticSearchPersistenceServiceImpl 
implements PersistenceService,
                 bulkProcessorFlushInterval = 
System.getProperty(BULK_PROCESSOR_FLUSH_INTERVAL, bulkProcessorFlushInterval);
                 bulkProcessorBackoffPolicy = 
System.getProperty(BULK_PROCESSOR_BACKOFF_POLICY, bulkProcessorBackoffPolicy);
 
-                Settings transportSettings = Settings.builder()
-                        .put(CLUSTER_NAME, clusterName).build();
-
                 // this property is used for integration tests, to make sure 
we don't conflict with an already running ElasticSearch instance.
                 if 
(System.getProperty("org.apache.unomi.itests.elasticsearch.transport.port") != 
null) {
                     elasticSearchAddressList.clear();
                     elasticSearchAddressList.add("localhost:" + 
System.getProperty("org.apache.unomi.itests.elasticsearch.transport.port"));
+                    logger.info("Overriding ElasticSearch address list from 
system property=" + elasticSearchAddressList);
+                }
+                // this property is used for integration tests, to make sure 
we don't conflict with an already running ElasticSearch instance.
+                if 
(System.getProperty("org.apache.unomi.itests.elasticsearch.cluster.name") != 
null) {
+                    clusterName = 
System.getProperty("org.apache.unomi.itests.elasticsearch.cluster.name");
+                    logger.info("Overriding cluster name from system 
property=" + clusterName);
                 }
 
+                Settings transportSettings = Settings.builder()
+                        .put(CLUSTER_NAME, clusterName).build();
+
+                logger.info("Connecting to ElasticSearch persistence backend 
using cluster name " + clusterName + " and index name " + indexName + "...");
+
                 client = new PreBuiltTransportClient(transportSettings);
                 for (String elasticSearchAddress : elasticSearchAddressList) {
                     String[] elasticSearchAddressParts = 
elasticSearchAddress.split(":");

Reply via email to