usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [2/2] incubator-usergrid git commit: Fixes aggregation check in test
Date Wed, 12 Aug 2015 20:41:11 GMT
Fixes aggregation check in test


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

Branch: refs/heads/two-dot-o
Commit: 542a48bb7f3b52e03650ba50d08267c4b804d41e
Parents: 9bebb06
Author: Todd Nine <tnine@apigee.com>
Authored: Wed Aug 12 11:15:38 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Wed Aug 12 11:43:09 2015 -0600

----------------------------------------------------------------------
 .../src/test/resources/usergrid-test.properties |  1 +
 .../apache/usergrid/persistence/CounterIT.java  | 29 ++++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/542a48bb/stack/config/src/test/resources/usergrid-test.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/test/resources/usergrid-test.properties b/stack/config/src/test/resources/usergrid-test.properties
index 3f680f4..e7c36e7 100644
--- a/stack/config/src/test/resources/usergrid-test.properties
+++ b/stack/config/src/test/resources/usergrid-test.properties
@@ -77,6 +77,7 @@ usergrid.version.properties=1.0.0
 # build number for display
 usergrid.version.build=0.1
 
+usergrid.counter.batch.interval=10
 #usergrid.auth.token_secret_salt=super secret token value
 #usergrid.auth.token_expires_from_last_use=false
 #usergrid.auth.token_refresh_reuses_id=false

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/542a48bb/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
index 2c72d26..a84e883 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CounterIT.java
@@ -87,6 +87,7 @@ public class CounterIT extends AbstractCoreIT {
         userProperties.put( "username", "test-username" );
         userProperties.put( "email", "test-email" );
         User user = ( User ) em.create( uuid, "user", userProperties ).toTypedEntity();
+
         LOG.debug( "user={}", user );
 
 
@@ -94,6 +95,7 @@ public class CounterIT extends AbstractCoreIT {
         assertEquals( new Long( 1 ), counters.get( "application.collection.users" ) );
 
         em.delete( user );
+
         counters = em.getEntityCounters( applicationId );
         assertEquals( new Long( 0 ), counters.get( "application.collection.users" ) );
     }
@@ -301,16 +303,33 @@ public class CounterIT extends AbstractCoreIT {
         //sleep to ensure the flush has executed
         Thread.sleep( 30000 );
 
-        Results r = em.getAggregateCounters( null, null, null, "visits", CounterResolution.SIX_HOUR,
ts, System.currentTimeMillis(), false );
+
+        final long totalCount = returnCounts( em, "visits" );
+
+        assertEquals(200, totalCount);
+    }
+
+
+    private long returnCounts( final EntityManager em, final String counterName ) {
+        Results r = em.getAggregateCounters( null, null, null, counterName, CounterResolution.SIX_HOUR,
ts,
+            System.currentTimeMillis(), false );
+
+
+
 
         final AggregateCounterSet counter = r.getCounters().get( 0 );
 
-        final long count = counter.getValues().get( 0 ).getValue();
+        assertEquals(counterName, counter.getName());
+
+        long count = 0;
+
+        for(final AggregateCounter value: counter.getValues()){
+            count += value.getValue();
+        }
+
+        return count;
 
-        final String name = counter.getName();
 
-        assertEquals("visits", name);
-        assertEquals(count, 200);
 
     }
 }


Mime
View raw message