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/03 19:00:46 UTC
[12/17] incubator-usergrid git commit: Refactored post users
simulation and user scenarios
Refactored post users simulation and user scenarios
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e7cd6f82
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e7cd6f82
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e7cd6f82
Branch: refs/heads/index-alias
Commit: e7cd6f82d5597c785be10f2ab7c230166ae9fdd8
Parents: 12a522a
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Dec 1 18:15:33 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Dec 1 18:15:33 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/UserScenarios.scala | 50 +++++++++++++++-----
.../org/apache/usergrid/settings/Settings.scala | 2 +-
.../simulations/PostUsersSimulation.scala | 35 +++++---------
3 files changed, 51 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7cd6f82/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 63466be..7d1c9b5 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
@@ -38,20 +38,33 @@ import io.gatling.core.Predef._
.check(status.saveAs("userStatus"), jsonPath("$..entities[0]").exists, jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs("userId"))
)
- val postUserIfNotExists =
- exec(getUserByUsername)
- .doIf ("${userStatus}", "404") {
+
+ /**
+ * Post a user
+ */
+ val postUser =
+
exec(
- http("POST geolocated Users")
- .post("/users")
- .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}",
- "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
- .check(status.saveAs("userStatus"))
- .check(status.is(200),jsonPath("$..entities[0].uuid").saveAs("userId"))
- )
- }
+ http("POST geolocated Users")
+ .post("/users")
+ .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}",
+ "showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
+ .check(status.saveAs("userStatus"))
+ .check(status.is(200),jsonPath("$..entities[0].uuid").saveAs("userId"))
+ )
+
+
+ /**
+ * Try to get a user, if it returns a 404, create the user
+ */
+ val postUserIfNotExists =
+ exec(getUserByUsername)
+ .doIf ("${userStatus}", "404") {
+ exec(postUser)
+ }
+
val putUser =
exec(getUserByUsername)
@@ -75,6 +88,10 @@ import io.gatling.core.Predef._
.check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
)
+ /**
+ * Logs in as the admin user. Checks if a user exists, if not, creates the user
+ * Logs in as the user, then creates 2 devices if they do not exist
+ */
val createUsersWithDevicesScenario = scenario("Create Users")
.feed(Settings.getInfiniteUserFeeder())
.exec(TokenScenarios.getManagementToken)
@@ -85,4 +102,11 @@ import io.gatling.core.Predef._
feed(FeederGenerator.generateEntityNameFeeder("device", Settings.numDevices))
.exec( DeviceScenarios.maybeCreateDevices)
}
+
+ /**
+ * Posts a new user every time
+ */
+ val postUsersInfinitely = scenario("Post Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(UserScenarios.postUser)
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7cd6f82/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
index 570b404..4ef28c1 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
@@ -58,7 +58,7 @@ object Settings {
val pushNotifier = if (System.getProperty("pushNotifier") != null) System.getProperty("pushNotifier") else "loadNotifier"
val pushProvider = if (System.getProperty("pushProvider") != null) System.getProperty("pushProvider") else "noop"
- println(s"Will inject $maxPossibleUsers users per sec")
+ println(s"Will inject up to $maxPossibleUsers users per sec")
def getUserFeeder():Array[Map[String, String]]= {
val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e7cd6f82/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
index 1c998cc..6992958 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
@@ -14,37 +14,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package org.apache.usergrid.simulations
+package org.apache.usergrid.simulations
import io.gatling.core.Predef._
- import org.apache.usergrid.datagenerators.FeederGenerator
- import org.apache.usergrid.scenarios.UserScenarios
- import org.apache.usergrid.settings.Settings
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.UserScenarios
+import org.apache.usergrid.settings.Settings
- import scala.concurrent.duration._
+import scala.concurrent.duration._
class PostUsersSimulation extends Simulation {
- // Target settings
- val httpConf = Settings.httpConf
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ println("End Setup")
- // Simulation settings
- val numUsers:Int = Settings.numUsers
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
- // Geolocation settings
- val centerLatitude:Double = Settings.centerLatitude
- val centerLongitude:Double = Settings.centerLongitude
- val userLocationRadius:Double = Settings.userLocationRadius
- val geosearchRadius:Int = Settings.geosearchRadius
+ setUp(
+ UserScenarios.postUsersInfinitely
+ .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.duration)) // wait for 15 seconds so create org can finish, need to figure out coordination
- val feeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude).queue
- val scnToRun = scenario("POST geolocated users")
- .feed(feeder)
- .exec(UserScenarios.postUserIfNotExists)
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+ ) .throttle(reachRps(Settings.maxPossibleUsers) in (Settings.rampTime.seconds)).protocols(Settings.httpConf.acceptHeader("application/json"))
}