usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [19/30] incubator-usergrid git commit: Adds put test to gatling
Date Mon, 09 Mar 2015 15:14:36 GMT
Adds put test to gatling


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

Branch: refs/heads/two-dot-o
Commit: b8f5bf6468f95fde810ebde8dc1e436db04cc2ce
Parents: ecc1dde
Author: Todd Nine <tnine@apigee.com>
Authored: Fri Mar 6 16:42:19 2015 -0700
Committer: Todd Nine <tnine@apigee.com>
Committed: Fri Mar 6 16:42:19 2015 -0700

----------------------------------------------------------------------
 .../datagenerators/EntityDataGenerator.scala    | 25 +++++++
 .../datagenerators/FeederGenerator.scala        | 18 ++++-
 .../usergrid/scenarios/EntityScenarios.scala    |  8 +--
 .../org/apache/usergrid/settings/Settings.scala |  4 +-
 .../simulations/PutCustomEntitySimulation.scala | 75 ++++++++++++++++++++
 5 files changed, 122 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b8f5bf64/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 daa54be..cb024d3 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
@@ -85,4 +85,29 @@
     return Map("entity" -> new JSONObject(entity).toString())
 
   }
+
+   def generateCustomEntityJSONString(): String = {
+
+      var entity: Map[String, String] = Map(
+        // "name" -> "fdsa",
+        "address" -> Utils.generateRandomInt(10000, 1000000).toString,
+        "city" -> Utils.generateRandomInt(10000, 1000000).toString,
+        "state" -> Utils.generateRandomInt(10000, 1000000).toString,
+        "zip" -> Utils.generateRandomInt(10000, 1000000).toString,
+        "phone" -> Utils.generateRandomInt(10000, 1000000).toString,
+        "businessname" -> Utils.generateRandomInt(0, 1).toString,
+        "menu" -> Utils.generateRandomInt(1, 1000000).toString,
+        "specials" -> Utils.generateRandomInt(1, 1000000).toString,
+        "profile" -> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.",
+        "description" -> "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat.",
+        "directions" -> Utils.generateRandomInt(18, 65).toString,
+        "atmosphere" -> Utils.generateRandomInt(48, 84).toString,
+        "bar" -> Utils.generateRandomInt(120, 350).toString,
+        "tables" -> Utils.generateRandomInt(50, 100000).toString,
+        "outdoor" -> Utils.generateRandomInt(50, 100000).toString
+        )
+
+     return new JSONObject(entity).toString();
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b8f5bf64/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 46dfdde..97be06a 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
@@ -155,8 +155,22 @@
      //val rod = "rod"
      val userFeeder = Iterator.from(seed).map(i=>EntityDataGenerator.generateCustomEntity())
      return userFeeder
-   } 
-   
+   }
+
+
+
+   /**
+    * Generate users forever
+    * @param seed The seed
+    * @return
+    */
+   def generateCustomEntityPutInfinite(seed:Int): Iterator[Map[String, Any]] = {
+     //val rod = "rod"
+     val userFeeder = Iterator.from(seed).map(i=>Map("entityName" -> i.toString.concat(UUID.randomUUID().toString),
"entity" -> EntityDataGenerator.generateCustomEntityJSONString()));
+     return userFeeder
+   }
+
+
    def testFeeder(seed:Int): Iterator[Map[String, String]] = {
      var entity: Map[String, String] = EntityDataGenerator.generateCustomEntity();
      Map("entity" -> entity)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b8f5bf64/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityScenarios.scala
b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityScenarios.scala
index 70d66fa..c3af32d 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityScenarios.scala
@@ -40,9 +40,9 @@ object EntityScenarios {
 
   val putEntity = exec(
     http("Put custom entity")
-      .put(Settings.baseAppUrl+"/${collectionType}/${entityName}")
-      .body(StringBody("{\"address\":\""+Utils.generateRandomInt(1, Settings.numEntities)+"\",\"phone\":\""+Utils.generateRandomInt(1,
Settings.numEntities)+"\"}}"))
-      .headers(Headers.jsonAuthorized)
+      .put(Settings.baseAppUrl+"/"+ Settings.collectionType+"/${entityName}")
+      .body(StringBody("""${entity}"""))
+      .headers(Headers.jsonAnonymous)
       .check(status.is(200))
   )
 
@@ -61,7 +61,7 @@ object EntityScenarios {
       .headers(Headers.jsonAnonymous)
       .check(status.is(200))
   )
-  
+
   val postEntityWithToken = exec(
     http("Post custom entity")
       .post(Settings.baseAppUrl+"/"+ Settings.collectionType)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b8f5bf64/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 949f65a..2619cad 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
@@ -44,8 +44,8 @@ object Settings {
 
   val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
   val numDevices:Int = Integer.getInteger("numDevices", 4000).toInt
-  
-  val collectionType:String = System.getProperty("collectionType")
+
+  val collectionType:String = System.getProperty("collectionType", "defaultthings")
 
   val rampTime:Int = Integer.getInteger("rampTime", 0).toInt // in seconds
   val throttle:Int = Integer.getInteger("throttle", 50).toInt // in seconds

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b8f5bf64/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutCustomEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutCustomEntitySimulation.scala
b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutCustomEntitySimulation.scala
new file mode 100644
index 0000000..2b129fc
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PutCustomEntitySimulation.scala
@@ -0,0 +1,75 @@
+/*
+ * 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 io.gatling.core.scenario.Simulation
+import org.apache.usergrid.datagenerators.FeederGenerator
+import org.apache.usergrid.scenarios.EntityScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * PostCustomEntitySimulation - creates lots of custom entities
+ *
+ * Run this way:
+ * mvn gatling:execute -DrampTime=10 -DmaxPossibleUsers=10 -Dduration=120 -Dorg=yourorgname
-Dapp=sandbox -Dbaseurl=https://api.usergrid.com -DadminUser=yourusername -DadminPassword='yourpassword'
-Dgatling.simulationClass=org.apache.usergrid.simulations.PostCustomEntitySimulation -DcollectionType=yourcollection
+ *
+ *
+ */
+class PutCustomEntitySimulation extends Simulation {
+
+  if(!Settings.skipSetup) {
+    println("Begin setup")
+    println("These aren't the droids you are looking for...")
+    //exec(TokenScenarios.getManagementToken)
+    println("End Setup")
+  }else{
+    println("Skipping Setup")
+  }
+
+  val numEntities:Int = Settings.numEntities
+  val collectionType = Settings.collectionType
+  println("collection type = " + collectionType)
+  val rampTime:Int = Settings.rampTime
+  val throttle:Int = Settings.throttle
+  val feeder = FeederGenerator.generateCustomEntityPutInfinite(0)
+  val httpConf = Settings.httpConf
+
+  val scnToRun = scenario("PUT custom entities")
+    .feed(feeder)
+    .exec(EntityScenarios.putEntity)
+
+  /*
+  val scnToRun = scenario("POST custom entities")
+    .feed(feeder)
+    .doIfOrElse(session => session("token").as[String].nonEmpty(session)) {
+      exec(EntityScenarios.postEntityWithToken)
+    } {
+      exec(EntityScenarios.postEntity)
+    }
+*/
+
+
+  setUp(scnToRun.inject(
+    rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
+    constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
+  ).protocols(httpConf)).maxDuration(Settings.duration)
+
+}


Mime
View raw message