usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [10/13] git commit: Improve IndexRebuild test to test connections.
Date Thu, 02 Oct 2014 05:44:20 GMT
Improve IndexRebuild test to test connections.


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

Branch: refs/heads/esbatching
Commit: 9a670e3d28781acc8554030229b928b8e6b47f2c
Parents: a644034
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Wed Oct 1 20:55:36 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Wed Oct 1 20:55:36 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  7 ++-
 .../corepersistence/CpRelationManager.java      |  4 +-
 .../PerformanceEntityRebuildIndexTest.java      | 63 ++++++++++++++++----
 3 files changed, 58 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a670e3d/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index b3d5135..accf2f8 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -326,7 +326,12 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
             return null; 
         } 
 
-        return results.iterator().next().getUuid();
+        Entity entity = results.iterator().next();
+        Object uuidObject = entity.getProperty("applicationUuid"); 
+        if ( uuidObject instanceof UUID ) {
+            return (UUID)uuidObject;
+        }
+        return UUIDUtils.tryExtractUUID( entity.getProperty("applicationUuid").toString()
);
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a670e3d/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index be21e85..fba758f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -642,7 +642,7 @@ public class CpRelationManager implements RelationManager {
         GraphManager gm = managerCache.getGraphManager(applicationScope);
         gm.writeEdge(edge).toBlockingObservable().last();
 
-        logger.debug("\n\nWrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}\n\n",
new Object[] { 
+        logger.debug("Wrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}", new
Object[] { 
             edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
             memberEntity.getId().getType(), memberEntity.getId().getUuid(),
             applicationScope.getApplication().getType(), applicationScope.getApplication().getUuid()});
 
@@ -998,7 +998,7 @@ public class CpRelationManager implements RelationManager {
         GraphManager gm = managerCache.getGraphManager(applicationScope);
         gm.writeEdge(edge).toBlockingObservable().last();
 
-        logger.debug("\n\nWrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}\n\n",
new Object[] { 
+        logger.debug("Wrote edgeType {}\n   from {}:{}\n   to {}:{}\n   scope {}:{}", new
Object[] { 
             edgeType, cpHeadEntity.getId().getType(), cpHeadEntity.getId().getUuid(),
             targetEntity.getId().getType(), targetEntity.getId().getUuid(),
             applicationScope.getApplication().getType(), applicationScope.getApplication().getUuid()});


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9a670e3d/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 0f033a2..acfb1e0 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -65,7 +65,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
     private static final long RUNTIME = TimeUnit.MINUTES.toMillis( 1 );
 
-    private static final long writeDelayMs = 15;
+    private static final long writeDelayMs = 100;
     //private static final long readDelayMs = 7;
 
     @Rule
@@ -103,29 +103,58 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT
{
         // ----------------- create a bunch of entities
 
         final long stopTime = System.currentTimeMillis() + RUNTIME;
-        final Map<String, Object> entityMap = new HashMap<>();
 
-        entityMap.put( "key1", 1000 );
-        entityMap.put( "key2", 2000 );
-        entityMap.put( "key3", "Some value" );
+        Map<String, Object> entityMap = new HashMap<String, Object>() {{
+            put("key1", 1000 );
+            put("key2", 2000 );
+            put("key3", "Some value");
+        }};
+        Map<String, Object> cat1map = new HashMap<String, Object>() {{
+            put("name", "enzo");
+            put("color", "orange");
+        }};
+        Map<String, Object> cat2map = new HashMap<String, Object>() {{
+            put("name", "marquee");
+            put("color", "grey");
+        }};
+        Map<String, Object> cat3map = new HashMap<String, Object>() {{
+            put("name", "bertha");
+            put("color", "tabby");
+        }};
+
+        Entity cat1 = em.create("cat", cat1map );
+        Entity cat2 = em.create("cat", cat2map );
+        Entity cat3 = em.create("cat", cat3map );
 
         List<EntityRef> entityRefs = new ArrayList<EntityRef>();
         int entityCount = 0;
         while ( System.currentTimeMillis() < stopTime ) {
-            entityMap.put("key", entityCount );
-            final Entity created;
+
+            final Entity entity;
+
             try {
-                created = em.create("testType", entityMap );
+                entityMap.put("key", entityCount );
+                entity = em.create("testType", entityMap );
+
+                em.refreshIndex();
+
+                em.createConnection(entity, "herds", cat1);
+                em.createConnection(entity, "herds", cat2);
+                em.createConnection(entity, "herds", cat3);
+
             } catch (Exception ex) {
                 throw new RuntimeException("Error creating entity", ex);
             }
-            entityRefs.add( new SimpleEntityRef( created.getType(), created.getUuid() ) );
+
+            entityRefs.add(new SimpleEntityRef( entity.getType(), entity.getUuid() ) );
             if ( entityCount % 100 == 0 ) {
                 logger.info("Created {} entities", entityCount );
             }
+
             entityCount++;
             try { Thread.sleep( writeDelayMs ); } catch (InterruptedException ignored ) {}
         }
+
         logger.info("Created {} entities", entityCount);
         em.refreshIndex();
 
@@ -218,23 +247,31 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT
{
         while ( true ) {
 
             for ( Entity e : results.getEntities() ) {
+
                 assertEquals( 2000, e.getProperty("key2"));
-                //if ( count % 100 == 0 ) {
-                    logger.info( "read {} entities", count++);
-                //}
+
+                Results catResults = em.searchConnectedEntities(e, Query.fromQL("select *"));
+                assertEquals( 3, catResults.size() );
+
+                if ( count % 100 == 0 ) {
+                    logger.info( "read {} entities", count);
+                }
+                count++;
             }
 
             if ( results.hasCursor() ) {
                 logger.info( "Counted {} : query again with cursor", count);
                 q.setCursor( results.getCursor() );
                 results = em.searchCollection( em.getApplicationRef(), collectionName, q
);
+
             } else {
                 break;
             }
         }
 
         if ( expected != -1 && expected != count ) {
-            throw new RuntimeException("Did not get expected " + expected + " entities");
+            throw new RuntimeException("Did not get expected " 
+                    + expected + " entities, instead got " + count );
         }
         return count;
     }


Mime
View raw message