You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/08/12 22:41:11 UTC

[2/2] incubator-usergrid git commit: Fixes aggregation check in test

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 <tn...@apigee.com>
Authored: Wed Aug 12 11:15:38 2015 -0600
Committer: Todd Nine <tn...@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);
 
     }
 }