usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [1/3] usergrid git commit: Switch DISTRIBUTED database queueing to default not cache in memory as the in memory impl causes duplicate messgae processing quite often at the moment.
Date Sun, 02 Apr 2017 23:23:18 GMT
Repository: usergrid
Updated Branches:
  refs/heads/master 8b63aae7d -> d3e988bcb


http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
index f8cb9d4e..af87ca5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java
@@ -75,7 +75,7 @@ public class UserResourceIT extends AbstractRestIT {
         usersResource = this.app().collection("users");
         userResource = this.app().collection("user");
 
-        clientSetup.refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
     }
 
     @Test
@@ -249,14 +249,14 @@ public class UserResourceIT extends AbstractRestIT {
         // same as above, but with actor partially filled out
 
         Entity entity = usersResource.entity(userId.toString()).activities().post(activity);
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         UUID firstActivityId = entity.getUuid();
 
         activity = new ActivityEntity("rod@rodsimpson.com", "POST", "activity 2");
         entity = usersResource.entity(userId.toString()).activities().post(activity);
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         UUID secondActivityId = entity.getUuid();
 
@@ -284,7 +284,7 @@ public class UserResourceIT extends AbstractRestIT {
         map.put("email", email);
 
         Entity userEntity = usersResource.post(new Entity(map));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // get the user with username property that has an email value
         Entity testUser = usersResource.entity(username).get();
@@ -315,7 +315,7 @@ public class UserResourceIT extends AbstractRestIT {
         map.put("email", email);
 
         usersResource.post(new Entity(map));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // get the user with email property value
         // get the user with username property that has an email value
@@ -339,7 +339,7 @@ public class UserResourceIT extends AbstractRestIT {
         map.put("email", email);
 
         usersResource.post(new Entity(map));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // get the user with email property value
         // get the user with username property that has an email value
@@ -409,7 +409,7 @@ public class UserResourceIT extends AbstractRestIT {
         Entity entity = usersResource.post(user);
         UUID createdId = entity.getUuid();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         Collection results = usersResource.get(new QueryParameters().setQuery(String.format("name = '%s'", name)));
         entity = new User(results.getResponse().getEntities().get(0));
         assertEquals(createdId, entity.getUuid());
@@ -429,13 +429,13 @@ public class UserResourceIT extends AbstractRestIT {
 
         UUID createdId = entity.getUuid();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Entity newEntity = usersResource.entity(createdId.toString()).get();
 
         userResource.entity(newEntity).delete();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Collection results = usersResource.get(
             new QueryParameters().setQuery(String.format("username = '%s'", username)));
@@ -460,7 +460,7 @@ public class UserResourceIT extends AbstractRestIT {
         User entity = new User(username, name, email, "password");
 
         entity = new User(usersResource.post(entity));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         UUID firstCreatedId = entity.getUuid();
         username = "username2";
@@ -470,7 +470,7 @@ public class UserResourceIT extends AbstractRestIT {
         entity = new User(username, name, email, "password");
 
         entity = new User(usersResource.post(entity));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         UUID secondCreatedId = entity.getUuid();
 
@@ -484,7 +484,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals(secondCreatedId.toString(), conn1.getUuid().toString());
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
 
         Entity conn2 = usersResource.entity(
@@ -492,7 +492,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertEquals(secondCreatedId.toString(), conn2.getUuid().toString());
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Collection conn1Connections = usersResource.entity(firstCreatedId.toString()).connection("conn1").get();
 
@@ -542,7 +542,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // named entity in collection name
         Entity conn1 = usersResource.entity(firstCreatedId.toString()).connection("conn1", "users")
@@ -595,6 +595,7 @@ public class UserResourceIT extends AbstractRestIT {
         role = new Entity();
         role.put("name", "connectionQuerybyEmail2");
         role = this.app().collection("roles").post(role);
+        waitForQueueDrainAndRefreshIndex();
 
 
         UUID roleId2 = role.getUuid();
@@ -605,24 +606,24 @@ public class UserResourceIT extends AbstractRestIT {
         perms.put("permission", "get:/stuff/**");
         Entity perms2 = this.app().collection("roles").entity(roleId2.toString()).connection("permissions")
             .post(new Entity(perms));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
+
         //connect the entities where role is the root
         Entity perms3 = this.app().collection("roles").entity(roleId1.toString()).connection("users")
             .entity(userId.toString()).post();
-
-        // now create a connection of "likes" between the first user and the
-        // second using pluralized form
-
         assertEquals(userId.toString(), perms3.getUuid().toString());
+        waitForQueueDrainAndRefreshIndex();
 
 
+        // now create a connection of "likes" between the first user and the
+        // second using pluralized form
         //connect the second role
 
         Entity perms4 = this.app().collection("roles").entity(roleId2).connection("users").entity(userId).post();
-
         assertEquals(userId.toString(), perms4.getUuid().toString());
+        waitForQueueDrainAndRefreshIndex();
+
 
-        refreshIndex();
         //query the second role, it should work
         Collection userRoles = this.app().collection("roles").entity(roleId2).connection("users")
             .get(new QueryParameters().setQuery("select%20*%20where%20username%20=%20'" + email + "'"));
@@ -678,7 +679,7 @@ public class UserResourceIT extends AbstractRestIT {
         Entity pizzaEntity = this.app().collection("pizzas").post(pizza);
 
         UUID secondCreatedId = pizzaEntity.getUuid();
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // now create a connection of "likes" between the first user and the
         // second using pluralized form
@@ -708,7 +709,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         Entity userEntity = usersResource.post(entity);
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         // attempt to log in
         Token token = this.app().token().post(new Token(username, "password"));
 
@@ -728,7 +729,7 @@ public class UserResourceIT extends AbstractRestIT {
         userEntity = usersResource.entity(username).put(userEntity);
 
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         // now see if we've updated
 
 
@@ -782,7 +783,7 @@ public class UserResourceIT extends AbstractRestIT {
                     .chainPut("pin", "1234");
 
         usersResource.post(entity);
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Collection response = usersResource.get();
         // disable the user
@@ -798,7 +799,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void test_PUT_password_fail() {
         Entity entity = usersResource.post(new User("edanuff", "edanuff", "edanuff@email.com", "sesame"));
         this.app().token().post(new Token("edanuff", "sesame"));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         boolean fail = false;
         try {
             Entity changeResponse = usersResource.entity("edanuff").collection("password")
@@ -829,17 +830,17 @@ public class UserResourceIT extends AbstractRestIT {
     @Test
     public void test_PUT_password_ok() {
         Entity entity = usersResource.post(new User("edanuff", "edanuff", "edanuff@email.com", "sesame"));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         usersResource.entity(entity).collection("password").post(new ChangePasswordEntity("sesame", "sesame1"));
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         this.app().token().post(new Token("edanuff", "sesame1"));
 
         // if this was successful, we need to re-set the password for other
         // tests
         Entity changeResponse = usersResource.entity("edanuff").collection("password")
             .post(new ChangePasswordEntity("sesame1", "sesame"));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         assertNotNull(changeResponse);
 
     }
@@ -849,14 +850,14 @@ public class UserResourceIT extends AbstractRestIT {
     public void setUserPasswordAsAdmin() throws IOException {
         usersResource.post(new User("edanuff", "edanuff", "edanuff@email.com", "sesame"));
         String newPassword = "foofoo";
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // change the password as admin. The old password isn't required
         Entity node = usersResource.entity("edanuff").connection("password")
             .post(new ChangePasswordEntity(newPassword));
         assertNotNull(node);
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         Token response = this.app().token().post(new Token("edanuff", newPassword));
         assertNotNull(response);
     }
@@ -899,7 +900,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void testChangePassordToInvalidValue() {
 
         Entity entity = usersResource.post(new User("edanuff", "edanuff", "edanuff@email.com", "sesame"));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         try {
             usersResource.entity(entity).collection("password").post(new ChangePasswordEntity("sesame", "abc"));
@@ -930,12 +931,12 @@ public class UserResourceIT extends AbstractRestIT {
         this.app().collection("roles").post(role);
         // check it
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         // add Role
 
         role = usersResource.entity(createdId).collection("roles").entity(roleName).post();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         // check it
         assertNotNull(role);
         assertNotNull(role.get("name"));
@@ -966,7 +967,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void revokeToken() throws Exception {
 
         this.app().collection("users").post(new User("edanuff", "edanuff", "edanuff@email.com", "sesame"));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         Token token1 = this.app().token().post(new Token("edanuff", "sesame"));
         Token token2 = this.app().token().post(new Token("edanuff", "sesame"));
 
@@ -984,7 +985,7 @@ public class UserResourceIT extends AbstractRestIT {
         this.app().token().setToken(adminToken);
 
         usersResource.entity("edanuff").connection("revoketokens").post(new Entity().chainPut("token", token1));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         // the tokens shouldn't work
 
         int status = 0;
@@ -1032,7 +1033,7 @@ public class UserResourceIT extends AbstractRestIT {
         // now revoke the tokens
         this.app().token().setToken(adminToken);
         usersResource.entity("edanuff").connection("revoketokens").post();
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // the token3 shouldn't work
 
@@ -1070,7 +1071,7 @@ public class UserResourceIT extends AbstractRestIT {
         usersResource.post(new User("test_1", "Test1 User", "test_1@test.com", "test123")); // client.setApiUrl(apiUrl);
         usersResource.post(new User("test_2", "Test2 User", "test_2@test.com", "test123")); // client.setApiUrl(apiUrl);
         usersResource.post(new User("test_3", "Test3 User", "test_3@test.com", "test123")); // client.setApiUrl(apiUrl);
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         //Entity appInfo = this.app().get().getResponse().getEntities().get(0);
 
@@ -1080,7 +1081,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertNotNull(token.getAccessToken());
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         int status = 0;
 
@@ -1123,7 +1124,7 @@ public class UserResourceIT extends AbstractRestIT {
         Entity entityConn = usersResource.entity(userId).connection("deactivate").post(new Entity());
 
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         try {
             this.app().token().post(new Token("test_1", "test123"));
@@ -1141,7 +1142,7 @@ public class UserResourceIT extends AbstractRestIT {
         String randomName = "user1_" + UUIDUtils.newTimeUUID().toString();
         User user = new User(randomName, randomName, randomName + "@apigee.com", "password");
         usersResource.post(user);
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // should update a field
         Entity response = usersResource.entity(randomName).get();
@@ -1155,7 +1156,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         response = usersResource.post(user2);
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Entity response2 = usersResource.entity(randomName).get();
 
@@ -1208,7 +1209,7 @@ public class UserResourceIT extends AbstractRestIT {
 
         assertNotNull(userId);
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         ql = "uuid = " + userId;
 
@@ -1223,7 +1224,7 @@ public class UserResourceIT extends AbstractRestIT {
     public void testCredentialsTransfer() throws Exception {
 
         usersResource.post(new User("test_1", "Test1 User", "test_1@test.com", "test123")); // client.setApiUrl(apiUrl);
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         //Entity appInfo = this.app().get().getResponse().getEntities().get(0);
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/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 965105b..315f1f5 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
@@ -57,7 +57,7 @@ public class EventsResourceIT extends AbstractRestIT {
         assertNotNull(node.getEntities());
         String advertising = node.getEntity().get("uuid").toString();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         payload = new LinkedHashMap<String, Object>();
         payload.put( "timestamp", 0 );
@@ -74,7 +74,7 @@ public class EventsResourceIT extends AbstractRestIT {
         assertNotNull(node.getEntities());
         String sales = node.getEntity().get("uuid").toString();
 
-        refreshIndex( );
+        waitForQueueDrainAndRefreshIndex( );
 
         payload = new LinkedHashMap<String, Object>();
         payload.put( "timestamp", 0 );
@@ -91,7 +91,7 @@ public class EventsResourceIT extends AbstractRestIT {
         assertNotNull(node.getEntities());
         String marketing = node.getEntity().get( "uuid" ).toString();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         String lastId = null;
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
index f47fba0..74ad38b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/BasicGeoTests.java
@@ -109,7 +109,7 @@ public class BasicGeoTests extends AbstractRestIT {
         assertEquals( lat.toString(), entity.getMap("location").get("latitude").toString() );
         assertEquals( lon.toString(), entity.getMap("location").get("longitude").toString() );
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         //2. read back that entity make sure it is accurate
         /*
@@ -144,7 +144,7 @@ public class BasicGeoTests extends AbstractRestIT {
         assertEquals( newLon.toString(), entity.get( "location" ).get("longitude").asText() );
   */
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         //4. read back the updated entity, make sure it is accurate
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
index 91ccf38..9a1cb3c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/GeoPagingTest.java
@@ -91,7 +91,7 @@ public class GeoPagingTest extends AbstractRestIT {
         }
 
     }
-    this.refreshIndex();
+    this.waitForQueueDrainAndRefreshIndex();
     // 2. Query the groups from a nearby location, restricting the search
     //    by creation time to a single entity where created[i-1] < created[i] < created[i+1]
       //since this geo location is contained by an actor it needs to be actor.location.
@@ -150,7 +150,7 @@ public class GeoPagingTest extends AbstractRestIT {
         .map("latitude", -33.889058)
         .map("longitude", 151.124024));
     this.app().collection(collectionType).post(props2);
-    this.refreshIndex();
+    this.waitForQueueDrainAndRefreshIndex();
 
     Collection collection = this.app().collection(collectionType).get();
     assertEquals("Should return both entities", 2, collection.getResponse().getEntityCount());
@@ -182,7 +182,7 @@ public class GeoPagingTest extends AbstractRestIT {
       cats[i] = cat;
       this.app().collection("cats").post(cat);
     }
-    this.refreshIndex();
+    this.waitForQueueDrainAndRefreshIndex();
 
     QueryParameters params = new QueryParameters();
     for (int consistent = 0; consistent < 20; consistent++) {
@@ -229,7 +229,7 @@ public class GeoPagingTest extends AbstractRestIT {
             cats[i] = cat;
             this.app().collection("cats").post(cat);
         }
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         final QueryParameters params = new QueryParameters();
         for (int consistent = 0; consistent < 20; consistent++) {
@@ -279,6 +279,7 @@ public class GeoPagingTest extends AbstractRestIT {
         .map("latitude", -33.746369)
         .map("longitude", 150.952183));
     this.app().collection(collectionType).post(props);
+    this.waitForQueueDrainAndRefreshIndex();
 
     Entity props2 = new Entity();
     props2.put("name", "usergrid2");
@@ -286,7 +287,7 @@ public class GeoPagingTest extends AbstractRestIT {
         .map("latitude", -33.889058)
         .map("longitude", 151.124024));
     this.app().collection(collectionType).post(props2);
-    this.refreshIndex();
+    this.waitForQueueDrainAndRefreshIndex();
 
     // 2. Query from the center point to ensure that one is returned
     Collection collection = this.app().collection(collectionType).get(queryClose);
@@ -326,7 +327,7 @@ public class GeoPagingTest extends AbstractRestIT {
         .map("longitude", 150.952183));
     this.app().collection("users").post(props);
 
-    this.refreshIndex();
+    this.waitForQueueDrainAndRefreshIndex();
     // 2. Create a list of geo points
     List<double[]> points = new ArrayList<>();
     points.add(new double []{33.746369, -89});//Woodland, MS

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
index 7525d51..02a54da 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/MatrixQueryTests.java
@@ -21,7 +21,6 @@ import org.apache.usergrid.rest.test.resource.endpoints.CollectionEndpoint;
 import org.apache.usergrid.rest.test.resource.model.Collection;
 import org.apache.usergrid.rest.test.resource.model.Entity;
 import org.apache.usergrid.rest.test.resource.model.QueryParameters;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import java.util.UUID;
@@ -78,7 +77,7 @@ public class MatrixQueryTests extends AbstractRestIT {
         restaurant2 = this.app().collection("restaurants").post(restaurant2);
         restaurant3 = this.app().collection("restaurants").post(restaurant3);
         restaurant4 = this.app().collection("restaurants").post(restaurant4);
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         //3. Create "likes" connections between users and restaurants
         //user 1 likes old major
@@ -91,7 +90,7 @@ public class MatrixQueryTests extends AbstractRestIT {
 
         //user 3 likes  Lola (it shouldn't appear in the results)
         this.app().collection("users").entity(user3).connection("likes").collection("restaurants").entity(restaurant4).post();
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         //4. Retrieve "likes" connections per user and ensure the correct restaurants are returned
         Collection user1likes = this.app().collection("users").entity(user1).connection("likes").get();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
index a190526..6591713 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/OrderByTest.java
@@ -246,7 +246,7 @@ public class OrderByTest extends QueryTestBase {
             }
         }
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         //2. Query without 'order by'
         String query = "select * where created > " + created;
         QueryParameters params = new QueryParameters().setQuery(query);
@@ -289,7 +289,7 @@ public class OrderByTest extends QueryTestBase {
             this.app().collection("activity").post(props);
         }
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         //2. Query a subset of the entities, specifying order and limit
         String query = "select * where created > " + 1 + " order by created desc";
         QueryParameters params = new QueryParameters().setQuery(query).setLimit(5);
@@ -334,7 +334,7 @@ public class OrderByTest extends QueryTestBase {
             logger.info(String.valueOf(Long.parseLong(activities[0].get("created").toString())));
         }
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex(750);
 
 
         ArrayUtils.reverse(activities);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
index f7eb3fe..0adafef 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/QueryTestBase.java
@@ -65,7 +65,7 @@ public class QueryTestBase  extends AbstractRestIT {
             logger.info(entities[i].entrySet().toString());
         }
         //refresh the index so that they are immediately searchable
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         return entities;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
index 286c984..acf51c1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/queries/SelectMappingsQueryTest.java
@@ -83,7 +83,7 @@ public class SelectMappingsQueryTest extends QueryTestBase {
             .withProp( "testProp", value )
             .withProp( "TESTPROP", otherValue);
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // testProp and TESTPROP should now have otherValue
 
@@ -110,7 +110,7 @@ public class SelectMappingsQueryTest extends QueryTestBase {
         Entity entity = new Entity()
             .withProp( "testprop", value );
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // testProp and TESTPROP should now have otherValue
 
@@ -130,7 +130,7 @@ public class SelectMappingsQueryTest extends QueryTestBase {
         Entity entity = new Entity()
             .withProp( "testprop", value );
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // now query this without encoding the plus symbol
         QueryParameters params = new QueryParameters()
@@ -160,13 +160,13 @@ public class SelectMappingsQueryTest extends QueryTestBase {
         String value = RandomStringUtils.randomAlphabetic( 20 );
         Entity entity = new Entity().withProp( "testProp", value );
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // override with TESTPROP=newValue
         String newValue = RandomStringUtils.randomAlphabetic( 20 );
         entity = new Entity().withProp( "TESTPROP", newValue );
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // testProp and TESTPROP should new be queryable by new value
 
@@ -193,13 +193,13 @@ public class SelectMappingsQueryTest extends QueryTestBase {
         String value = RandomStringUtils.randomAlphabetic( 20 );
         Entity entity = new Entity().withProp( "TESTPROP", value );
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // override with testProp=newValue
         String newValue = RandomStringUtils.randomAlphabetic( 20 );
         entity = new Entity().withProp( "testProp", newValue );
         app().collection( collectionName ).post( entity );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // testProp and TESTPROP should new be queryable by new value
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
index 431d224..841ac1d 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AccessTokenIT.java
@@ -153,7 +153,7 @@ public class AccessTokenIT extends AbstractRestIT {
         assertNotNull( token.getAccessToken() );
         management().token().setToken( token );
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         assertNotNull( management().me().get( Token.class ) );
 
@@ -177,7 +177,7 @@ public class AccessTokenIT extends AbstractRestIT {
         assertNotNull( adminToken );
         assertNotNull( adminToken.getAccessToken() );
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         assertNotNull( management().me().get( Token.class ) );
 
@@ -237,7 +237,7 @@ public class AccessTokenIT extends AbstractRestIT {
         management().token().setToken( clientSetup.getSuperuserToken() );
         management().users().user( clientSetup.getUsername() ).revokeTokens().post(true , ApiResponse.class, null,null);
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
 
         //test that token 1 doesn't work
@@ -278,7 +278,7 @@ public class AccessTokenIT extends AbstractRestIT {
         management().token().setToken( clientSetup.getSuperuserToken() );
         management().users().user( clientSetup.getUsername() ).revokeToken().post( false, ApiResponse.class,null,queryParameters );
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
 
         //test that token 1 doesn't work

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
index f80f131..829f561 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/AdminUsersIT.java
@@ -17,7 +17,6 @@
 
 package org.apache.usergrid.rest.management;
 
-import com.sun.jersey.api.client.UniformInterfaceException;
 import net.jcip.annotations.NotThreadSafe;
 import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.management.MockImapClient;
@@ -77,7 +76,7 @@ public class AdminUsersIT extends AbstractRestIT {
         // change the password as admin. The old password isn't required
         management.users().user( username ).password().post(Entity.class,passwordPayload);
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         //Get the token using the new password
         Token adminToken = management.token().post( false, Token.class, new Token( username, "testPassword" ) ,null );
@@ -159,7 +158,7 @@ public class AdminUsersIT extends AbstractRestIT {
         // change the password as admin. The old password isn't required
         management.users().user( username ).password().post(Entity.class, passwordPayload );
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
 
         //Get the token using the new password
@@ -197,7 +196,7 @@ public class AdminUsersIT extends AbstractRestIT {
         management.token().setToken( clientSetup.getSuperuserToken());
         management.users().user( username ).password().post( passwordPayload );
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         assertNotNull( management.token().post( false, Token.class, new Token(username, "testPassword"), null ));
 
@@ -260,7 +259,7 @@ public class AdminUsersIT extends AbstractRestIT {
             //Send rest call to the /testProperties endpoint to persist property changes
             clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
 
-            refreshIndex();
+            waitForQueueDrainAndRefreshIndex();
 
             //Create organization for the admin user to be confirmed
             Organization organization = createOrgPayload( "testUnconfirmedAdminLogin", null );
@@ -342,7 +341,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             //Send rest call to the /testProperties endpoint to persist property changes
             clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
-            refreshIndex();
+            waitForQueueDrainAndRefreshIndex();
 
             Token superuserToken = management.token().post( Token.class,
                 new Token( clientSetup.getSuperuserName(), clientSetup.getSuperuserPassword() )  );
@@ -379,7 +378,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
             //Send rest call to the /testProperties endpoint to persist property changes
             clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
-            refreshIndex();
+            waitForQueueDrainAndRefreshIndex();
 
             Token testToken = management().token().post(Token.class,
                 new Token( originalTestProperties.getAsString( PROPERTIES_TEST_ACCOUNT_ADMIN_USER_EMAIL ),
@@ -586,7 +585,7 @@ public class AdminUsersIT extends AbstractRestIT {
     public void reactivateTest() throws Exception {
         //call reactivate endpoint on default user
         clientSetup.getRestClient().management().users().user( clientSetup.getUsername() ).reactivate().get();
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         //Create mocked inbox and check to see if you recieved an email in the users inbox.
         List<Message> inbox = Mailbox.get( clientSetup.getEmail());
@@ -599,7 +598,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
         // initiate password reset
         management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // create mocked inbox, get password reset email and extract token
         List<Message> inbox = Mailbox.get( clientSetup.getEmail() );
@@ -630,7 +629,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
         assertTrue( html.contains( "password set" ) );
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
 
         html = management().users().user( clientSetup.getUsername() ).resetpw().post( formData );
@@ -644,7 +643,7 @@ public class AdminUsersIT extends AbstractRestIT {
 
         // initiate password reset
         management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // create mocked inbox, get password reset email and extract token
         List<Message> inbox = Mailbox.get( clientSetup.getEmail() );
@@ -725,7 +724,7 @@ public class AdminUsersIT extends AbstractRestIT {
         payload.put( "newpassword", passwords[1] );
         management().users().user( clientSetup.getUsername() ).password().post( Entity.class,payload );
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         payload.put( "newpassword", passwords[0] );
         payload.put( "oldpassword", passwords[1] );
@@ -747,7 +746,7 @@ public class AdminUsersIT extends AbstractRestIT {
         // request password reset
 
         management().users().user( clientSetup.getUsername() ).resetpw().post(new Form());
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // get resetpw token from email
 
@@ -774,7 +773,7 @@ public class AdminUsersIT extends AbstractRestIT {
         String html = management().users().user( clientSetup.getUsername() ).resetpw().getTarget().request()
             .post( javax.ws.rs.client.Entity.form(formData), String.class );
         assertTrue( html.contains( "password set" ) );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // login with new password and get token
 
@@ -797,7 +796,7 @@ public class AdminUsersIT extends AbstractRestIT {
             put("newpassword", "test");
         }};
         management().users().user( clientSetup.getUsername() ).password().post( false, payload, null );
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         // get password and check password change time again
 
@@ -851,7 +850,7 @@ public class AdminUsersIT extends AbstractRestIT {
         //Create admin user
         management().orgs().org( clientSetup.getOrganizationName() ).users().post(ApiResponse.class ,adminUserPayload );
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         //Retrieves the admin users
         ApiResponse adminUsers = management().orgs().org( clientSetup.getOrganizationName() ).users().get(ApiResponse.class);
@@ -905,7 +904,7 @@ public class AdminUsersIT extends AbstractRestIT {
             //Send rest call to the /testProperties endpoint to persist property changes
             clientSetup.getRestClient().testPropertiesResource().post( testPropertiesPayload );
 
-            refreshIndex();
+            waitForQueueDrainAndRefreshIndex();
 
             //Retrieve properties and ensure that they are set correctly.
             ApiResponse apiResponse = clientSetup.getRestClient().testPropertiesResource().get();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
index 81ff2d3..1b649d2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ExportResourceIT.java
@@ -141,7 +141,7 @@ public class ExportResourceIT extends AbstractRestIT {
         assertNotNull( uuid );
 
         exportEntity = null;
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         try {
 
             exportEntity = management().orgs().org( clientSetup.getOrganizationName() )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
index c390393..9c35a6c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ImportResourceIT.java
@@ -193,7 +193,7 @@ public class ImportResourceIT extends AbstractRestIT {
         Organization orgPayload = new Organization(
             newOrgName, newOrgUsername, newOrgEmail, newOrgName, newOrgPassword, null);
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post(orgPayload);
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
         assertNotNull(orgCreatedResponse);
 
 
@@ -391,8 +391,8 @@ public class ImportResourceIT extends AbstractRestIT {
 //            for ( org.apache.usergrid.persistence.Entity importedThing : importedThings ) {
 //                emApp1.delete( importedThing );
 //            }
-//            emApp1.refreshIndex();
-//            emApp2.refreshIndex();
+//            emApp1.waitForQueueDrainAndRefreshIndex();
+//            emApp2.waitForQueueDrainAndRefreshIndex();
 //
 //            importedThings = emApp2.getCollection(
 //                appId2, "things", null, Query.Level.ALL_PROPERTIES).getEntities();
@@ -438,7 +438,7 @@ public class ImportResourceIT extends AbstractRestIT {
             .addToPath(importEntity.getUuid().toString())
             .get();
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Entity importGetIncludes = this.management().orgs().org( org ).app()
             .addToPath(app)
@@ -671,7 +671,7 @@ public class ImportResourceIT extends AbstractRestIT {
             Thread.sleep(1000);
         }
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         return importEntity;
     }
@@ -697,7 +697,7 @@ public class ImportResourceIT extends AbstractRestIT {
 
         }
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
 //        // first two things are related to each other
 //        em.createConnection(new SimpleEntityRef(type, created.get(0).getUuid()),
@@ -705,7 +705,7 @@ public class ImportResourceIT extends AbstractRestIT {
 //        em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
 //            "related", new SimpleEntityRef(type, created.get(0).getUuid()));
 //
-//        em.refreshIndex();
+//        em.waitForQueueDrainAndRefreshIndex();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
index 635368e..0a80d73 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/ManagementResourceIT.java
@@ -213,7 +213,7 @@ public class ManagementResourceIT extends AbstractRestIT {
             users1.add( "follower" + Integer.toString( i ) );
         }
 
-        refreshIndex(  );
+        waitForQueueDrainAndRefreshIndex(  );
 
         checkFeed( "leader1", users1 );
         //try with 11
@@ -230,20 +230,20 @@ public class ManagementResourceIT extends AbstractRestIT {
 
         //create user
         createUser( leader );
-        refreshIndex(   );
+        waitForQueueDrainAndRefreshIndex(   );
 
         String preFollowContent = leader + ": pre-something to look for " + UUID.randomUUID().toString();
 
         addActivity( leader, leader + " " + leader + "son", preFollowContent );
-        refreshIndex(  );
+        waitForQueueDrainAndRefreshIndex(  );
 
         String lastUser = followers.get( followers.size() - 1 );
         int i = 0;
         for ( String user : followers ) {
             createUser( user );
-            refreshIndex( );
+            waitForQueueDrainAndRefreshIndex( );
             follow( user, leader );
-            refreshIndex(  );
+            waitForQueueDrainAndRefreshIndex(  );
         }
         userFeed = getUserFeed( lastUser );
         assertTrue( userFeed.size() == 1 );
@@ -254,7 +254,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         String postFollowContent = leader + ": something to look for " + UUID.randomUUID().toString();
         addActivity( leader, leader + " " + leader + "son", postFollowContent );
 
-        refreshIndex(  );
+        waitForQueueDrainAndRefreshIndex(  );
 
         //check feed
         userFeed = getUserFeed( lastUser );
@@ -321,7 +321,7 @@ public class ManagementResourceIT extends AbstractRestIT {
             .post( new Application( "mgmt-org-app" ) );
 
 
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
 
         Entity appdata = apiResponse.getEntities().get(0);
         assertEquals((clientSetup.getOrganizationName() + "/mgmt-org-app")
@@ -336,7 +336,7 @@ public class ManagementResourceIT extends AbstractRestIT {
         assertEquals("Roles", roles.get("title").toString());
         assertEquals(4, roles.size());
 
-        refreshIndex(   );
+        waitForQueueDrainAndRefreshIndex(   );
 
         // GET /applications/mgmt-org-app
 
@@ -361,7 +361,7 @@ public class ManagementResourceIT extends AbstractRestIT {
     public void checkSizes() throws Exception {
         final String appname = clientSetup.getAppName();
         this.app().collection("testCollection").post(new Entity().chainPut("name","test"));
-        refreshIndex();
+        waitForQueueDrainAndRefreshIndex();
         Entity size = management().orgs().org( clientSetup.getOrganizationName() ).app().addToPath(appname).addToPath("_size").get();
         Entity rolesSize = management().orgs().org(clientSetup.getOrganizationName()).app().addToPath(appname).addToPath("roles/_size").get();
         Entity collectionsSize = management().orgs().org(clientSetup.getOrganizationName()).app().addToPath(appname).addToPath("collections/_size").get();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
index 2bbdaaf..ad204ae 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/OrganizationsIT.java
@@ -68,7 +68,7 @@ public class OrganizationsIT extends AbstractRestIT {
         assertNotNull( organizationResponse );
 
 //        Thread.sleep( 1000 );
-//        this.refreshIndex();
+//        this.waitForQueueDrainAndRefreshIndex();
 
         //Creates token
         Token token =
@@ -78,7 +78,7 @@ public class OrganizationsIT extends AbstractRestIT {
 
         assertNotNull( token );
 
-        //this.refreshIndex();
+        //this.waitForQueueDrainAndRefreshIndex();
 
         //Assert that the get returns the correct org and owner.
         Organization returnedOrg = clientSetup.getRestClient().management().orgs().org( organization.getOrganization() ).get();
@@ -136,7 +136,7 @@ public class OrganizationsIT extends AbstractRestIT {
         // Create organization
         Organization organization = createOrgPayload( "testCreateDuplicateOrgName", null );
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( organization );
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         assertNotNull( orgCreatedResponse );
 
@@ -193,7 +193,7 @@ public class OrganizationsIT extends AbstractRestIT {
         //create the org/owner
         Organization orgCreatedResponse = clientSetup.getRestClient().management().orgs().post( organization );
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         assertNotNull( orgCreatedResponse );
 
@@ -394,7 +394,7 @@ public class OrganizationsIT extends AbstractRestIT {
         //update the organization.
         management().orgs().org( clientSetup.getOrganizationName() ).put(orgPayload);
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         //retrieve the organization
         Organization orgResponse = management().orgs().org( clientSetup.getOrganizationName() ).get();
@@ -408,7 +408,7 @@ public class OrganizationsIT extends AbstractRestIT {
         //update the organization.
         management().orgs().org( clientSetup.getOrganizationName() ).put(orgPayload);
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
 
         orgResponse = management().orgs().org( clientSetup.getOrganizationName() ).get();
 
@@ -433,7 +433,7 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization orgResponse = management().orgs().org( clientSetup.getOrganizationName() ).get();
 
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
         //attempt to post duplicate connection
         Entity userPostResponse = management().orgs().org( clientSetup.getOrganizationName() ).users().user( clientSetup.getEmail() ).put( entity );
 
@@ -461,7 +461,7 @@ public class OrganizationsIT extends AbstractRestIT {
         Organization orgResponse = management().orgs().org( clientSetup.getOrganizationName() ).get();
 
 
-        this.refreshIndex();
+        this.waitForQueueDrainAndRefreshIndex();
         //attempt to post duplicate connection
         try {
             Entity userPostResponse = management().orgs().org( clientSetup.getOrganizationName() ).users().post( Entity.class, entity );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
index 8404632..90a6919 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
@@ -170,7 +170,7 @@ public class RegistrationIT extends AbstractRestIT {
                 "changeme");
             UUID userId = node.getUuid();
 
-            refreshIndex();
+            waitForQueueDrainAndRefreshIndex();
 
             String subject = "Password Reset";
 
@@ -239,7 +239,7 @@ public class RegistrationIT extends AbstractRestIT {
 
             //Disgusting data manipulation to parse the form response.
             Map adminUserPostResponse = (management().users().post( User.class, userForm ));
-            refreshIndex();
+            waitForQueueDrainAndRefreshIndex();
 
             Map adminDataMap = ( Map ) adminUserPostResponse.get( "data" );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
index 6e5e4f9..4799b0c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/AbstractRestIT.java
@@ -173,10 +173,12 @@ public class AbstractRestIT extends JerseyTest {
         return this.app().token().post( new Token( username, password ) );
     }
 
-    public void refreshIndex() {
-        //TODO see how we can refresh index (not async) for tests so sleep may not be needed
+    public void waitForQueueDrainAndRefreshIndex(int waitTimeMillis) {
+        // indexing is async, tests will need to wait for stuff to be processed.
+        // this sleep is slightly longer becasue distributed queueing on top of Cassandra can be used without and in-mem
+        // copy.  see Qakka in the persistence module
         try {
-            Thread.sleep(250); //ensure index docs are finished being sent to Elasticsearch by Usergrid before refresh
+            Thread.sleep(waitTimeMillis);
             clientSetup.refreshIndex();
         } catch (InterruptedException e) {
             System.out.println("Error refreshing index");
@@ -184,6 +186,10 @@ public class AbstractRestIT extends JerseyTest {
         }
     }
 
+    public void waitForQueueDrainAndRefreshIndex() {
+        waitForQueueDrainAndRefreshIndex(750);
+    }
+
 
     /**
      * Takes in the expectedStatus message and the expectedErrorMessage then compares it to the ClientErrorException

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index 98c5640..615bedd 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -72,6 +72,11 @@ elasticsearch.queue_impl=DISTRIBUTED
 # Queueing Test Settings
 # Reduce the long polling time for the tests
 queue.long.polling.time.millis=50
-queue.num.actors=50
+queue.num.actors=100
 queue.sender.num.actors=100
 queue.writer.num.actors=100
+elasticsearch.worker_count=12
+elasticsearch.worker_count_utility=4
+queue.get.timeout.seconds=10
+queue.send.timeout.seconds=10
+usergrid.push.worker_count=8

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
index 7d02360..22d7344 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/QueueListener.java
@@ -20,6 +20,7 @@ import com.codahale.metrics.*;
 import com.codahale.metrics.Timer;
 import com.google.inject.Injector;
 
+import org.apache.commons.lang.RandomStringUtils;
 import org.apache.usergrid.persistence.EntityManagerFactory;
 
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
@@ -148,7 +149,7 @@ public class QueueListener  {
             Thread.currentThread().setDaemon(true);
         }
 
-        Thread.currentThread().setName(getClass().getSimpleName()+"_PushNotifications-"+threadNumber);
+        Thread.currentThread().setName(getClass().getSimpleName()+"_Push-"+ RandomStringUtils.randomAlphanumeric(4)+"-"+threadNumber);
 
         final AtomicInteger consecutiveExceptions = new AtomicInteger();
 
@@ -268,12 +269,16 @@ public class QueueListener  {
                                 if (logger.isTraceEnabled()) {
                                     logger.trace("no messages...sleep...{}", sleepWhenNoneFound);
                                 }
-                                Thread.sleep(sleepWhenNoneFound);
+                                try {
+                                    Thread.sleep(sleepWhenNoneFound);
+                                } catch (InterruptedException e){
+                                    // noop
+                                }
                             }
                             timerContext.stop();
                             //send to the providers
                             consecutiveExceptions.set(0);
-                        }catch (Exception ex){
+                        } catch (Exception ex){
                             logger.error("failed to dequeue",ex);
 
                             // clear the queue name cache b/c tests might have wiped the keyspace
@@ -286,7 +291,7 @@ public class QueueListener  {
                                 Thread.sleep(sleeptime);
                             }catch (InterruptedException ie){
                                 if (logger.isTraceEnabled()) {
-                                    logger.info("sleep interrupted");
+                                    logger.trace("sleep interrupted");
                                 }
                             }
                         }
@@ -306,7 +311,7 @@ public class QueueListener  {
             return;
         }
         for(Future future : futures){
-            future.cancel(true);
+            future.cancel(false);
         }
 
         pool.shutdownNow();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
index 6b619b7..44b0139 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/gcm/GCMAdapter.java
@@ -16,7 +16,6 @@
  */
 package org.apache.usergrid.services.notifications.gcm;
 
-import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.android.gcm.server.*;
 import org.apache.usergrid.persistence.entities.Notification;
@@ -99,7 +98,7 @@ public class GCMAdapter implements ProviderAdapter {
         if(!map.containsKey(priorityKey) && notification.getPriority() != null){
             map.put(priorityKey, notification.getPriority());
         }
-        Batch batch = getBatch( map);
+        Batch batch = getBatch( map );
         batch.add(providerId, tracker);
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
index 89ff272..74c5c92 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
@@ -73,7 +73,7 @@ public class ServiceApplication extends CoreApplication {
         ServiceResults testRequest = testRequest( action, expectedCount, true, params );
 
         if ( !action.equals( ServiceAction.GET )) {
-            this.refreshIndex();
+            this.waitForQueueDrainAndRefreshIndex();
         }
 
         return testRequest;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
index a46bd60..60a5ba0 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
@@ -235,7 +235,7 @@ public class EmailFlowIT {
         assertNotNull( orgOwner );
 
         ApplicationInfo app = setup.getMgmtSvc().createApplication( orgOwner.getOrganization().getUuid(), appName );
-        this.app.refreshIndex();
+        this.app.waitForQueueDrainAndRefreshIndex();
 
         //turn on app admin approval for app users
         enableAdminApproval(app.getId());

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
index 075ee03..20d12ab 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
@@ -62,7 +62,7 @@ public class RoleIT {
 
         UUID applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "test-app" ).getId();
         EntityManager em = setup.getEmf().getEntityManager( applicationId );
-        setup.getEntityIndex().refresh(em.getApplicationId());
+        setup.getEntityIndex().waitForQueueDrainAndRefresh(em.getApplicationId(), 500);
 
         Map<String, Object> properties = new LinkedHashMap<String, Object>();
         properties.put( "username", "edanuff5" );
@@ -71,8 +71,7 @@ public class RoleIT {
         User user = em.create( User.ENTITY_TYPE, User.class, properties );
 
         em.createRole( "logged-in", "Logged In", 2000 );
-        setup.getEntityIndex().refresh(em.getApplicationId());
-        setup.getEntityIndex().refresh(em.getApplicationId());
+        setup.getEntityIndex().waitForQueueDrainAndRefresh(em.getApplicationId(), 500);
         em.addUserToRole( user.getUuid(), "logged-in" );
 
         String accessToken = setup.getMgmtSvc().getAccessTokenForAppUser( applicationId, user.getUuid(), 0 );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
index c071d1f..62818c2 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/CollectionServiceIT.java
@@ -232,7 +232,7 @@ public class CollectionServiceIT extends AbstractServiceIT {
             // ok
         }
 
-        app.refreshIndex();
+        app.waitForQueueDrainAndRefreshIndex();
         try {
             // try DELETE on cats with dogs name
             app.testRequest( ServiceAction.DELETE, 0, "cats", "Danny" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
index d3c2436..d37bb10 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
@@ -68,13 +68,14 @@ public class GroupServiceIT extends AbstractServiceIT {
         app.createGroupRole( group.getUuid(), "admin", 0 );
         app.createGroupRole( group.getUuid(), "author", 0 );
 
-        setup.getEntityIndex().refresh(app.getId());
+        app.waitForQueueDrainAndRefreshIndex(500);
 
 
         app.grantGroupRolePermission( group.getUuid(), "admin", "users:access:*" );
         app.grantGroupRolePermission( group.getUuid(), "admin", "groups:access:*" );
         app.grantGroupRolePermission( group.getUuid(), "author", "assets:access:*" );
-        setup.getEntityIndex().refresh(app.getId());
+
+        app.waitForQueueDrainAndRefreshIndex(500);
 
         app.testDataRequest( ServiceAction.GET, "groups", group.getUuid(), "rolenames" );
         app.testDataRequest( ServiceAction.GET, "groups", group.getUuid(), "roles", "admin", "permissions" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
index 8c2be2c..81dced1 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ServiceInvocationIT.java
@@ -82,6 +82,8 @@ public class ServiceInvocationIT extends AbstractServiceIT {
 
         app.testRequest( ServiceAction.POST, 1, null, "users", "edanuff", "likes", cat.getUuid() );
 
+        app.waitForQueueDrainAndRefreshIndex(250);
+
         Entity restaurant = app.doCreate( "restaurant", "Brickhouse" );
 
         app.createConnection( user, "likes", restaurant );
@@ -92,6 +94,8 @@ public class ServiceInvocationIT extends AbstractServiceIT {
 
         app.testRequest( ServiceAction.POST, 1, "users", user.getUuid(), "connections", "likes", restaurant.getUuid() );
 
+        app.waitForQueueDrainAndRefreshIndex(250);
+
         app.testRequest( ServiceAction.GET, 1, "users", "edanuff", "likes", "cats" );
 
         app.testRequest( ServiceAction.GET, 3, "users", "edanuff", "likes" );
@@ -104,7 +108,7 @@ public class ServiceInvocationIT extends AbstractServiceIT {
         app.testRequest( ServiceAction.GET, 1, "users", "edanuff", "likes",
                 Query.fromQL( "select * where name='axis*'" ) );
 
-//        TODO, we don't allow this at the RESt level, why is this a test?
+//        TODO, we don't allow this at the REST level, why is this a test?
 //        app.testRequest( ServiceAction.GET, 3, null, "users", "edanuff", "connections" );
 
         app.put( "color", "blacknwhite" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index 5ea815f..c035192 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -28,7 +28,6 @@ import org.apache.usergrid.persistence.SimpleEntityRef;
 import org.apache.usergrid.persistence.entities.Notification;
 import org.apache.usergrid.persistence.entities.Receipt;
 import org.apache.usergrid.services.AbstractServiceIT;
-import org.apache.usergrid.services.notifications.gcm.NotificationsServiceIT;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,8 +51,7 @@ public abstract class AbstractServiceNotificationIT extends AbstractServiceIT {
             throws Exception {
         long timeout = System.currentTimeMillis() + 60000;
         while (System.currentTimeMillis() < timeout) {
-            Thread.sleep(200);
-            app.refreshIndex();
+            app.waitForQueueDrainAndRefreshIndex(200);
             notification = app.getEntityManager().get(notification.getUuid(), Notification.class);
             if (notification.getFinished() != null) {
                 return notification;
@@ -95,10 +93,9 @@ public abstract class AbstractServiceNotificationIT extends AbstractServiceIT {
             }
         }
 
-        //assertEquals(expected, receipts.size());
-        if( expected != receipts.size()){
-            logger.warn("Expected receipt count {} does not match actual count {}", expected, receipts.size());
-        }
+
+        assertEquals(expected, receipts.size());
+
 
         for (EntityRef receipt : receipts) {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 2a757ca..1c3bbcd 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -117,7 +117,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
                 setup.getEntityIndex().refresh(app.getId());
 
         listener = new QueueListener(ns.getServiceManagerFactory(),ns.getEntityManagerFactory(), new Properties());
-        listener.DEFAULT_SLEEP = 200;
         listener.start();
     }
 
@@ -234,24 +233,24 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         );
 
 
-        // verify Query for CREATED state
+        notificationWaitForComplete(notification);
+        app.waitForQueueDrainAndRefreshIndex(250);
+
+        // verify Query for FINISHED state and that the devices processed is 0
         Query query =  Query.fromEquals( "state", Notification.State.FINISHED.toString() );
         Results results = app.getEntityManager().searchCollection(app.getEntityManager().getApplicationRef(), "notifications", query);
-        Entity entity = results.getEntitiesMap().get(notification.getUuid());
-        assertNotNull(entity);
-
-        notificationWaitForComplete(notification);
+        notification = (Notification)results.getEntitiesMap().get(notification.getUuid()).toTypedEntity();
+        assertEquals(0, notification.getDeviceProcessedCount());
 
         // perform push //
 
-        //ns.getQueueManager().processBatchAndReschedule(notification, null);
         notification = app.getEntityManager().get(e.getUuid(), Notification.class);
 
         // verify Query for FINISHED state
         query = Query.fromEquals("state", Notification.State.FINISHED.toString());
         results = app.getEntityManager().searchCollection(app.getEntityManager().getApplicationRef(),
                 "notifications", query);
-        entity = results.getEntitiesMap().get(notification.getUuid());
+        Entity entity = results.getEntitiesMap().get(notification.getUuid());
         assertNotNull(entity);
 
         notification = (Notification) entity.toTypedEntity();
@@ -501,7 +500,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
     @Test
     public void oneDeviceTwoNotifiers() throws Exception {
 
-        // This test should configure 2 notifiers on a device and ensure that we can send to one of them
+        // This test should configure 2 notifiers on device1 and ensure that we can send to one of them
 
         // create a 2nd notifier //
         Object notifierName1 = "apNs2";
@@ -525,17 +524,19 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         assertEquals(notifier2.getProvider(), PROVIDER);
         assertEquals(notifier2.getEnvironment(), environment1);
 
+
+        // Add a device token for the 2nd notifier
+        app.clear();
         String key2 = notifier2.getName() + NOTIFIER_ID_POSTFIX;
-        device1.setProperty(key2, PUSH_TOKEN);
-        app.getEntityManager().update(device1);
-        setup.getEntityIndex().refresh(app.getId()); // need to refresh the index after an update
+        app.put(key2, PUSH_TOKEN);
+        app.testRequest(ServiceAction.PUT, 1, "devices", device1).getEntity();
 
 
         // create push notification //
         app.clear();
         String payload = getPayload();
         Map<String, String> payloads = new HashMap<String, String>(1);
-        payloads.put(notifier.getUuid().toString(), payload);
+        payloads.put(notifierName, payload);
         app.put("payloads", payloads);
         app.put("debug",true);
 
@@ -543,14 +544,14 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
             "notifications").getEntity();
         app.testRequest(ServiceAction.GET, 1, "notifications", notificationEntity.getUuid());
 
-        Notification notification = app.getEntityManager().get(notificationEntity.getUuid(),
-                Notification.class);
-        assertEquals(
-                notification.getPayloads().get(notifier.getUuid().toString()),
-                payload);
+        Notification notification = app.getEntityManager().get(notificationEntity.getUuid(), Notification.class);
+        assertEquals(payload, notification.getPayloads().get(notifierName));
 
         // perform push //
         notification = notificationWaitForComplete(notification);
+
+        app.waitForQueueDrainAndRefreshIndex(2500);
+
         checkReceipts(notification, 1);
     }
 
@@ -692,6 +693,9 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
         // perform push //
         notification = notificationWaitForComplete(notification);
+
+        app.waitForQueueDrainAndRefreshIndex(250);
+
         checkReceipts(notification, 2);
 
         // Statistics are not accurate.  See - https://issues.apache.org/jira/browse/USERGRID-1207

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index 1a9f4f7..8360009 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -62,13 +62,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
     private NotificationsService ns;
     private QueueListener listener;
 
-
-    @BeforeClass
-    public static void setup() {
-
-
-    }
-
     @Before
     public void before() throws Exception {
 
@@ -103,7 +96,6 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         ns = getNotificationService();
 
         listener = new QueueListener(ns.getServiceManagerFactory(), ns.getEntityManagerFactory(), new Properties());
-        listener.DEFAULT_SLEEP = 200;
         listener.start();
     }
 
@@ -569,6 +561,9 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         // wait for notification to be marked finished
         notification = notificationWaitForComplete(notification);
 
+        // receipts are created and queried, wait a bit longer for this to happen as indexing
+        app.waitForQueueDrainAndRefreshIndex(500);
+
         // get the receipts entity IDs
         List<EntityRef> receipts = getNotificationReceipts(notification);
         assertEquals(1, receipts.size());
@@ -635,6 +630,10 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
         notification = notificationWaitForComplete(notification);
         app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
 
+
+        // receipts are created and queried, wait a bit longer for this to happen as indexing
+        app.waitForQueueDrainAndRefreshIndex(500);
+
         // get the receipts entity IDs
         List<EntityRef> receipts = getNotificationReceipts(notification);
         assertEquals(1, receipts.size());

http://git-wip-us.apache.org/repos/asf/usergrid/blob/d3e988bc/stack/services/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/usergrid-custom-test.properties b/stack/services/src/test/resources/usergrid-custom-test.properties
index 49f8b5d..bcc8b8e 100644
--- a/stack/services/src/test/resources/usergrid-custom-test.properties
+++ b/stack/services/src/test/resources/usergrid-custom-test.properties
@@ -38,13 +38,14 @@ elasticsearch.queue_impl.resolution=true
 elasticsearch.queue_impl=DISTRIBUTED
 
 # Queueing Test Settings
-# Reduce the long polling time for the tests
-queue.long.polling.time.millis=150
-queue.num.actors=5
-queue.sender.num.actors=5
-queue.writer.num.actors=5
-elasticsearch.worker_count=2
-usergrid.push.worker_count=2
+queue.long.polling.time.millis=50
+queue.num.actors=50
+queue.sender.num.actors=50
+queue.writer.num.actors=50
+queue.get.timeout.seconds=10
+elasticsearch.worker_count=8
+elasticsearch.worker_count_utility=8
+usergrid.push.worker_count=8
 
 
 # This property is required to be set and cannot be defaulted anywhere


Mime
View raw message