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/08 03:19:40 UTC

[1/2] incubator-usergrid git commit: Added infinite feeder

Repository: incubator-usergrid
Updated Branches:
  refs/heads/toddtest 832df3b5d -> 4fd87decc


Added infinite 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/89c6857f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/89c6857f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/89c6857f

Branch: refs/heads/toddtest
Commit: 89c6857fd464fc97767a07833d82a5da4d887688
Parents: 832df3b
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 7 19:11:56 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 7 19:11:56 2014 -0700

----------------------------------------------------------------------
 .../datagenerators/EntityDataGenerator.scala    |  4 +-
 .../datagenerators/FeederGenerator.scala        | 41 +++++++++++++++++++-
 .../scenarios/NotificationScenarios.scala       |  6 ++-
 .../org/apache/usergrid/settings/Settings.scala | 13 +++++--
 .../usergrid/simulations/AppSimulation.scala    |  8 ++--
 5 files changed, 59 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/89c6857f/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..44f0e07 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,9 +41,9 @@ object EntityDataGenerator {
 
   }
 
-  def generateUser(userId: Int): Map[String,String] = {
+  def generateUser(userId: String): Map[String,String] = {
 
-    return Map("username" -> "user".concat(userId.toString),
+    return Map("username" -> "user".concat(userId),
       "profileId" -> Utils.generateRandomInt(10000, 1000000).toString,
       "displayName" -> Utils.generateRandomInt(10000, 1000000).toString,
       "showAge" -> Utils.generateRandomInt(0, 1).toString,

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/89c6857f/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..008f129 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
@@ -17,6 +17,7 @@
  package org.apache.usergrid.datagenerators
 
  import java.util.UUID
+ import java.util.concurrent.atomic.{AtomicInteger, AtomicLong}
 
  import io.gatling.core.Predef._
  import org.apache.usergrid.settings.Utils
@@ -27,7 +28,7 @@ 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 +39,44 @@ object FeederGenerator {
     return userArray.toArray
   }
 
+
+  /**
+   * Generate users forever
+   * @param radius
+   * @param centerLatitude
+   * @param centerLongitude
+   * @return
+   */
+  def generateUserWithGeolocationFeederInfinite(radius: Double, centerLatitude: Double, centerLongitude: Double): Iterator[Map[String, String]] = {
+
+//    val count: AtomicInteger = new AtomicInteger();
+    val userFeeder = Iterator.continually(generateUserData(UUID.randomUUID(), radius, centerLatitude, centerLongitude))
+
+    return userFeeder
+
+
+  }
+
+  /**
+   * Generate user data based on atomically increasing integers
+   * @param radius
+   * @param centerLatitude
+   * @param centerLongitude
+   * @return
+   */
+  def generateUserData(uuid: UUID, radius: Double, centerLatitude: Double, centerLongitude: Double): Map[String, String] = {
+
+
+    var user: Map[String, String] = EntityDataGenerator.generateUser(uuid.toString)
+    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/89c6857f/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 2385924..0e4ad9d 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
@@ -79,7 +79,10 @@ object NotificationScenarios {
      *
      */
 
+    //not sure we want to do this, but the feeder runs out otherwise. It doe
     .feed(userFeeder)
+    //create the user
+    .exec(UserScenarios.postUser)
     .exec(TokenScenarios.getUserToken)
     .exec( UserScenarios.getUserByUsername)
     .repeat(2){
@@ -91,9 +94,8 @@ object NotificationScenarios {
     // print the Session for debugging, don't do that on real Simulations
     println(session)
     session
-  }).forever(){
+  })
     exec( sendNotificationToUser)
-  }
 
   /**
    * TODO: Add posting to users, which would expect a user in the session

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/89c6857f/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 8ccb7db..8c22df9 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
@@ -57,10 +57,15 @@ object Settings {
 
   println(s"Will inject $maxPossibleUsers over $rampTime seconds at $maxPossibleUsers/$rampTime users per sec")
 
-  def getUserFeeder():Array[Map[String, String]]= {
-    val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(maxPossibleUsers, userLocationRadius, centerLatitude, centerLongitude)
-    return userFeeder
-  }
+//  def getUserFeeder():Array[Map[String, String]]= {
+//    val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(maxPossibleUsers, userLocationRadius, centerLatitude, centerLongitude)
+//    return userFeeder
+//  }
+
+  def getUserFeeder():Iterator[Map[String, String]]= {
+     val userFeeder = FeederGenerator.generateUserWithGeolocationFeederInfinite( userLocationRadius, centerLatitude, centerLongitude)
+     return userFeeder
+   }
 
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/89c6857f/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 0314f45..96bd0df 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,10 +33,10 @@ import scala.concurrent.duration._
  */
 class AppSimulation extends Simulation {
   println("Begin setup")
-  Setup.setupOrg()
-  Setup.setupApplication()
-  Setup.setupNotifier()
-  Setup.setupUsers()
+//  Setup.setupOrg()
+//  Setup.setupApplication()
+//  Setup.setupNotifier()
+//  Setup.setupUsers()
   println("End Setup")
 
   setUp(


[2/2] incubator-usergrid git commit: Updated the create simulation

Posted by to...@apache.org.
Updated the create simulation


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

Branch: refs/heads/toddtest
Commit: 4fd87decc8713749f91873715b0fa59e86195d56
Parents: 89c6857
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Nov 7 19:19:34 2014 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Nov 7 19:19:34 2014 -0700

----------------------------------------------------------------------
 .../scenarios/NotificationScenarios.scala       | 25 ++++----
 .../simulations/UserCreateGetSimulation.scala   | 60 ++++++++++++++++++++
 2 files changed, 73 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4fd87dec/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 0e4ad9d..9be7a4e 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
@@ -80,22 +80,23 @@ object NotificationScenarios {
      */
 
     //not sure we want to do this, but the feeder runs out otherwise. It doe
+    .exec(TokenScenarios.getManagementToken)
     .feed(userFeeder)
     //create the user
     .exec(UserScenarios.postUser)
-    .exec(TokenScenarios.getUserToken)
+//    .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)
+//    .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)
 
   /**
    * TODO: Add posting to users, which would expect a user in the session

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4fd87dec/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/UserCreateGetSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/UserCreateGetSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/UserCreateGetSimulation.scala
new file mode 100644
index 0000000..feea6ec
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/UserCreateGetSimulation.scala
@@ -0,0 +1,60 @@
+/*
+ *
+ *  * 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 io.gatling.core.scenario.Simulation
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.{UserScenarios, TokenScenarios, NotificationScenarios}
+import org.apache.usergrid.settings.Settings
+
+import scala.concurrent.duration._
+
+/**
+ * Classy class class.
+ */
+class UserCreateGetSimulation extends Simulation {
+  println("Begin setup")
+  Setup.setupOrg()
+  Setup.setupApplication()
+  println("End Setup")
+
+  val userFeeder = Settings.getUserFeeder
+  val createScenario = scenario("Create and Get users")
+
+    //get our management token, then feed forever
+      .exec(TokenScenarios.getManagementToken)
+      .feed(userFeeder)
+      //create the user
+      .exec(UserScenarios.postUser)
+      .exec( UserScenarios.getUserByUsername)
+
+  setUp(
+    createScenario
+      //inject all our users over the ramp time
+//      .inject(constantUsersPerSec(Settings.maxPossibleUsers) during (Settings.rampTime))
+      //ramp up to our max possible users over the ramp time.  We may not get there if we hit our max tps first
+      .inject(rampUsers(Settings.maxPossibleUsers) over  (Settings.rampTime))
+      //during the ramp time, try to hit our max TPS.  Then hold it for the duration of the test
+      .throttle(reachRps(Settings.throttle) in (Settings.rampTime.seconds), holdFor(Settings.duration))
+      .protocols(Settings.httpConf.acceptHeader("application/json"))
+  )
+}