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

incubator-usergrid git commit: Added session injection of a singleton token for removing post from report

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-252 c64fcba72 -> 9ad779ebf


Added session injection of a singleton token for removing post from report

Created 2 distinct scenarios for users get by username and get by page.


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

Branch: refs/heads/USERGRID-252
Commit: 9ad779ebf6e27f1e676207752afb53e8da9fdfae
Parents: c64fcba
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Dec 4 16:12:56 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Dec 4 16:12:56 2014 -0700

----------------------------------------------------------------------
 .../apache/usergrid/helpers/Extractors.scala    | 11 +++++
 .../usergrid/scenarios/UserScenarios.scala      | 26 ++++++----
 .../org/apache/usergrid/settings/Headers.scala  |  6 ++-
 .../simulations/GetUserPagesSimulation.scala    | 51 ++++++++++++++++++++
 .../simulations/GetUsersSimulation.scala        |  2 +-
 5 files changed, 85 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
index 055bf8d..3e85712 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
@@ -66,6 +66,17 @@ object Extractors {
   }
 
 
+      val ManagementToken: String = Setup.getManagementToken()
+
+
+  /**
+   * Get the management token for the admin username and password in settings, then inject it into the session
+   * under the variable "authToken"
+   * @return
+   */
+  def injectStaticTokenToSession() : Expression[Session] = {
+      session => session.set("authToken", ManagementToken)
+  }
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/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 e48b60c..2cfdef2 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
@@ -24,7 +24,6 @@ import org.apache.usergrid.datagenerators.FeederGenerator
 import org.apache.usergrid.settings.{Headers, Settings, Utils}
 import org.apache.usergrid.helpers.Extractors._
 
-import scala.util.parsing.json.JSONArray
 
 object UserScenarios {
 
@@ -86,9 +85,11 @@ object UserScenarios {
        exec(postUser)
      }
 
+  
    val putUser = exec(
      http("PUT geolocated Users")
        .put("/users/${username}")
+       .headers(Headers.jsonAuthorized)
        .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
         "displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
         "height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
@@ -99,10 +100,10 @@ object UserScenarios {
       
 
    val deleteUser = exec(
-     http("PUT geolocated Users")
+     http("DELETE geolocated Users")
        .delete("/users/${username}")
+       .headers(Headers.jsonAuthorized)
        .check(status.is(200))
-
    )
 
    val deleteUserIfExists =
@@ -175,27 +176,34 @@ object UserScenarios {
    /**
     * Puts a new user every time
     */
-   val putUsersInfinitely =  scenario("Put Users")
+   val putUsersInfinitely =  scenario("Put Users").exec(injectStaticTokenToSession)
      .feed(Settings.getInfiniteUserFeeder())
      .exec(putUser)
 
    /**
     * Deletes user every time
     */
-   val deleteUsersInfinitely =  scenario("Delete Users")
+   val deleteUsersInfinitely =  scenario("Delete Users").exec(injectStaticTokenToSession)
      .feed(Settings.getInfiniteUserFeeder())
      .exec(deleteUser)
 
    /**
     * Get the users a page at a time until exhausted
     */
-   val getUsersToEnd = scenario("Get Users")
-     //get the management token
-     .exec(TokenScenarios.getManagementToken)
+   val getUserPagesToEnd = scenario("Get User Pages").exec(injectStaticTokenToSession)
      //get users without a cursor
      .exec(getUsersWithoutCursor)
      //as long as we have a cursor, keep getting results
      .asLongAs(stringParamExists(SessionVarCursor)) {
         exec(getUsersWithCursor)
-      }
+      }.exec(sessionFunction => {
+     sessionFunction
+   })
+
+  val getUsersByUsername = scenario("Get User By Username").exec(injectStaticTokenToSession)
+    .feed(Settings.getInfiniteUserFeeder())
+         //get users without a cursor
+         .exec(getUserByUsername)
+
+
  }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
index 9b735e5..6cd6f2e 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
@@ -16,7 +16,9 @@
  */
  package org.apache.usergrid.settings
 
-/**
+ import org.apache.usergrid.helpers.Setup
+
+ /**
  *
  */
 object Headers {
@@ -40,4 +42,6 @@ object Headers {
 
 
 
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
new file mode 100755
index 0000000..5d76ca0
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * Posts application users continually to an application.  Expects the following parameters
+ *
+ * -DmaxPossibleUsers : The maximum number of users to be making requests as fast as possible.  Think of this as conccurrent users in the system
+ * -DrampTime: The amount of time (in seconds) to allow for maxPossibleUsers to be reached.  This will add new users linearlly
+ * -Dduration: The amount of time (in seconds) to continue to perform requests up with the maxPossibleUsers
+ */
+class GetUserPagesSimulation extends Simulation {
+
+  println("Begin setup")
+  Setup.setupOrg()
+  Setup.setupApplication()
+  println("End Setup")
+
+
+  setUp(
+    UserScenarios.getUserPagesToEnd
+      .inject(
+        /**
+         * injection steps take from this forum post
+         * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
+         */
+        rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
+        constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+
+      )).protocols(Settings.httpConf.acceptHeader("application/json"))
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9ad779eb/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 cceab3c..a088e27 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.getUsersToEnd
+    UserScenarios.getUsersByUsername
       .inject(
         /**
          * injection steps take from this forum post