usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [18/52] [abbrv] git commit: More test fixes related to merge from master and previous serialization fix.
Date Wed, 03 Sep 2014 22:11:13 GMT
More test fixes related to merge from master and previous serialization fix.


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

Branch: refs/heads/two-dot-o-push-notifications
Commit: 9ddb53730170977cbf5f3082dedd1fe77197f6e9
Parents: ce8c170
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Thu Aug 28 15:37:38 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Thu Aug 28 15:37:38 2014 -0400

----------------------------------------------------------------------
 .../usergrid/batch/job/SchedulerRuntime2IT.java | 54 ++++++++++----------
 .../usergrid/batch/job/SchedulerRuntime3IT.java |  2 +
 .../usergrid/persistence/CollectionIT.java      | 17 +++---
 .../persistence/GeoQueryBooleanTest.java        |  2 +
 .../exception/CollectionRuntimeException.java   |  1 -
 .../MvccEntitySerializationStrategyImpl.java    | 16 +++++-
 .../persistence/index/impl/EntityIndexTest.java | 19 +++++++
 .../src/test/resources/log4j.properties         |  6 ++-
 .../test/resources/usergrid-test-context.xml    |  3 +-
 9 files changed, 81 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime2IT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime2IT.java
b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime2IT.java
index fdc3c07..fb66427 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime2IT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime2IT.java
@@ -17,16 +17,17 @@
 package org.apache.usergrid.batch.job;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.util.concurrent.TimeUnit;
+import static org.apache.usergrid.batch.job.AbstractSchedulerRuntimeIT.cassandraResource;
 
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.cassandra.Concurrent;
 import org.apache.usergrid.persistence.entities.JobData;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 
 /**
@@ -35,7 +36,6 @@ import org.apache.usergrid.persistence.entities.JobData;
 @Concurrent
 public class SchedulerRuntime2IT extends AbstractSchedulerRuntimeIT {
 	private static final Logger logger = LoggerFactory.getLogger(SchedulerRuntime2IT.class.getName());
-
     /** Test the scheduler ramps up correctly when there are more jobs to be read after a
pause */
     @Test
     public void schedulingWithNoJobs() throws InterruptedException {
@@ -50,34 +50,31 @@ public class SchedulerRuntime2IT extends AbstractSchedulerRuntimeIT {
         }
 
         scheduler.refreshIndex();
-
-        // previously:
-        // now wait until everything fires
-        // boolean waited = getJobListener().blockTilDone( getCount(), 15000L );
-        // assertTrue( "Jobs ran", waited );
-        // assertTrue( getCount() + " successful jobs ran", 
-        // getCount() == getJobListener().getSuccessCount() );
         
         // now:
         // note that the waitForCount only wait for job execution. It does NOT wait for job
Completion
         boolean waited = counterJob.waitForCount(waitTime, TimeUnit.MILLISECONDS);
-        assertTrue( "Failed to run " 
-                + getCount() + " number of jobs. Waited " + waitTime + " ms.", waited );
+        assertTrue( "Failed to run " + getCount() 
+                + " number of jobs. Waited " + waitTime 
+                + " seconds.", waited );
         
         scheduler.refreshIndex();
-
+        
         // now:
         // blockTilDone look into the JobListener hook and blocked until jobs are completed.
         // TODO : need a retry count so it doesn't reblock forever
         while (!getJobListener().blockTilDone(waitTime)) {
         	logger.warn("Jobs not yet finished after waited {}, block again" , waitTime);
         }
-        assertEquals( "Expected success job: " + getCount()+ ". Actual :" 
-            + getJobListener().getSuccessCount() + ". Total count: " 
-            + getJobListener().getDoneCount() , getCount() , getJobListener().getSuccessCount()
);
+        assertEquals( "Expected success job: " + getCount()
+                + ". Actual :" + getJobListener().getSuccessCount() 
+                + ". Total count: " + getJobListener().getDoneCount() , 
+                getCount() , getJobListener().getSuccessCount() );
         
         Thread.sleep( 5000L );
 
+        scheduler.refreshIndex();
+        
         // set the counter job latch size
         counterJob.setLatch( getCount() );
         getJobListener().setExpected( getCount() );
@@ -87,32 +84,35 @@ public class SchedulerRuntime2IT extends AbstractSchedulerRuntimeIT {
         }
 
         scheduler.refreshIndex();
-
+        
         // previously: 
         // now wait until everything fires
         // waited = getJobListener().blockTilDone( 2 * getCount(), 15000L );
         // waited = counterJob.waitForCount(waitTime, TimeUnit.MILLISECONDS );
-        // assertTrue( "Failed to run " + 2* getCount() + " number of jobs. Success count
= " 
-        // + getJobListener().getSuccessCount() + ". Waited " + waitTime  + " seconds.",
waited );
+        // assertTrue( "Failed to run " + 2* getCount() + " number of jobs. 
+        // Success count = " + getJobListener().getSuccessCount() + ". Waited " + waitTime
 + " seconds.", waited );
         // assertTrue( 2 * getCount() + " successful jobs ran",
         //  ( 2 * getCount() ) == getJobListener().getSuccessCount() );
 		
-		// now: note that the waitForCount only wait for job execution. 
-        // It does NOT wait for job Completion
+		// now:
+        // note that the waitForCount only wait for job execution. It does NOT wait for job
Completion
         waited = counterJob.waitForCount(waitTime, TimeUnit.MILLISECONDS);
-        assertTrue( "Failed to run " + getCount() + " number of jobs. Waited " + waitTime

-                + " seconds.", waited );
+        assertTrue( "Failed to run " + getCount() + " number of jobs. Waited " + waitTime
+ " seconds.", waited );
         
         scheduler.refreshIndex();
-
+        
         // now:
         // blockTilDone look into the JobListener hook and blocked until jobs are completed.
         // TODO : need a retry count so it doesn't reblock forever
         while (!getJobListener().blockTilDone(waitTime)) {
         	logger.warn("Jobs not yet finished after waited {}, block again" , waitTime);
         }
-        assertEquals( "Expected success job: " +2 * getCount()+ ". Actual :" 
-            + getJobListener().getSuccessCount() + ". Total count: " 
-            + getJobListener().getDoneCount(), 2 * getCount() , getJobListener().getSuccessCount());
+
+        scheduler.refreshIndex();
+        
+        assertEquals( "Expected success job: " +2 * getCount()
+                + ". Actual :" + getJobListener().getSuccessCount() 
+                + ". Total count: " + getJobListener().getDoneCount() , 
+                2 * getCount() , getJobListener().getSuccessCount() );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime3IT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime3IT.java
b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime3IT.java
index d9a48c6..2968eda 100644
--- a/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime3IT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/batch/job/SchedulerRuntime3IT.java
@@ -73,6 +73,8 @@ public class SchedulerRuntime3IT extends AbstractSchedulerRuntimeIT {
         // make sure we're not racing the test
         boolean waited = getJobListener().blockTilDone(waitTime);
 
+        scheduler.refreshIndex();
+
         //we shouldn't trip the latch.  It should fail failCount times, and not run again
         assertTrue( "Jobs ran", waited );
         assertTrue( failCount + " failures resulted", getJobListener().getFailureCount()
== failCount );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index 8ff14de..57b4940 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -850,24 +850,27 @@ public class CollectionIT extends AbstractCoreIT {
         EntityManager em = setup.getEmf().getEntityManager( applicationId );
         assertNotNull( em );
 
+        // create two game entities, each with an array of entities that have subField =
'Foo'
 
-        Map<String, Object> subObject = new LinkedHashMap<String, Object>();
-        subObject.put( "subField", "Foo" );
-
-        Map<String, Object> properties = new LinkedHashMap<String, Object>();
-        properties.put( "subObjectArray", new Map[] { subObject } );
+        Map<String, Object> properties = new LinkedHashMap<String, Object>()
{{
+            put( "subObjectArray", new ArrayList<Map<String, Object>>() {{
+                add( new LinkedHashMap<String, Object>() {{
+                    put("subField", "Foo");
+                }});
+            }});
+        }};
 
         Entity entity1 = em.create( "game", properties );
         assertNotNull( entity1 );
 
-
         Entity entity2 = em.create( "game", properties );
         assertNotNull( entity2 );
 
         em.refreshIndex();
 
 
-        // simple not
+        // search for games without sub-field Foo should returned zero entities
+
         Query query = Query.fromQL( "select * where NOT subObjectArray.subField = 'Foo'"
).withLimit( 1 );
         Results r = em.searchCollection( em.getApplicationRef(), "games", query );
         assertEquals( 0, r.size() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 738a1c6..8ba860a 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -33,6 +33,7 @@ import org.apache.usergrid.persistence.index.query.Query;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import org.junit.Ignore;
 
 
 @Concurrent()
@@ -111,6 +112,7 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
 
 
     @Test
+    @Ignore // work in progress
     public void testGeoQueryWithNot() throws Exception {
 
         log.info( "GeoQueryBooleanTest.testGeoQueryWithOr" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/CollectionRuntimeException.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/CollectionRuntimeException.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/CollectionRuntimeException.java
index 168aaec..82e1c76 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/CollectionRuntimeException.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/exception/CollectionRuntimeException.java
@@ -19,7 +19,6 @@ package org.apache.usergrid.persistence.collection.exception;
 
 import org.apache.usergrid.persistence.collection.CollectionScope;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.model.entity.Entity;
 
 
 public class CollectionRuntimeException extends RuntimeException {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index 4f8d1f3..a9e087b 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -45,6 +45,7 @@ import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.dataformat.smile.SmileFactory;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
@@ -64,6 +65,8 @@ import com.netflix.astyanax.serializers.AbstractSerializer;
 import com.netflix.astyanax.serializers.ByteBufferSerializer;
 import com.netflix.astyanax.serializers.BytesArraySerializer;
 import com.netflix.astyanax.serializers.UUIDSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @author tnine
@@ -71,6 +74,7 @@ import com.netflix.astyanax.serializers.UUIDSerializer;
 @Singleton
 public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializationStrategy,
Migration {
 
+    private static final Logger log =  LoggerFactory.getLogger( MvccLogEntrySerializationStrategyImpl.class
);
 
     private static final EntitySerializer SER = new EntitySerializer();
 
@@ -305,7 +309,7 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
 
         public static final SmileFactory f = new SmileFactory(  );
 
-        public static ObjectMapper mapper = new ObjectMapper( f );
+        public static ObjectMapper mapper;
 
         private static byte[] STATE_COMPLETE = new byte[] { 0 };
         private static byte[] STATE_DELETED = new byte[] { 1 };
@@ -317,6 +321,16 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
         //the marker for when we're passed a "null" value
         private static final byte[] EMPTY = new byte[] { 0x0 };
 
+        public EntitySerializer() {
+            try {
+                mapper = new ObjectMapper( f );
+                mapper.enable(SerializationFeature.INDENT_OUTPUT);
+                mapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT,
"@class"); 
+            } catch ( Exception e ) {
+                throw new RuntimeException("Error setting up mapper", e);
+            }
+        }
+
         @Override
         public ByteBuffer toByteBuffer( final EntityWrapper wrapper ) {
             if ( wrapper == null ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 3b40978..2f0def1 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -178,6 +178,7 @@ public class EntityIndexTest extends BaseIT {
 
     private void testQueries( EntityIndex entityIndex ) {
 
+
         testQuery( entityIndex, "name = 'Morgan Pierce'", 1 );
 
         testQuery( entityIndex, "name = 'morgan pierce'", 1 );
@@ -203,6 +204,24 @@ public class EntityIndexTest extends BaseIT {
         testQuery( entityIndex, "name = 'Morgan* '", 1 );
         
         testQuery( entityIndex, "name = 'Morgan*'", 1 );
+
+        
+        // test a couple of array sub-property queries
+
+        int totalUsers = 102;
+
+        // nobody has a friend named Jack the Ripper
+        testQuery( entityIndex, "friends.name = 'Jack the Ripper'", 0 );
+
+        // everybody doesn't have a friend named Jack the Ripper
+        testQuery( entityIndex, "not (friends.name = 'Jack the Ripper')", totalUsers );
+
+        // one person has a friend named Shari Hahn
+        testQuery( entityIndex, "friends.name = 'Wendy Moody'", 1 );
+
+        // everybody but 1 doesn't have a friend named Shari Hahh
+        testQuery( entityIndex, "not (friends.name = 'Shari Hahn')", totalUsers - 1);
+
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/corepersistence/queryindex/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/resources/log4j.properties b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
index 2ff29c6..e84489c 100644
--- a/stack/corepersistence/queryindex/src/test/resources/log4j.properties
+++ b/stack/corepersistence/queryindex/src/test/resources/log4j.properties
@@ -28,8 +28,10 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) %c{1} - %m%n
 
 log4j.logger.org.apache.usergrid=INFO
 
-#log4j.logger.org.apache.usergrid.persistence.CollectionIT=DEBUG
-#log4j.logger.org.apache.usergrid.persistence.collection=WARN
 #log4j.logger.org.apache.usergrid.persistence.index=DEBUG
+log4j.logger.org.apache.usergrid.persistence.index.impl=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index.query=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index.query.tree=DEBUG
+#log4j.logger.org.apache.usergrid.persistence.index.utils=DEBUG
 
 #log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG, stdout
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ddb5373/stack/query-validator/src/test/resources/usergrid-test-context.xml
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/resources/usergrid-test-context.xml b/stack/query-validator/src/test/resources/usergrid-test-context.xml
index a4f78eb..03bb2e5 100644
--- a/stack/query-validator/src/test/resources/usergrid-test-context.xml
+++ b/stack/query-validator/src/test/resources/usergrid-test-context.xml
@@ -46,7 +46,8 @@
 
     <bean id="binaryStore" class="org.apache.usergrid.services.assets.data.LocalFileBinaryStore"/>
 
-    <bean id="setup" class="org.apache.usergrid.persistence.cassandra.Setup">
+    <bean id="setup" class="org.apache.usergrid.corepersistence.HybridSetup">
+        <constructor-arg ref="properties"/>
         <constructor-arg ref="entityManagerFactory"/>
         <constructor-arg ref="cassandraService"/>
     </bean>


Mime
View raw message