You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/12/10 18:13:51 UTC

[02/41] incubator-usergrid git commit: Mostly working. Need to finish with setting cursor to empty on last request

Mostly working.  Need to finish with setting cursor to empty on last request


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

Branch: refs/heads/UG-rest-test-framework-overhaul
Commit: 23727010cc0bd3ca5a2363b6de5577a6845ed599
Parents: bd79d37
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Dec 3 17:53:34 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Dec 3 17:53:34 2014 -0700

----------------------------------------------------------------------
 .../usergrid/scenarios/UserScenarios.scala      | 42 +++++++++++++++-----
 .../simulations/GetUsersSimulation.scala        |  2 +-
 2 files changed, 34 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/23727010/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
index 2ca6d21..2bbe9a3 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -57,14 +57,6 @@ import io.gatling.core.Predef._
 
 
 
-   val getUsersWithCursor = exec(
-     http("GET user")
-       .get("/users?cursor=${cursor}")
-       .headers(Headers.jsonAuthorized)
-       .check(status.saveAs("userStatus"),  jsonPath("$..entities").saveAs("users"))
-   )
-
-
    /**
      * Try to get a user, if it returns a 404, create the user
      */
@@ -90,6 +82,27 @@ import io.gatling.core.Predef._
        )
       }
 
+   /**
+    * Get a collection of users without a cursor.  Sets the cursor and entities array as "users"
+    */
+   val getUsersWithoutCursor = exec(
+     http("GET user")
+       .get("/users")
+       .headers(Headers.jsonAuthorized)
+       .check(status.is(200),  jsonPath("$..entities").saveAs("users"), jsonPath("$..cursor").saveAs("cursor"))
+   )
+
+   /**
+    * Get the next page of users with the cursor, expects the value "cursor" to be present in teh session
+    */
+   val getUsersWithCursor = exec(
+        http("GET user")
+          .get("/users?cursor=${cursor}")
+          .headers(Headers.jsonAuthorized)
+          .check(status.is(200),  jsonPath("$..entities").saveAs("users"), jsonPath("$..cursor").saveAs("cursor"))
+      )
+
+
    val deleteUserByUsername = exec(
      http("DELETE user")
        .delete("/users/${username}")
@@ -119,5 +132,16 @@ import io.gatling.core.Predef._
         .feed(Settings.getInfiniteUserFeeder())
         .exec(UserScenarios.postUser)
 
-   val getUsersIndefinitely = scenario("Get Users").exec()
+   /**
+    * Get the users a page at a time until exhausted
+    */
+   val getUsersToEnd = scenario("Get Users").exec(
+   //get the management token
+     TokenScenarios.getManagementToken,
+   //get users without a cursor
+     getUsersWithoutCursor
+   //as long as we have a cursor, keep getting results
+   ).asLongAs(session => session("cursor").as[String] != "") {
+     exec(getUsersWithCursor)
+   }
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/23727010/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
index eefeff1..cceab3c 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
@@ -37,7 +37,7 @@ class GetUsersSimulation extends Simulation {
 
 
   setUp(
-    UserScenarios.postUsersInfinitely
+    UserScenarios.getUsersToEnd
       .inject(
         /**
          * injection steps take from this forum post