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/06/02 21:13:56 UTC
incubator-usergrid git commit: Reworked the counters test to only use
the rest tier, not worry about the service AND core tier.
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-dev 81b2c0406 -> 6be835ca8
Reworked the counters test to only use the rest tier, not worry about the service AND core tier.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6be835ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6be835ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6be835ca
Branch: refs/heads/two-dot-o-dev
Commit: 6be835ca8bc4aedf5bd9a82c9c468f7a8f7e99d4
Parents: 81b2c04
Author: GERey <gr...@apigee.com>
Authored: Tue Jun 2 12:13:51 2015 -0700
Committer: GERey <gr...@apigee.com>
Committed: Tue Jun 2 12:13:51 2015 -0700
----------------------------------------------------------------------
.../events/ApplicationRequestCounterIT.java | 64 ++++----------------
1 file changed, 12 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6be835ca/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/ApplicationRequestCounterIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/ApplicationRequestCounterIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/ApplicationRequestCounterIT.java
index 655d2e6..0de8eb7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/ApplicationRequestCounterIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/ApplicationRequestCounterIT.java
@@ -17,25 +17,15 @@
package org.apache.usergrid.rest.applications.events;
-import java.util.UUID;
-
-import javax.ws.rs.core.MediaType;
-
-import com.fasterxml.jackson.databind.JsonNode;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.EntityManager;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.Query;
-import org.apache.usergrid.persistence.Results;
-import org.apache.usergrid.persistence.index.query.CounterResolution;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.services.ServiceManager;
-import org.apache.usergrid.utils.UUIDUtils;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -49,49 +39,19 @@ public class ApplicationRequestCounterIT extends AbstractRestIT {
private static final Logger log = LoggerFactory.getLogger( ApplicationRequestCounterIT.class );
long ts = System.currentTimeMillis() - ( 24 * 60 * 60 * 1000 );
-
@Test
public void applicationrequestInternalCounters() throws Exception {
- // Get application id
- JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-
- assertNotNull( node.get( "entities" ) );
-
- String uuid = node.get( "application" ).asText();
- assertEquals( true, UUIDUtils.isUUID( uuid ) );
-
- refreshIndex("test-organization", "test-app");
- UUID applicationId = UUID.fromString( uuid );
- EntityManagerFactory emf = setup.getEmf();
- EntityManager em = emf.getEntityManager( applicationId );
+ //get default application
+ ApiResponse defaultApp = org().app( clientSetup.getAppName() ).get();
- int beforeTotalCall = getCounter( em, ServiceManager.APPLICATION_REQUESTS );
- int beforeCall = getCounter( em, ServiceManager.APPLICATION_REQUESTS_PER.concat( "get" ) );
-
- // call
- node = mapper.readTree( resource().path( "/test-organization/test-app/counters" ).queryParam( "resolution", "all" )
- .queryParam( "counter", "application.requests" ).queryParam( "access_token", adminToken() )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-
- assertNotNull( node.get( "counters" ) );
-
- int afterTotalCall = getCounter( em, ServiceManager.APPLICATION_REQUESTS );
- int afterCall = getCounter( em, ServiceManager.APPLICATION_REQUESTS_PER.concat( "get" ) );
-
- assertEquals( 1, afterCall - beforeCall );
- assertEquals( 1, afterTotalCall - beforeTotalCall );
- }
+ QueryParameters queryParameters = new QueryParameters();
+ queryParameters.addParam( "resolution", "all" ).addParam( "counter","application.requests" );
+ Collection countersResponse = org().app( clientSetup.getAppName() ).collection( "counters" ).get( queryParameters ,true );
+ assertNotNull( countersResponse );
+// ArrayList counterValues = ( ArrayList ) countersResponse.getResponse().getProperties().get( "counters" );
+// assertEquals( 1, counterValues.indexOf( 1 ));
- private int getCounter( EntityManager em, String key ) throws Exception {
- Query query = new Query();
- query.addCounterFilter( key + ":*:*:*" );
- query.setStartTime( ts );
- query.setFinishTime( System.currentTimeMillis() );
- query.setResolution( CounterResolution.ALL );
- Results r = em.getAggregateCounters( query );
- return ( int ) r.getCounters().get( 0 ).getValues().get( 0 ).getValue();
}
}