updated engine - specify class to run, added custom entity 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/19179bc9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/19179bc9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/19179bc9 Branch: refs/heads/two-dot-o-events Commit: 19179bc95968e6f7644787c65c522aa6fbea34a4 Parents: fadee4a Author: Rod Simpson <[email protected]> Authored: Thu Nov 6 17:45:41 2014 -0700 Committer: Rod Simpson <[email protected]> Committed: Thu Nov 6 17:45:41 2014 -0700 ---------------------------------------------------------------------- .../datagenerators/EntityDataGenerator.scala | 21 +++++++ .../datagenerators/FeederGenerator.scala | 9 +++ .../usergrid/scenarios/EntityScenarios.scala | 65 ++++++++++++++++++++ .../PostCustomEntitySimulation.scala | 61 ++++++++++++++++++ stack/loadtests/src/test/scala/Engine.scala | 4 +- 5 files changed, 158 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19179bc9/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 6917930..2481737 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 @@ -59,4 +59,25 @@ object EntityDataGenerator { ) } + def generateCustomEntity(entityName: String): Map[String,String] = { + + return Map( + "name" -> entityName, + "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 + ) + } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19179bc9/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 03ba0f6..8832bd7 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 @@ -113,4 +113,13 @@ object FeederGenerator { } + def generateCustomEntityFeeder(numEntities: Int): Array[Map[String, String]] = { + var entityArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]] + for (entityCount <- 1 to numEntities) { + var entity: Map[String, String] = EntityDataGenerator.generateCustomEntity(entityCount.toString) + entityArray += entity + } + return entityArray.toArray + } + } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19179bc9/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 new file mode 100644 index 0000000..35b80d7 --- /dev/null +++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityScenarios.scala @@ -0,0 +1,65 @@ +/* + * 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.scenarios + +import io.gatling.core.Predef._ +import io.gatling.http.Predef._ +import org.apache.usergrid.datagenerators.{EntityDataGenerator, FeederGenerator} +import org.apache.usergrid.settings.{Headers, Utils, Settings} + +/** + * Provides CRUD methods for custom entities + * + * + * + */ +object EntityScenarios { + + val getEntity = exec( + http("GET custom entityr") + .get(Settings.baseUrl+"/${collectionType}/${entityName}") + .headers(Headers.jsonAuthorized) + .check(status.is(200)) + ) + + val putEntity = exec( + http("Put custom entity") + .put(Settings.baseUrl+"/${collectionType}/${entityName}") + .body(StringBody("{\"address\":\""+Utils.generateRandomInt(1, Settings.numEntities)+"\",\"phone\":\""+Utils.generateRandomInt(1, Settings.numEntities)+"\"}}")) + .headers(Headers.jsonAuthorized) + .check(status.is(200)) + ) + + + val deleteEntity = exec( + http("DELETE custom entityr") + .get(Settings.baseUrl+"/${collectionType}/${entityName}") + .headers(Headers.jsonAuthorized) + .check(status.is(200)) + ) + + val postEntity = exec( + http("Post custom entity") + //.post(Settings.baseUrl+"/${collectionType}") + .post(Settings.baseUrl+"/restaurants") + //.body(StringBody(EntityDataGenerator.generateCustomEntity("/${entityName}").toString())) + .body(StringBody("{\"property\":\"fred\"}")) + .headers(Headers.jsonAuthorized) + .check(status.is(200)) + ) + +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19179bc9/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostCustomEntitySimulation.scala ---------------------------------------------------------------------- diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostCustomEntitySimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostCustomEntitySimulation.scala new file mode 100644 index 0000000..f5523b1 --- /dev/null +++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostCustomEntitySimulation.scala @@ -0,0 +1,61 @@ +/* + * + * * 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.scenario.Simulation +import org.apache.usergrid.helpers.Setup +import org.apache.usergrid.scenarios.{EntityScenarios, TokenScenarios} +import java.nio.file.{Paths, Files} +import io.gatling.core.Predef._ +import org.apache.usergrid.datagenerators.FeederGenerator +import scala.concurrent.duration._ +import org.apache.usergrid.settings.{Headers, Settings} + +/** + * Classy class class. + */ +class PostCustomEntitySimulation extends Simulation { + + if(!Settings.skipSetup) { + println("Begin setup") + Setup.setupOrg() + Setup.setupApplication() + println("End Setup") + }else{ + println("Skipping Setup") + } + + val numEntities:Int = Settings.numEntities + val collectionType:String = "restaurants" + val rampTime:Int = Settings.rampTime + val throttle:Int = Settings.throttle + val feeder = FeederGenerator.generateCustomEntityFeeder(numEntities).queue + val httpConf = Settings.httpConf + + val scnToRun = scenario("POST custom entities") + .feed(feeder) + .exec(TokenScenarios.getManagementToken) + .exec(EntityScenarios.postEntity) + + setUp(scnToRun.inject(atOnceUsers(numEntities)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf)).maxDuration(Settings.duration) + +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/19179bc9/stack/loadtests/src/test/scala/Engine.scala ---------------------------------------------------------------------- diff --git a/stack/loadtests/src/test/scala/Engine.scala b/stack/loadtests/src/test/scala/Engine.scala index 543674a..48c93f8 100644 --- a/stack/loadtests/src/test/scala/Engine.scala +++ b/stack/loadtests/src/test/scala/Engine.scala @@ -25,8 +25,8 @@ object Engine extends App { props.resultsDirectory(IDEPathHelper.resultsDirectory.toString) props.requestBodiesDirectory(IDEPathHelper.requestBodiesDirectory.toString) props.binariesDirectory(IDEPathHelper.mavenBinariesDirectory.toString) - - props.simulationClass("org.apache.usergrid.simulations.AppSimulation") + val simName = if(System.getProperty("simulationClass")!=null) System.getProperty("simulationClass") else "AppSimulation"; + props.simulationClass("org.apache.usergrid.simulations."+simName) Gatling.fromMap(props.build) }
