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/11/11 00:22:03 UTC
[38/42] incubator-usergrid git commit: loadtests:infinite user feeder
loadtests:infinite user feeder
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a3b517b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a3b517b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a3b517b8
Branch: refs/heads/es-type-updates
Commit: a3b517b85a6e43fc75817d93a4e07e321818667f
Parents: 87d6e43
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Nov 10 14:54:11 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Nov 10 14:54:11 2014 -0700
----------------------------------------------------------------------
.../datagenerators/EntityDataGenerator.scala | 2 +-
.../datagenerators/FeederGenerator.scala | 43 +++++++++++++++++--
.../scenarios/NotificationScenarios.scala | 14 +-----
.../usergrid/scenarios/UserScenarios.scala | 26 ++++++++---
.../org/apache/usergrid/settings/Settings.scala | 12 +++++-
.../usergrid/simulations/AppSimulation.scala | 8 +---
.../usergrid/simulations/SetupSimulation.scala | 45 ++++++++++++++++++++
7 files changed, 118 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
index 2481737..f923eb2 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
@@ -41,7 +41,7 @@ object EntityDataGenerator {
}
- def generateUser(userId: Int): Map[String,String] = {
+ def generateUser(userId: String): Map[String,String] = {
return Map("username" -> "user".concat(userId.toString),
"profileId" -> Utils.generateRandomInt(10000, 1000000).toString,
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
index 8832bd7..7aee8c0 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
@@ -16,18 +16,20 @@
*/
package org.apache.usergrid.datagenerators
+ import java.util
import java.util.UUID
-
+ import java.util.concurrent.atomic.{AtomicInteger, AtomicLong}
import io.gatling.core.Predef._
import org.apache.usergrid.settings.Utils
import scala.collection.mutable.ArrayBuffer
+ import scala.util.Random
-object FeederGenerator {
+ object FeederGenerator {
def generateUserWithGeolocationFeeder(numUsers: Int, radius: Double, centerLatitude: Double, centerLongitude: Double): Array[Map[String, String]] = {
var userArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
for (userCount <- 1 to numUsers) {
- var user: Map[String, String] = EntityDataGenerator.generateUser(userCount)
+ var user: Map[String, String] = EntityDataGenerator.generateUser(userCount.toString)
var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
var blockLists: Map[String, String] = EntityDataGenerator.generateBlockUserLists(numUsers)
@@ -38,6 +40,41 @@ object FeederGenerator {
return userArray.toArray
}
+
+
+ /**
+ * Generate users forever
+ * @param radius
+ * @param centerLatitude
+ * @param centerLongitude
+ * @return
+ */
+ def generateUserWithGeolocationFeederInfinite(radius: Double, centerLatitude: Double, centerLongitude: Double, maxPossible: Int): Iterator[Map[String, String]] = {
+ val userFeeder = Iterator.from(1).map(i=>generateUserData(i.toString, radius, centerLatitude, centerLongitude))
+ return userFeeder
+
+ }
+
+ /**
+ * Generate user data based on atomically increasing integers
+ * @param radius
+ * @param centerLatitude
+ * @param centerLongitude
+ * @return
+ */
+ def generateUserData(id: String, radius: Double, centerLatitude: Double, centerLongitude: Double): Map[String, String] = {
+
+
+ var user: Map[String, String] = EntityDataGenerator.generateUser(id)
+ var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+ var blockLists: Map[String, String] = EntityDataGenerator.generateBlockUserLists(1)
+
+ user = user ++ geolocation ++ blockLists
+
+ return user
+ }
+
+
def generateGeolocationFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
val geolocationFeeder = new Feeder[String] {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
index c616472..6ed5625 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
@@ -68,21 +68,9 @@ object NotificationScenarios {
)
- val userFeeder = Settings.getUserFeeder
+ val userFeeder = Settings.getInfiniteUserFeeder()
val createScenario = scenario("Create Push Notification")
.feed(userFeeder)
- .exec(TokenScenarios.getUserToken)
- .exec( UserScenarios.getUserByUsername)
- .repeat(2){
- feed(FeederGenerator.generateEntityNameFeeder("device", Settings.numDevices))
- .exec( DeviceScenarios.postDeviceWithNotifier)
- .exec(ConnectionScenarios.postUserToDeviceConnection)
- }
- .exec(session => {
- // print the Session for debugging, don't do that on real Simulations
- println(session)
- session
- })
.exec( sendNotificationToUser)
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/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 d4579f7..0ebc5b6 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
@@ -54,14 +54,14 @@ import io.gatling.core.Predef._
http("POST geolocated Users")
.put("/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.is(200), status.saveAs("userStatus"), jsonPath("$..entities[0].uuid").saveAs("userId"))
- )
+ "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.in(200 to 400), status.saveAs("userStatus"), jsonPath("$..entities[0].uuid").saveAs("userId"))
+ )
.doIf("${userStatus}", "400") {
- exec(getUserByUsername)
- }
+ exec(getUserByUsername)
+ }
val deleteUserByUsername = exec(
http("DELETE user")
@@ -69,4 +69,16 @@ import io.gatling.core.Predef._
.headers(Headers.jsonAuthorized)
.check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
)
+
+ val createUsersWithDevicesScenario = scenario("Create Users")
+ .feed(Settings.getInfiniteUserFeeder())
+ .exec(TokenScenarios.getManagementToken)
+ .exec(UserScenarios.postUser)
+ .exec(TokenScenarios.getUserToken)
+ .exec(UserScenarios.getUserByUsername)
+ .repeat(2){
+ feed(FeederGenerator.generateEntityNameFeeder("device", Settings.numDevices))
+ .exec( DeviceScenarios.postDeviceWithNotifier)
+ .exec(ConnectionScenarios.postUserToDeviceConnection)
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/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 67faccd..4bcb6bb 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
@@ -38,7 +38,10 @@ object Settings {
// Simulation settings
val constantUsers:Int = Integer.getInteger("rampUsers", 10).toInt
- var numUsers:Int = constantUsers * duration
+ val numUsers:Int = constantUsers * duration
+
+ // Simulation settings
+ val maxPossibleUsers:Int = Integer.getInteger("maxPossibleUsers", 10).toInt
val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
val numDevices:Int = Integer.getInteger("numDevices", 4000).toInt
@@ -58,10 +61,15 @@ object Settings {
println(s"Will inject $constantUsers users per sec")
- def getUserFeeder():Array[Map[String, String]]= {
+ def getUserFeeder():Array[Map[String, String]]= {
val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude)
return userFeeder
}
+ def getInfiniteUserFeeder():Iterator[Map[String, String]]= {
+ val userFeeder = FeederGenerator.generateUserWithGeolocationFeederInfinite( userLocationRadius, centerLatitude, centerLongitude,maxPossibleUsers)
+ return userFeeder
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AppSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AppSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AppSimulation.scala
index 48fff1c..a9cfd10 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AppSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AppSimulation.scala
@@ -33,16 +33,12 @@ import scala.concurrent.duration._
*/
class AppSimulation extends Simulation {
println("Begin setup")
- Setup.setupOrg()
- Setup.setupApplication()
Setup.setupNotifier()
- Setup.setupUsers()
println("End Setup")
setUp(
NotificationScenarios.createScenario
- .inject(constantUsersPerSec(Settings.constantUsers) during (Settings.duration)) // wait for 15 seconds so create org can finish, need to figure out coordination
- .throttle(reachRps(Settings.throttle) in (Settings.rampTime.seconds))
+ .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.duration))
.protocols(Settings.httpConf.acceptHeader("application/json"))
- )
+ ).throttle(reachRps(Settings.throttle) in (Settings.rampTime seconds), holdFor(Settings.duration))
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a3b517b8/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
new file mode 100644
index 0000000..ab68d98
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/SetupSimulation.scala
@@ -0,0 +1,45 @@
+/*
+ *
+ * * Licensed to the Apache Software Foundation (ASF) under one or more
+ * * contributor license agreements. 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. For additional information regarding
+ * * copyright in this work, please see the NOTICE file in the top level
+ * * directory of this distribution.
+ *
+ */
+
+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
+import scala.concurrent.duration._
+
+/**
+ * Classy class class.
+ */
+class SetupSimulation extends Simulation{
+
+ println("Begin setup")
+ Setup.setupOrg()
+ Setup.setupApplication()
+ Setup.setupNotifier()
+ println("End Setup")
+
+ setUp(
+ UserScenarios.createUsersWithDevicesScenario
+ .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.duration))
+ .protocols(Settings.httpConf.acceptHeader("application/json"))
+ ).throttle(reachRps(Settings.throttle) in (Settings.rampTime seconds), holdFor(Settings.duration))
+}