You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/08/08 21:05:12 UTC

[06/15] More progress on getting REST tests working in two-dot-o branch, current status is Tests run: 205, Failures: 12, Errors: 18, Skipped: 11.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index fd0adae..9632183 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -101,7 +101,7 @@ public abstract class AbstractRestIT extends JerseyTest {
 
         setupUsers();
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         LOG.info( "acquiring token" );
         access_token = userToken( "ed@anuff.com", "sesame" );
@@ -109,20 +109,26 @@ public abstract class AbstractRestIT extends JerseyTest {
 
         loginClient();
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
     }
 
 
-    public void reindex( UUID appId ) {
-        resource().path( "/testreindex" )
+    public void refreshIndex( UUID appId ) {
+
+        LOG.debug("Refreshing index for appId {}", appId );
+
+        resource().path( "/refreshindex" )
             .queryParam( "app_id", appId.toString() )
             .accept( MediaType.APPLICATION_JSON )
             .post();
     }
 
 
-    public void reindex( String orgName, String appName ) {
-        resource().path( "/testreindex" )
+    public void refreshIndex( String orgName, String appName ) {
+
+        LOG.debug("Refreshing index for app {}/{}", orgName, appName );
+
+        resource().path( "/refreshindex" )
             .queryParam( "org_name", orgName )
             .queryParam( "app_name", appName )
             .accept( MediaType.APPLICATION_JSON )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/RestITSuite.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/RestITSuite.java b/stack/rest/src/test/java/org/apache/usergrid/rest/RestITSuite.java
index 2885543..3b26568 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/RestITSuite.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/RestITSuite.java
@@ -16,7 +16,6 @@
  */
 package org.apache.usergrid.rest;
 
-
 import org.junit.ClassRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
@@ -39,15 +38,14 @@ import org.apache.usergrid.rest.management.organizations.OrganizationResourceIT;
 import org.apache.usergrid.rest.management.organizations.OrganizationsResourceIT;
 import org.apache.usergrid.rest.management.users.organizations.UsersOrganizationsResourceIT;
 
-
 @RunWith(Suite.class)
 @Suite.SuiteClasses(
         {
-                ActivityResourceIT.class, AdminEmailEncodingIT.class, ApplicationRequestCounterIT.class,
-                AssetResourceIT.class, BasicIT.class, CollectionsResourceIT.class, ContentTypeResourceIT.class,
-                DevicesResourceIT.class, EventsResourceIT.class, GroupResourceIT.class, OrganizationResourceIT.class,
-                OrganizationsResourceIT.class, OwnershipResourceIT.class, PagingResourceIT.class,
-                PermissionsResourceIT.class, UserResourceIT.class, UsersOrganizationsResourceIT.class
+            ActivityResourceIT.class, AdminEmailEncodingIT.class, ApplicationRequestCounterIT.class,
+            AssetResourceIT.class, BasicIT.class, CollectionsResourceIT.class, ContentTypeResourceIT.class,
+            DevicesResourceIT.class, EventsResourceIT.class, GroupResourceIT.class, OrganizationResourceIT.class,
+            OrganizationsResourceIT.class, OwnershipResourceIT.class, PagingResourceIT.class,
+            PermissionsResourceIT.class, UserResourceIT.class, UsersOrganizationsResourceIT.class
         })
 @Concurrent()
 public class RestITSuite {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationRequestCounterIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationRequestCounterIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationRequestCounterIT.java
index 097085e..007741a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationRequestCounterIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationRequestCounterIT.java
@@ -61,6 +61,8 @@ public class ApplicationRequestCounterIT extends AbstractRestIT {
         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 );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index 4f8671a..1bfa288 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -59,6 +59,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String clientId = setup.getMgmtSvc().getClientIdForOrganization( orgInfo.getUuid() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForOrganization( orgInfo.getUuid() );
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -74,6 +76,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( appInfo.getId() );
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -92,6 +96,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String clientId = setup.getMgmtSvc().getClientIdForApplication( app.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( app.getId() );
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource()
                 .path( "/test-organization/test-app" )
                 .queryParam( "client_id", clientId )
@@ -112,6 +118,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String clientId = setup.getMgmtSvc().getClientIdForApplication( app.getId() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForApplication( app.getId() );
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource()
                 .path( "/test-organization/test-app" )
                 .queryParam( "client_id", clientId )
@@ -140,6 +148,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
 
         assertNotNull( getEntity( node, 0 ) );
 
+        refreshIndex("test-organization", "test-app");
+
         payload = hashMap( "username", "applicationWithJsonCreds" ).map( "password", "applicationWithJsonCreds" )
                 .map( "grant_type", "password" );
 
@@ -164,6 +174,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         String clientId = setup.getMgmtSvc().getClientIdForOrganization( orgInfo.getUuid() );
         String clientSecret = setup.getMgmtSvc().getClientSecretForOrganization( orgInfo.getUuid() );
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource().path( "/" + appInfo.getId() ).queryParam( "client_id", clientId )
                 .queryParam( "client_secret", clientSecret ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -184,6 +196,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
     public void test_GET_credentials_ok() throws IOException {
         String mgmtToken = adminToken();
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/credentials" ).queryParam( "access_token", mgmtToken )
                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                         .get( String.class ));
@@ -196,6 +210,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
     public void testResetAppCredentials() throws IOException {
         String mgmtToken = adminToken();
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/credentials" ).queryParam( "access_token", mgmtToken )
                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                         .post( String.class ));
@@ -211,6 +227,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         Status status = null;
         JsonNode node = null;
 
+        refreshIndex("test-organization", "test-app");
+
         try {
             node = mapper.readTree( resource().path( "/test-organization/test-app" ).queryParam( "access_token", mgmtToken )
                     .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
@@ -338,6 +356,8 @@ public class ApplicationResourceIT extends AbstractRestIT {
         ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
         String clientId = setup.getMgmtSvc().getClientIdForApplication( appInfo.getId() );
 
+        refreshIndex("test-organization", "test-app");
+
         Form payload = new Form();
         payload.add( "username", "wrong_user" );
         payload.add( "password", "wrong_password" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
index c72aee1..33667c7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/DevicesResourceIT.java
@@ -46,6 +46,8 @@ public class DevicesResourceIT extends AbstractRestIT {
 
         String path = "devices/" + uuid;
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode response = mapper.readTree( appPath( path ).put( String.class, payload ));
 
         // create
@@ -58,6 +60,8 @@ public class DevicesResourceIT extends AbstractRestIT {
         response = mapper.readTree( appPath( path ).delete( String.class ));
         assertNotNull( getEntity( response, 0 ) );
 
+        refreshIndex("test-organization", "test-app");
+
         // check deleted
         try {
             response = mapper.readTree( appPath( path ).get( String.class ));
@@ -72,6 +76,8 @@ public class DevicesResourceIT extends AbstractRestIT {
         entity = getEntity( response, 0 );
         assertNotNull( entity );
 
+        refreshIndex("test-organization", "test-app");
+
         // check existence
         response = mapper.readTree( appPath( path ).get( String.class ));
         assertNotNull( getEntity( response, 0 ) );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
index 688af26..6f51122 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/assets/AssetResourceIT.java
@@ -78,6 +78,8 @@ public class AssetResourceIT extends AbstractRestIT {
         byte[] foundData = IOUtils.toByteArray( is );
         assertEquals( 7979, foundData.length );
 
+        refreshIndex("test-organization", "test-app");
+
         node = mapper.readTree( resource().path( "/test-organization/test-app/assets/my/clean/path" )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON_TYPE )
                 .get( String.class ));
@@ -123,6 +125,8 @@ public class AssetResourceIT extends AbstractRestIT {
         byte[] foundData = IOUtils.toByteArray( is );
         assertEquals( 7979, foundData.length );
 
+        refreshIndex("test-organization", "test-app");
+
         // get data by name
         is = resource().path( "/test-organization/test-app/foos/assetname" ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_OCTET_STREAM_TYPE ).get( InputStream.class );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BadGrammarQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BadGrammarQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BadGrammarQueryTest.java
index 7dc830a..bd95fd8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BadGrammarQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BadGrammarQueryTest.java
@@ -57,6 +57,8 @@ public class BadGrammarQueryTest extends AbstractRestIT {
 
         JsonNode activity = things.create( props );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select * where name != 'go'";
 
         ClientResponse.Status status = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
index 6f21e19..fe12766 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/BrowserCompatibilityTest.java
@@ -71,6 +71,8 @@ public class BrowserCompatibilityTest extends AbstractRestIT {
         Map<String, String> entity = hashMap( "name", "thing1" );
         JsonNode response = things.create( entity );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         UUID entityId = getEntityId( response, 0 );
 
         assertNotNull( entityId );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/PagingResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/PagingResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/PagingResourceIT.java
index 29de6ac..017be14 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/PagingResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/PagingResourceIT.java
@@ -17,7 +17,6 @@
 package org.apache.usergrid.rest.applications.collection;
 
 
-import com.fasterxml.jackson.core.JsonParser;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -41,7 +40,6 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-import org.codehaus.jackson.JsonFactory;
 
 
 /** Simple tests to test querying at the REST tier */
@@ -69,6 +67,8 @@ public class PagingResourceIT extends AbstractRestIT {
             created.add( entity );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // now page them all
         ApiResponse response = null;
         Iterator<Map<String, String>> entityItr = created.iterator();
@@ -107,6 +107,8 @@ public class PagingResourceIT extends AbstractRestIT {
             created.add( entity );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // now page them all
         ApiResponse response = null;
 
@@ -152,6 +154,7 @@ public class PagingResourceIT extends AbstractRestIT {
             created.add( entity );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
 
         ApiResponse response;
         int deletePageSize = 10;
@@ -161,6 +164,8 @@ public class PagingResourceIT extends AbstractRestIT {
         for ( int i = 0; i < size / deletePageSize; i++ ) {
             response = parse( things.delete() );
 
+            refreshIndex(context.getOrgName(), context.getAppName());
+
             assertEquals( "Only 10 entities should have been deleted", 10, response.getEntityCount() );
         }
 
@@ -184,6 +189,8 @@ public class PagingResourceIT extends AbstractRestIT {
         Map<String, String> data = hashMap( "name", "thing1" );
         JsonNode response = things.create( data );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         JsonNode entity = getEntity( response, 0 );
 
         String uuid = entity.get( "uuid" ).asText();
@@ -205,6 +212,8 @@ public class PagingResourceIT extends AbstractRestIT {
 
         assertEquals( entity, returnedEntity );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // verify it's gone
         returnedEntity = getEntity( things.entity( uuid ).get(), 0 );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
index 5dbce3b..fd4a12a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/AndOrQueryTest.java
@@ -74,7 +74,7 @@ public class AndOrQueryTest extends AbstractRestIT {
             }
         }
 
-        this.reindex( context.getAppUuid() );
+        this.refreshIndex( context.getAppUuid() );
 
         String errorQuery = "select * where created >= " + created + "AND madeup = true";
         JsonNode incorrectNode = activities.withQuery( errorQuery ).get();
@@ -106,7 +106,7 @@ public class AndOrQueryTest extends AbstractRestIT {
             JsonNode activity = activities.create( props );
         }
 
-        this.reindex( context.getAppUuid() );
+        this.refreshIndex( context.getAppUuid() );
 
         String query = "select * where not verb = 'go'";
         JsonNode incorrectNode = activities.query( query, "limit", Integer.toString( 10 ) );
@@ -137,7 +137,7 @@ public class AndOrQueryTest extends AbstractRestIT {
 
         JsonNode[] correctValues = activities.createEntitiesWithOrdinal( props, numValuesTested );
 
-        this.reindex( context.getAppUuid() );
+        this.refreshIndex( context.getAppUuid() );
 
         String inCorrectQuery = "select * where verb = 'go' and ordinal >= 10 ";
 
@@ -154,7 +154,7 @@ public class AndOrQueryTest extends AbstractRestIT {
         JsonNode[] correctValues;
         correctValues = madeupStuff.createEntitiesWithOrdinal( character, 1000 );
 
-        this.reindex( context.getAppUuid() );
+        this.refreshIndex( context.getAppUuid() );
 
         String inquisitiveQuery =
                 "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff' ORDER BY " + "Ordinal asc";
@@ -174,7 +174,7 @@ public class AndOrQueryTest extends AbstractRestIT {
 
         JsonNode[] correctValues = madeupStuff.createEntitiesWithOrdinal( character, numOfEntities );
 
-        this.reindex( context.getAppUuid() );
+        this.refreshIndex( context.getAppUuid() );
 
         String inquisitiveQuery = "select * where Ordinal >= 0 and Ordinal <= 2000 or WhoHelpedYou = 'Ruff'";
 
@@ -191,7 +191,7 @@ public class AndOrQueryTest extends AbstractRestIT {
 
         madeupStuff.createEntitiesWithOrdinal( character, 1000 );
 
-        this.reindex( context.getAppUuid() );
+        this.refreshIndex( context.getAppUuid() );
 
         String inquisitiveQuery = "select * where Ordinal gte 0 and Ordinal lte 2000 or WhoHelpedYou eq 'Ruff'";
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/OrderByTest.java
index 8d727c7..7e96818 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/OrderByTest.java
@@ -66,6 +66,8 @@ public class OrderByTest extends AbstractRestIT {
             }
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select * where created > " + created;
         JsonNode node = activities.withQuery( query ).get();
         assertEquals( 10, node.get( "entities" ).size() );
@@ -95,6 +97,8 @@ public class OrderByTest extends AbstractRestIT {
             JsonNode activity = activities.create( props );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select * where created > " + 1 + " order by created desc";
 
         JsonNode incorrectNode = activities.withQuery( query ).withLimit( 5 ).get();
@@ -137,6 +141,8 @@ public class OrderByTest extends AbstractRestIT {
             activites.add( activity );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         long lastCreated = activites.get( activites.size() - 1 ).get( "created" ).asLong();
 
         String errorQuery = String.format( "select * where created <= %d order by created desc", lastCreated );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PagingEntitiesTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PagingEntitiesTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PagingEntitiesTest.java
index 957d35c..effc618 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PagingEntitiesTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PagingEntitiesTest.java
@@ -71,6 +71,9 @@ public class PagingEntitiesTest extends AbstractRestIT {
             }
         }
         ArrayUtils.reverse( verifyCreated );
+        
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select * where created >= " + created;
 
 
@@ -120,6 +123,8 @@ public class PagingEntitiesTest extends AbstractRestIT {
             }
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select * where created >= " + created + " or verb = 'stop'";
 
         JsonNode node = activities.withQuery( query ).get();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
index 6e11eb8..10a435b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
@@ -59,23 +59,25 @@ public class PutTest extends AbstractRestIT {
 
 
         for ( int i = 0; i < 5; i++ ) {
-
             props.put( "ordinal", i );
             JsonNode activity = activities.create( props );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select * ";
 
         JsonNode node = activities.withQuery( query ).get();
         String uuid = node.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
         StringBuilder buf = new StringBuilder( uuid );
 
-
         activities.addToUrlEnd( buf );
         props.put( "actor", newActor );
         node = activities.put( props );
-        node = activities.withQuery( query ).get();
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
+        node = activities.withQuery( query ).get();
         assertEquals( 6, node.get( "entities" ).size() );
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GeoPagingTest.java
index 44ab030..91be0b2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GeoPagingTest.java
@@ -70,6 +70,8 @@ public class GeoPagingTest extends AbstractRestIT {
             index[i] = activity.findValue( "created" ).longValue();
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query =
                 "select * where location within 20000 of 37,-75 and created > " + index[2] + " and " + "created < "
                         + index[4] + "";
@@ -106,6 +108,8 @@ public class GeoPagingTest extends AbstractRestIT {
             saved[i] = activity;
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         JsonNode node = null;
         for ( int consistent = 0; consistent < 20; consistent++ ) {
             String query =

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
index 3eee059..7bbd95b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
@@ -68,6 +68,8 @@ public class UpdateGroupIT extends AbstractRestIT {
 
         assertTitle( groupId, "Old Title" );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // update that group by giving it a new title and using group path in URL
         try {
             Map<String, Object> group = new HashMap<String, Object>();
@@ -81,6 +83,8 @@ public class UpdateGroupIT extends AbstractRestIT {
 
         assertTitle( groupId, "New Title" );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // update that group by giving it a new title and using UUID in URL
         try {
             Map<String, Object> group = new HashMap<String, Object>();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
index a9a7f21..8953c49 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/events/EventsResourceIT.java
@@ -59,6 +59,8 @@ public class EventsResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "entities" ) );
         String advertising = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
 
+        refreshIndex("test-organization","test-app");
+
         payload = new LinkedHashMap<String, Object>();
         payload.put( "timestamp", 0 );
         payload.put( "category", "sales" );
@@ -67,7 +69,7 @@ public class EventsResourceIT extends AbstractRestIT {
                 put( "ad_sales", 20 );
             }
         } );
-
+        
         node = mapper.readTree( resource().path( "/test-organization/test-app/events" ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                 .post( String.class, payload ));
@@ -75,6 +77,8 @@ public class EventsResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "entities" ) );
         String sales = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
 
+        refreshIndex("test-organization","test-app");
+
         payload = new LinkedHashMap<String, Object>();
         payload.put( "timestamp", 0 );
         payload.put( "category", "marketing" );
@@ -91,6 +95,8 @@ public class EventsResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "entities" ) );
         String marketing = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
 
+        refreshIndex("test-organization","test-app");
+
         String lastId = null;
 
         // subsequent GETs advertising

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queues/QueueResourceLong1IT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queues/QueueResourceLong1IT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queues/QueueResourceLong1IT.java
index 64f90a8..636dad7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queues/QueueResourceLong1IT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queues/QueueResourceLong1IT.java
@@ -53,6 +53,8 @@ public class QueueResourceLong1IT extends AbstractQueueResourceIT {
             queue.post( MapUtils.hashMap( "id", i ) );
         }
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // now consume and make sure we get each message. We should receive each
         // message, and we'll use this for comparing results later
         final long timeout = 5000;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ActivityResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ActivityResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ActivityResourceIT.java
index 9f7df0f..b8ac91d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ActivityResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ActivityResourceIT.java
@@ -90,6 +90,8 @@ public class ActivityResourceIT extends AbstractRestIT {
         client.postGroupActivity( GROUP, "POST", activityTitle, activityDesc, "testCategory", null, null, null, null,
                 null );
 
+        refreshIndex("test-organization", "test-app");
+
         Query results = client.queryActivityFeedForGroup( GROUP );
 
         ApiResponse response = results.getResponse();
@@ -127,6 +129,8 @@ public class ActivityResourceIT extends AbstractRestIT {
 
         client.postUserActivity( "POST", activityTitle, activityDesc, "testCategory", current, null, null, null, null );
 
+        refreshIndex("test-organization", "test-app");
+
         Query results = client.queryActivityFeedForUser( USER );
 
         ApiResponse response = results.getResponse();
@@ -165,6 +169,8 @@ public class ActivityResourceIT extends AbstractRestIT {
 
         client.postActivity( "POST", activityTitle, activityDesc, "testCategory", current, null, null, null, null );
 
+        refreshIndex("test-organization", "test-app");
+
         Query results = client.queryActivity();
 
         ApiResponse response = results.getResponse();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
index 66c2ebb..0027f2e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
@@ -88,6 +88,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
     public void permissionWithMeInString() throws Exception {
         // user is created get a token
         createUser( "sumeet.agarwal@usergrid.com", "sumeet.agarwal@usergrid.com", "secret", "Sumeet Agarwal" );
+        refreshIndex("test-organization", "test-app");
 
         String token = userToken( "sumeet.agarwal@usergrid.com", "secret" );
 
@@ -115,6 +116,8 @@ public class CollectionsResourceIT extends AbstractRestIT {
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                 .post( String.class, data ));
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/nestprofiles" ).queryParam( "access_token", token )
                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                         .get( String.class ));
@@ -145,6 +148,8 @@ public class CollectionsResourceIT extends AbstractRestIT {
                 .post( String.class, payload ));
 
 
+        refreshIndex("test-organization", "test-app");
+
         //query for the first entity
 
         String query = "summaryOverview = 'My Summary'";
@@ -170,7 +175,6 @@ public class CollectionsResourceIT extends AbstractRestIT {
     @Test
     public void testNoDuplicateFields() throws Exception {
 
-        UUID entityId = null;
         {
             // create an "app_user" object with name fred
             Map<String, String> payload = hashMap( "type", "app_user" ).map( "name", "fred" );
@@ -180,9 +184,12 @@ public class CollectionsResourceIT extends AbstractRestIT {
                     .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
 
             String uuidString = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
-            entityId = UUIDUtils.tryGetUUID( uuidString );
+            UUID entityId = UUIDUtils.tryGetUUID( uuidString );
+            Assert.assertNotNull( entityId );
         }
 
+        refreshIndex("test-organization", "test-app");
+
         {
             // check REST API response for duplicate name property
             // have to look at raw response data, Jackson will remove dups

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ConnectionResourceTest.java
index 00ce1c2..5ab5ccd 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/ConnectionResourceTest.java
@@ -81,12 +81,16 @@ public class ConnectionResourceTest extends AbstractRestIT {
     /*finish setting up the two users */
 
 
+        refreshIndex("test-organization", "test-app");
+
         ClientResponse toddWant = resource().path( "/test-organization/test-app/users/todd/likes/peeps" )
                 .queryParam( "access_token", access_token ).accept( MediaType.TEXT_HTML )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( ClientResponse.class, objectOfDesire );
 
         assertEquals( 200, toddWant.getStatus() );
 
+        refreshIndex("test-organization", "test-app");
+
         JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/peeps" ).queryParam( "access_token", access_token )
                         .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                         .get( String.class ));
@@ -116,10 +120,14 @@ public class ConnectionResourceTest extends AbstractRestIT {
         UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
 
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         //test we have the "likes" in our connection meta data response
 
         JsonNode response = things.entity( "thing1" ).get();
@@ -171,10 +179,14 @@ public class ConnectionResourceTest extends AbstractRestIT {
         UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
 
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         //test we have the "likes" in our connection meta data response
 
         JsonNode response = things.entity( "thing1" ).get();
@@ -216,11 +228,15 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
         JsonNode response = things.entity( "thing2" ).delete();
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         JsonNode node = things.entity ( "thing2" ).get();
 
         assertNull(node);
@@ -236,11 +252,15 @@ public class ConnectionResourceTest extends AbstractRestIT {
 
         UUID thing2Id = getEntityId( things.create( hashMap( "name", "thing2" ) ), 0 );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         //create the connection
         things.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
 
         JsonNode response = things.entity( "thing1" ).delete();
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         JsonNode node = things.entity ( "thing1" ).get();
 
         assertNull(node);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
index 7fdc8b2..adb64b0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/GroupResourceIT.java
@@ -69,6 +69,8 @@ public class GroupResourceIT extends AbstractRestIT {
         catch ( Exception e ) {
             log.error( "Error creating group " + GROUP, e );
         }
+        refreshIndex("test-organization", "test-app");
+
     }
 
 
@@ -78,6 +80,8 @@ public class GroupResourceIT extends AbstractRestIT {
         ApiResponse response = client.createGroup( "groupName/withslash" );
         assertNull( response.getError() );
 
+        refreshIndex("test-organization", "test-app");
+
         {
             boolean failed = false;
             try {
@@ -107,6 +111,8 @@ public class GroupResourceIT extends AbstractRestIT {
 
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
 
+        refreshIndex("test-organization", "test-app");
+
         UUID newId = response.getEntities().get( 0 ).getUuid();
 
         Query results = client.queryGroups( String.format( "name='%s'", groupName ) );
@@ -153,6 +159,8 @@ public class GroupResourceIT extends AbstractRestIT {
         ApiResponse response = client.createGroup( groupName );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
 
+        refreshIndex("test-organization", "test-app");
+
         UUID createdId = response.getEntities().get( 0 ).getUuid();
 
         // add Permission
@@ -166,6 +174,8 @@ public class GroupResourceIT extends AbstractRestIT {
         assertNull( node.get( "errors" ) );
         assertEquals( node.get( "data" ).get( 0 ).asText(), "delete:/test" );
 
+        refreshIndex("test-organization", "test-app");
+
         node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/permissions" )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -183,6 +193,8 @@ public class GroupResourceIT extends AbstractRestIT {
         assertNull( node.get( "errors" ) );
         assertTrue( node.get( "data" ).size() == 0 );
 
+        refreshIndex("test-organization", "test-app");
+
         node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/permissions" )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -204,6 +216,8 @@ public class GroupResourceIT extends AbstractRestIT {
 
         UUID createdId = response.getEntities().get( 0 ).getUuid();
 
+        refreshIndex("test-organization", "test-app");
+
         // create Role
 
         String json = "{\"title\":\"" + roleName + "\",\"name\":\"" + roleName + "\"}";
@@ -215,6 +229,8 @@ public class GroupResourceIT extends AbstractRestIT {
         assertNull( node.get( "errors" ) );
 
 
+        refreshIndex("test-organization", "test-app");
+
         // add Role
 
         node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles/" + roleName )
@@ -237,6 +253,8 @@ public class GroupResourceIT extends AbstractRestIT {
         assertNull( node.get( "errors" ) );
         assertTrue( node.get( "entities" ).findValuesAsText( "name" ).contains( roleName ) );
 
+        refreshIndex("test-organization", "test-app");
+
         // remove Role
 
         node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles/" + roleName )
@@ -244,6 +262,8 @@ public class GroupResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
         assertNull( node.get( "errors" ) );
 
+        refreshIndex("test-organization", "test-app");
+
         node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + createdId + "/roles" )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
@@ -262,6 +282,8 @@ public class GroupResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
         assertNull( node.get( "errors" ) );
 
+        refreshIndex("test-organization", "test-app");
+
         // now it should be gone
         node = mapper.readTree( resource().path( "/test-organization/test-app/roles" ).queryParam( "access_token", access_token )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
index a85930d..68cf9b8 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/OwnershipResourceIT.java
@@ -79,10 +79,14 @@ public class OwnershipResourceIT extends AbstractRestIT {
         // anonymous user
         context.clearUser();
 
-        TestUser user1 =
-                new TestAppUser( "testuser1@usergrid.org", "password", "testuser1@usergrid.org" ).create( context )
-                                                                                                 .login( context )
-                                                                                                 .makeActive( context );
+        refreshIndex(context.getOrgName(), context.getAppName());
+
+        TestUser user1 = new TestAppUser( "testuser1@usergrid.org", "password", "testuser1@usergrid.org" ).create( context );
+        refreshIndex(context.getOrgName(), context.getAppName());
+        user1.login( context );
+        user1.makeActive( context );
+
+        refreshIndex(context.getOrgName(), context.getAppName());
 
         // create device 1 on user1 devices
         context.application().users().user( "me" ).devices()
@@ -90,16 +94,21 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         // anonymous user
         context.clearUser();
+        refreshIndex(context.getOrgName(), context.getAppName());
 
         // create device 2 on user 2
-        TestUser user2 =
-                new TestAppUser( "testuser2@usergrid.org", "password", "testuser2@usergrid.org" ).create( context )
-                                                                                                 .login( context )
-                                                                                                 .makeActive( context );
+        TestUser user2 = new TestAppUser( "testuser2@usergrid.org", "password", "testuser2@usergrid.org" ).create( context );
+        refreshIndex(context.getOrgName(), context.getAppName());
+        user2.login( context );
+        user2.makeActive( context );
+
+        refreshIndex(context.getOrgName(), context.getAppName());
 
         context.application().users().user( "me" ).devices()
                .create( MapUtils.hashMap( "name", "device2" ).map( "number", "5552223333" ) );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // now query on user 1.
 
         DevicesCollection devices = context.withUser( user1 ).application().users().user( "me" ).devices();
@@ -169,6 +178,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
         // anonymous user
         context.clearUser();
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         TestUser user1 =
                 new TestAppUser( "testuser1@usergrid.org", "password", "testuser1@usergrid.org" ).create( context )
                                                                                                  .login( context )
@@ -182,7 +193,9 @@ public class OwnershipResourceIT extends AbstractRestIT {
         data = context.application().users().user( "me" ).connection( "likes" ).collection( "restaurants" )
                       .entity( "4peaks" ).post();
 
-        String peaksId = getEntity( data, 0 ).get( "uuid" ).asText();
+        refreshIndex(context.getOrgName(), context.getAppName());
+
+       String peaksId = getEntity( data, 0 ).get( "uuid" ).asText();
 
         // anonymous user
         context.clearUser();
@@ -193,12 +206,16 @@ public class OwnershipResourceIT extends AbstractRestIT {
                                                                                                  .login( context )
                                                                                                  .makeActive( context );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         data = context.application().collection( "restaurants" )
                       .create( MapUtils.hashMap( "name", "arrogantbutcher" ) );
 
         data = context.application().users().user( "me" ).connection( "likes" ).collection( "restaurants" )
                       .entity( "arrogantbutcher" ).post();
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String arrogantButcherId = getEntity( data, 0 ).get( "uuid" ).asText();
 
         // now query on user 1.
@@ -207,6 +224,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
                 context.withUser( user1 ).application().users().user( "me" ).connection( "likes" )
                        .collection( "restaurants" );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         // check we can get it via id
         data = likeRestaurants.entity( peaksId ).get();
         assertNotNull( data );
@@ -298,6 +317,8 @@ public class OwnershipResourceIT extends AbstractRestIT {
 
         JsonNode city = context.application().collection( "cities" ).create( MapUtils.hashMap( "name", "tempe" ) );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String cityId = getEntity( city, 0 ).get( "uuid" ).asText();
 
         // create a 4peaks restaurant

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/PermissionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/PermissionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/PermissionsResourceIT.java
index e8c057c..f76026b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/PermissionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/PermissionsResourceIT.java
@@ -76,7 +76,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertEquals( ROLE, getEntity( node, 0 ).get( "name" ).asText() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // add the user to the role
         node = mapper.readTree( resource().path( "/test-organization/test-app/roles/" + ROLE + "/users/" + USER )
@@ -85,7 +85,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertNull( node.get( "error" ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // now check the user has the role
         node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + USER + "/roles" )
@@ -100,7 +100,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).delete( String.class ));
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // check if the role was deleted
 
@@ -131,7 +131,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertNull( node.get( "error" ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         node = mapper.readTree( resource().path( "/test-organization/test-app/groups/" + groupPath + "/users/" + USER )
                 .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
@@ -139,7 +139,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertNull( node.get( "error" ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Map<String, Group> groups = client.getGroupsForUser( USER );
 
@@ -153,7 +153,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertNull( node.get( "error" ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         groups = client.getGroupsForUser( USER );
 
@@ -198,7 +198,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertNull( getError( node ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // now try to add permission as the user, this should work
         addPermission( orgname, applicationName, "usercreatedrole", "get,put,post:/foo/**" );
@@ -267,7 +267,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         UUID userId = createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "reviewer1",
                 "reviewer1@usergrid.com" );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // grant this user the "reviewer" role
         node = mapper.readTree( resource().path( String.format( "/%s/%s/users/reviewer1/roles/reviewer", orgname, applicationName ) )
@@ -276,7 +276,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertNull( getError( node ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         String reviewer1Token = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), userId, 0 );
 
@@ -290,14 +290,14 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         review = hashMap( "rating", "4" ).map( "name", "4peaks" ).map( "review", "Huge beer selection" );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // put a review as the reviewer1 user
         resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
                 .queryParam( "access_token", reviewer1Token ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, review );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // get the reviews
 
@@ -323,7 +323,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertEquals( Status.UNAUTHORIZED, status );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         status = null;
 
@@ -338,7 +338,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertEquals( Status.UNAUTHORIZED, status );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // now test some groups
         UUID secondUserId = createRoleUser( orgs.getOrganization().getUuid(), appInfo.getId(), adminToken, "reviewer2",
@@ -351,21 +351,21 @@ public class PermissionsResourceIT extends AbstractRestIT {
                 .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, group );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // link the group to the role
         resource().path( String.format( "/%s/%s/groups/reviewergroup/roles/reviewer", orgname, applicationName ) )
                 .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, group );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // add the user to the group
         resource().path( String.format( "/%s/%s/users/reviewer2/groups/reviewergroup", orgname, applicationName ) )
                 .queryParam( "access_token", adminToken ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // post 2 reviews. Should get permissions from the group
 
@@ -380,14 +380,14 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         review = hashMap( "rating", "4" ).map( "name", "currycorner" ).map( "review", "Authentic" );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // post a review as the reviewer2 user
         resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
                 .queryParam( "access_token", secondUserToken ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, review );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // get all reviews as a user
         node = mapper.readTree( resource().path( String.format( "/%s/%s/reviews", orgname, applicationName ) )
@@ -414,7 +414,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
 
         assertEquals( Status.UNAUTHORIZED, status );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         status = null;
 
@@ -444,7 +444,11 @@ public class PermissionsResourceIT extends AbstractRestIT {
      */
     @Test
     public void wildcardMiddlePermission() throws Exception {
-        Map<String, String> params = buildOrgAppParams();
+
+         Map<String, String> params = buildOrgAppParams();
+        String orgname =params.get( "orgName" ) ;
+        String applicationName = params.get( "appName" ) ;
+        
         OrganizationOwnerInfo orgs = setup.getMgmtSvc().createOwnerAndOrganization( params.get( "orgName" ),
                 params.get( "username" ), "noname", params.get( "email" ), params.get( "password" ), true, false );
 
@@ -466,7 +470,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
         assertNull( getError( node ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // allow access to reviews
         addPermission( params.get( "orgName" ), params.get( "appName" ), adminToken, "reviewer",
@@ -491,7 +495,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
                         "wildcardpermusertwo@apigee.com" );
         assertNotNull( userTwoId );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // assign userOne the reviewer role
         node = mapper.readTree( resource().path( String
@@ -499,7 +503,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
                         userOneId.toString() ) ).queryParam( "access_token", adminToken )
                 .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         Map<String, String> book = hashMap( "title", "Ready Player One" ).map( "author", "Earnest Cline" );
 
@@ -512,7 +516,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
         assertEquals( "Ready Player One", getEntity( node, 0 ).get( "title" ).textValue() );
         String bookId = getEntity( node, 0 ).get( "uuid" ).textValue();
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         String userOneToken = setup.getMgmtSvc().getAccessTokenForAppUser( appInfo.getId(), userOneId, 0 );
         // post a review of the book as user1
@@ -524,17 +528,24 @@ public class PermissionsResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, review ));
         String reviewId = getEntity( node, 0 ).get( "uuid" ).textValue();
 
+        refreshIndex(orgname, applicationName);
+
         // POST https://api.usergrid.com/my-org/my-app/users/me/wrote/review/${reviewId}
         node = mapper.readTree( resource().path( String
                 .format( "/%s/%s/users/me/wrote/review/%s", params.get( "orgName" ), params.get( "appName" ),
                         reviewId ) ).queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
 
+        refreshIndex(orgname, applicationName);
+
         node = mapper.readTree( resource().path( String
                 .format( "/%s/%s/users/me/reviewed/books/%s", params.get( "orgName" ), params.get( "appName" ),
                         bookId ) ).queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
         logNode( node );
+
+        refreshIndex(orgname, applicationName);
+
         // POST https://api.usergrid.com/my-org/my-app/books/${bookId}/review/${reviewId}
         node = mapper.readTree( resource().path( String
                 .format( "/%s/%s/books/%s/review/%s", params.get( "orgName" ), params.get( "appName" ), bookId,
@@ -542,7 +553,7 @@ public class PermissionsResourceIT extends AbstractRestIT {
                 .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class ));
         logNode( node );
 
-        reindex("test-organization", "test-app");
+        refreshIndex(orgname, applicationName);
 
         // now try to post the same thing to books to verify as userOne the failure
         Status status = null;
@@ -557,6 +568,8 @@ public class PermissionsResourceIT extends AbstractRestIT {
         }
         assertEquals( Status.UNAUTHORIZED, status );
 
+        refreshIndex(orgname, applicationName);
+
         node = mapper.readTree( resource().path( String
                 .format( "/%s/%s/users/me/reviewed/books", params.get( "orgName" ), params.get( "appName" ) ) )
                 .queryParam( "access_token", userOneToken ).accept( MediaType.APPLICATION_JSON )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/RetrieveUsersTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/RetrieveUsersTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/RetrieveUsersTest.java
index 502b8bd..9c7a968 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/RetrieveUsersTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/RetrieveUsersTest.java
@@ -59,6 +59,8 @@ public class RetrieveUsersTest extends AbstractRestIT {
         props.put( "username", "Bob" );
         users.create( props );
 
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         String query = "select *";
         String incorrectQuery = "select * where username = 'Alica'";
 
@@ -74,6 +76,8 @@ public class RetrieveUsersTest extends AbstractRestIT {
         props.put( "username", "Nina" );
 
         JsonNode response = users.create( props );
+        refreshIndex(context.getOrgName(), context.getAppName());
+
         JsonNode entity = response.get( "entities" ).get( 0 );
         JsonNode metadata = entity.get( "metadata" );
         JsonNode sets = metadata.get( "sets" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e45dd323/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
index 4aeb3fb..043f4d1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/UserResourceIT.java
@@ -73,7 +73,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void usernameQuery() throws IOException {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         String ql = "username = 'user*'";
 
@@ -91,7 +91,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void nameQuery() throws IOException {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         String ql = "name = 'John*'";
 
@@ -107,7 +107,7 @@ public class UserResourceIT extends AbstractRestIT {
     @Test
     public void nameQueryByUUIDs() throws Exception {
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         String ql = "select uuid name = 'John*'";
 
@@ -124,7 +124,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void nameFullTextQuery() throws IOException {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         String ql = "name contains 'Smith' order by name ";
 
@@ -146,7 +146,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void fullTextQueryNotFullTextIndexed() throws IOException {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         String ql = "username contains 'user' ";
 
@@ -164,7 +164,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void fullQueryNotIndexed() throws IOException {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         String ql = "picture = 'foo' ";
 
@@ -181,7 +181,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void emtpyActorActivity() throws IOException {
         UserRepo.INSTANCE.load( resource(), access_token );
         UUID userId = UserRepo.INSTANCE.getByUserName( "user1" );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Activity activity = new Activity();
         activity.setProperty( "email", "rod@rodsimpson.com" );
@@ -215,7 +215,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void noUUIDorEmail() throws IOException {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID userId = UserRepo.INSTANCE.getByUserName( "user1" );
 
@@ -258,7 +258,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void ignoreUUIDandEmail() throws IOException {
         UserRepo.INSTANCE.load( resource(), access_token );
         UUID userId = UserRepo.INSTANCE.getByUserName( "user1" );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID testUUID = UUIDUtils.newTimeUUID();
         String testEmail = "foo@bar.com";
@@ -305,7 +305,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void userActivitiesDefaultOrder() throws IOException {
         UserRepo.INSTANCE.load( resource(), access_token );
         UUID userId = UserRepo.INSTANCE.getByUserName( "user1" );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Activity activity = new Activity();
         activity.setProperty( "email", "rod@rodsimpson.com" );
@@ -316,7 +316,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Entity entity = response.getFirstEntity();
 
@@ -331,7 +331,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         entity = response.getFirstEntity();
 
@@ -359,7 +359,8 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username, name, email, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+
+        refreshIndex("test-organization", "test-app");
 
         Entity userEntity = response.getEntities().get( 0 );
 
@@ -389,6 +390,9 @@ public class UserResourceIT extends AbstractRestIT {
     @Test
     public void resultSizeSame() throws IOException {
         UserRepo.INSTANCE.load( resource(), access_token );
+
+        refreshIndex("test-organization", "test-app");
+
         UUID userId1 = UserRepo.INSTANCE.getByUserName( "user1" );
         UUID userId2 = UserRepo.INSTANCE.getByUserName( "user2" );
         UUID userId3 = UserRepo.INSTANCE.getByUserName( "user3" );
@@ -444,7 +448,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username, name, id + "@usergrid.org", "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID createdId = response.getEntities().get( 0 ).getUuid();
 
@@ -465,7 +469,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username, name, id + "@usergrid.org", "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID createdId = response.getEntities().get( 0 ).getUuid();
 
@@ -481,7 +485,7 @@ public class UserResourceIT extends AbstractRestIT {
         // now create that same user again, it should work
         response = client.createUser( username, name, id + "@usergrid.org", "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         createdId = response.getEntities().get( 0 ).getUuid();
 
@@ -499,7 +503,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username, name, email, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID firstCreatedId = response.getEntities().get( 0 ).getUuid();
 
@@ -509,7 +513,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         response = client.createUser( username, name, email, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID secondCreatedId = response.getEntities().get( 0 ).getUuid();
 
@@ -524,7 +528,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // singular collection name
         path = String.format( "/test-organization/test-app/user/%s/conn2/%s", firstCreatedId, secondCreatedId );
@@ -534,7 +538,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         path = String.format( "/test-organization/test-app/users/%s/conn1", firstCreatedId );
 
@@ -576,7 +580,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username1, name1, email1, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID firstCreatedId = response.getEntities().get( 0 ).getUuid();
 
@@ -586,7 +590,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         response = client.createUser( username2, name2, email2, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID secondCreatedId = response.getEntities().get( 0 ).getUuid();
 
@@ -623,7 +627,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( email, name, email, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID userId = response.getEntities().get( 0 ).getUuid();
 
@@ -667,7 +671,7 @@ public class UserResourceIT extends AbstractRestIT {
         node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                          .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, perms ));
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         //connect the entities where role is the root
         path = String.format( "/test-organization/test-app/roles/%s/users/%s", roleId1, userId );
@@ -680,7 +684,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
 
         //connect the second role
@@ -692,7 +696,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals( userId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         //query the second role, it should work
         path = String.format( "/test-organization/test-app/roles/%s/users", roleId2 );
@@ -725,7 +729,7 @@ public class UserResourceIT extends AbstractRestIT {
         //query the first role, it should 404
         path = String.format( "/test-organization/test-app/roles/%s/users", roleId1 );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         try {
             node = mapper.readTree( resource().path( path ).queryParam( "access_token", access_token )
@@ -759,7 +763,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username1, name1, email1, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID firstCreatedId = response.getEntities().get( 0 ).getUuid();
 
@@ -775,7 +779,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         UUID secondCreatedId = response.getEntities().get( 0 ).getUuid();
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
@@ -789,7 +793,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals( secondCreatedId.toString(), getEntity( node, 0 ).get( "uuid" ).asText() );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // named entity in collection name
         path = String.format( "/test-organization/test-app/users/%s/conn2/pizzas/%s", username1, name );
@@ -812,7 +816,7 @@ public class UserResourceIT extends AbstractRestIT {
         ApiResponse response = client.createUser( username, name, email, "password" );
 
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Entity userEntity = response.getEntities().get( 0 );
 
@@ -839,7 +843,7 @@ public class UserResourceIT extends AbstractRestIT {
                          .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
                          .type( MediaType.APPLICATION_JSON_TYPE ).put( String.class, userEntity.getProperties() ));
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // now see if we've updated
         node = mapper.readTree( resource().path( "/test-organization/test-app/token" ).queryParam( "username", username )
@@ -912,7 +916,7 @@ public class UserResourceIT extends AbstractRestIT {
                   .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                   .post( String.class, payload );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users" ).queryParam( "access_token", access_token )
                           .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
@@ -1047,7 +1051,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         ApiResponse response = client.createUser( username, name, email, "password" );
         assertNull( "Error was: " + response.getErrorDescription(), response.getError() );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         UUID createdId = response.getEntities().get( 0 ).getUuid();
 
@@ -1062,7 +1066,7 @@ public class UserResourceIT extends AbstractRestIT {
         // check it
         assertNull( node.get( "errors" ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // add Role
 
@@ -1077,7 +1081,7 @@ public class UserResourceIT extends AbstractRestIT {
         assertNotNull( node.get( "entities" ).get( 0 ).get( "name" ) );
         assertEquals( node.get( "entities" ).get( 0 ).get( "name" ).asText(), roleName );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId + "/roles" )
             .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
@@ -1098,7 +1102,7 @@ public class UserResourceIT extends AbstractRestIT {
         // check it
         assertNull( node.get( "errors" ) );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         node = mapper.readTree( resource().path( "/test-organization/test-app/users/" + createdId + "/roles" )
                          .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
@@ -1218,7 +1222,7 @@ public class UserResourceIT extends AbstractRestIT {
         createUser( "test_1", "test_1@test.com", "test123", "Test1 User" ); // client.setApiUrl(apiUrl);
         createUser( "test_2", "test_2@test.com", "test123", "Test2 User" ); // client.setApiUrl(apiUrl);
         createUser( "test_3", "test_3@test.com", "test123", "Test3 User" ); // client.setApiUrl(apiUrl);
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         ApplicationInfo appInfo = setup.getMgmtSvc().getApplicationInfo( "test-organization/test-app" );
 
@@ -1238,7 +1242,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertNotNull( user_token_from_client_credentials );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Status status = null;
 
@@ -1285,7 +1289,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         setup.getMgmtSvc().deactivateUser( appInfo.getId(), userId );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         try {
             resource().path( "/test-organization/test-app/token" ).queryParam( "grant_type", "password" )
@@ -1306,7 +1310,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void delegatePutOnNotFound() throws Exception {
         String randomName = "user1_" + UUIDUtils.newTimeUUID().toString();
         createUser( randomName, randomName + "@apigee.com", "password", randomName );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         // should update a field
         JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/users/" + randomName )
@@ -1327,7 +1331,7 @@ public class UserResourceIT extends AbstractRestIT {
                              .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
                              .put( String.class, payload ));
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         logNode( response );
         response = mapper.readTree( resource().path( "/test-organization/test-app/users/" + randomName )
@@ -1373,7 +1377,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void queryForUserUuids() throws Exception {
 
         UserRepo.INSTANCE.load( resource(), access_token );
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         Status status = null;
 
@@ -1395,7 +1399,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertNotNull( userId );
 
-        reindex("test-organization", "test-app");
+        refreshIndex("test-organization", "test-app");
 
         ql = "uuid = " + userId;