Repository: incubator-unomi
Updated Branches:
  refs/heads/master da9d4d277 -> af7bfb114


UNOMI-184 Integration tests will fail "randomly"
This should fix the integration tests. Problem was due to the reloading of 
property types while ElasticSearch was still indexing, making the newly created 
property not yet available. Fixed by changing the reload frequency from 5 
seconds to 10 seconds. We really need to make these timers configurable though, 
but this will be done at a later point in time.
Also included in this fix :
- The integration tests will now setup the camel context in "tracing" mode, 
making issues easier to debug. This is only done during integration tests, by 
default tracing is disabled.
- Improved error logging in LineSplitProcessor, this will also make catching 
other problems with this processor hopefully easier.

Signed-off-by: Serge Huber <shu...@apache.org>


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

Branch: refs/heads/master
Commit: af7bfb11474937ad01e50423f24ee681451e6a58
Parents: da9d4d2
Author: Serge Huber <shu...@apache.org>
Authored: Sun Jun 24 20:47:03 2018 +0200
Committer: Serge Huber <shu...@apache.org>
Committed: Sun Jun 24 20:47:03 2018 +0200

----------------------------------------------------------------------
 .../org/apache/unomi/router/api/IRouterCamelContext.java |  2 ++
 .../api/services/ImportExportConfigurationService.java   |  6 +++++-
 .../unomi/router/core/context/RouterCamelContext.java    |  4 ++++
 .../unomi/router/core/processor/LineSplitProcessor.java  | 11 +++++++++--
 .../services/AbstractConfigurationServiceImpl.java       |  4 ++++
 .../org/apache/unomi/itests/ProfileImportRankingIT.java  |  2 ++
 .../org/apache/unomi/itests/ProfileImportSurfersIT.java  |  7 ++++++-
 .../unomi/services/services/ProfileServiceImpl.java      |  4 ++--
 8 files changed, 34 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/IRouterCamelContext.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/IRouterCamelContext.java
 
b/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/IRouterCamelContext.java
index 8775b43..d35c3d4 100644
--- 
a/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/IRouterCamelContext.java
+++ 
b/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/IRouterCamelContext.java
@@ -24,4 +24,6 @@ public interface IRouterCamelContext {
     void killExistingRoute(String routeId, boolean fireEvent) throws Exception;
 
     void updateProfileReaderRoute(Object configuration, boolean fireEvent) 
throws Exception;
+
+    void setTracing(boolean tracing);
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ImportExportConfigurationService.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ImportExportConfigurationService.java
 
b/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ImportExportConfigurationService.java
index 1cf670a..e7197f8 100644
--- 
a/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ImportExportConfigurationService.java
+++ 
b/extensions/router/router-api/src/main/java/org/apache/unomi/router/api/services/ImportExportConfigurationService.java
@@ -66,5 +66,9 @@ public interface ImportExportConfigurationService<T> {
      */
     void setRouterCamelContext(IRouterCamelContext routerCamelContext);
 
-
+    /**
+     * Retrieve the configured router camel context
+     * @return the configured instance, or null if not configured
+     */
+    IRouterCamelContext getRouterCamelContext();
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java
 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java
index 309d27a..fdcebfa 100644
--- 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java
+++ 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/context/RouterCamelContext.java
@@ -98,6 +98,10 @@ public class RouterCamelContext implements 
SynchronousBundleListener, IRouterCam
         this.clusterService = clusterService;
     }
 
+    public void setTracing(boolean tracing) {
+        camelContext.setTracing(true);
+    }
+
     public void initCamelContext() throws Exception {
         logger.info("Initialize Camel Context...");
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
index c28c0c3..4b6c246 100644
--- 
a/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
+++ 
b/extensions/router/router-core/src/main/java/org/apache/unomi/router/core/processor/LineSplitProcessor.java
@@ -113,6 +113,13 @@ public class LineSplitProcessor implements Processor {
 
                 if (profileData.length > fieldsMapping.get(fieldMappingKey)) {
                     try {
+                        if (propertyType == null) {
+                            logger.error("No valid property type found for 
propertyTypeId=" + fieldMappingKey);
+                        } else {
+                            if (propertyType.getValueTypeId() == null) {
+                                logger.error("No value type id found for 
property type " + propertyType.getItemId());
+                            }
+                        }
                         if (propertyType.getValueTypeId().equals("string") || 
propertyType.getValueTypeId().equals("email") ||
                                 propertyType.getValueTypeId().equals("date")) {
                             if 
(BooleanUtils.isTrue(propertyType.isMultivalued())) {
@@ -139,8 +146,8 @@ public class LineSplitProcessor implements Processor {
                         } else if 
(propertyType.getValueTypeId().equals("integer")) {
                             properties.put(fieldMappingKey, new 
Integer(profileData[fieldsMapping.get(fieldMappingKey)].trim()));
                         }
-                    } catch (Exception e) {
-                        logger.error("Error converting profileData", e);
+                    } catch (Throwable t) {
+                        logger.error("Error converting profileData", t);
                         if (fieldMappingKey != null && 
fieldsMapping.get(fieldMappingKey) != null && profileData != null && 
profileData[fieldsMapping.get(fieldMappingKey)] != null) {
                             throw new BadProfileDataFormatException("Unable to 
convert '" + profileData[fieldsMapping.get(fieldMappingKey)].trim() + "' to " + 
propertyType!=null?propertyType.getValueTypeId():"Null propertyType ", new 
Throwable("DATA_TYPE"));
                         } else {

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
index 68011eb..e7c5d67 100644
--- 
a/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
+++ 
b/extensions/router/router-service/src/main/java/org/apache/unomi/router/services/AbstractConfigurationServiceImpl.java
@@ -48,6 +48,10 @@ public abstract class AbstractConfigurationServiceImpl 
implements SynchronousBun
         this.routerCamelContext = routerCamelContext;
     }
 
+    public IRouterCamelContext getRouterCamelContext() {
+        return routerCamelContext;
+    }
+
     public void postConstruct() {
         logger.debug("postConstruct {" + bundleContext.getBundle() + "}");
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
index 7641348..a2f0f39 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportRankingIT.java
@@ -56,6 +56,8 @@ public class ProfileImportRankingIT extends BaseIT {
     @Test
     public void testImportRanking() throws InterruptedException {
 
+        importConfigurationService.getRouterCamelContext().setTracing(true);
+
         /*** Create Missing Properties ***/
         PropertyType propertyTypeUciId = new PropertyType(new 
Metadata("integration", "uciId", "UCI ID", "UCI ID"));
         propertyTypeUciId.setValueTypeId("string");

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
----------------------------------------------------------------------
diff --git 
a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java 
b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
index d1ee1ad..082ffaf 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ProfileImportSurfersIT.java
@@ -23,6 +23,7 @@ import org.apache.unomi.api.PropertyType;
 import org.apache.unomi.api.services.ProfileService;
 import org.apache.unomi.router.api.ImportConfiguration;
 import org.apache.unomi.router.api.RouterConstants;
+import org.apache.unomi.router.api.RouterUtils;
 import org.apache.unomi.router.api.services.ImportExportConfigurationService;
 import org.junit.Assert;
 import org.junit.Test;
@@ -70,7 +71,11 @@ public class ProfileImportSurfersIT extends BaseIT {
 
         PropertyType propAlive = profileService.getPropertyType("alive");
 
-        Assert.assertNotNull(propAlive);
+        Assert.assertNotNull("Alive property should not be null", propAlive);
+
+        propAlive = 
RouterUtils.getPropertyTypeById(profileService.getTargetPropertyTypes("profiles"),
 "alive");
+
+        Assert.assertNotNull("Lookup of alive property through profiles target 
has failed !", propAlive);
 
         /*** Surfers Test ***/
         ImportConfiguration importConfigSurfers = new ImportConfiguration();

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/af7bfb11/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
 
b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
index bdce139..02f6f0c 100644
--- 
a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
+++ 
b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
@@ -260,8 +260,8 @@ public class ProfileServiceImpl implements ProfileService, 
SynchronousBundleList
                 loadPropertyTypesFromPersistence();
             }
         };
-        allPropertyTypesTimer.scheduleAtFixedRate(task, 5000, 5000);
-        logger.info("Scheduled task for property type loading each 5s");
+        allPropertyTypesTimer.scheduleAtFixedRate(task, 10000, 10000);
+        logger.info("Scheduled task for property type loading each 10s");
     }
 
     private void loadPropertyTypesFromPersistence() {

Reply via email to