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 2015/08/03 22:30:46 UTC
[02/21] incubator-usergrid git commit: USERGRID-871: refactor Gatling
load testing code
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/enums/AuthType.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/AuthType.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/AuthType.scala
new file mode 100644
index 0000000..2823d95
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/AuthType.scala
@@ -0,0 +1,10 @@
+package org.apache.usergrid.enums
+
+/**
+ * Created by mdunker on 7/20/15.
+ */
+object AuthType {
+ val Anonymous = "anonymous"
+ val Token = "token"
+ val Basic = "basic"
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ConfigProperties.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ConfigProperties.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ConfigProperties.scala
new file mode 100644
index 0000000..9a4989a
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ConfigProperties.scala
@@ -0,0 +1,47 @@
+package org.apache.usergrid.enums
+
+/**
+ * Created by mdunker on 7/20/15.
+ */
+object ConfigProperties {
+ val Org = "org"
+ val App = "app"
+ val AdminUser = "adminUser"
+ val AdminPassword = "adminPassword"
+ val BaseUrl = "baseurl"
+ val AuthType = "authType"
+ val TokenType = "tokenType"
+ val SkipSetup = "skipSetup"
+ val CreateOrg = "createOrg"
+ val CreateApp = "createApp"
+ val LoadEntities = "loadEntities"
+ val ScenarioType = "scenarioType"
+ val RampUsers = "rampUsers"
+ val ConstantUsersPerSec = "constantUsersPerSec"
+ val ConstantUsersDuration = "constantUsersDuration"
+ val UserSeed = "userSeed"
+ val AppUser = "appUser"
+ val AppUserPassword = "appUserPassword"
+ val NumEntities = "numEntities"
+ val NumDevices = "numDevices"
+ val CollectionType = "collectionType"
+ val RampTime = "rampTime"
+ val Throttle = "throttle"
+ val RpsTarget = "rpsTarget"
+ val RpsRampTime = "rpsRampTime"
+ val HoldDuration = "holdDuration"
+ val PushNotifier = "pushNotifier"
+ val PushProvider = "pushProvider"
+ val EntityPrefix = "entityPrefix"
+ val EntityType = "entityType"
+ val EntitySeed = "entitySeed"
+ val SearchLimit = "searchLimit"
+ val SearchQuery = "searchQuery"
+ val EndConditionType = "endConditionType"
+ val EndMinutes = "endMinutes"
+ val EndRequestCount = "endRequestCount"
+ val Values = Seq(Org,App,AdminUser,AdminPassword,BaseUrl,AuthType,TokenType,SkipSetup,CreateOrg,CreateApp,LoadEntities,
+ ScenarioType,RampUsers,ConstantUsersPerSec,ConstantUsersDuration,UserSeed,AppUser,AppUserPassword,NumEntities,
+ NumDevices,CollectionType,RampTime,Throttle,RpsTarget,RpsRampTime,HoldDuration,PushNotifier,EntityPrefix,EntityType,
+ EntitySeed,SearchLimit,SearchQuery,EndConditionType,EndMinutes,EndRequestCount)
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EndConditionType.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EndConditionType.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EndConditionType.scala
new file mode 100644
index 0000000..4bbb9cc
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EndConditionType.scala
@@ -0,0 +1,9 @@
+package org.apache.usergrid.enums
+
+/**
+ * Created by mdunker on 7/21/15.
+ */
+object EndConditionType {
+ val MinutesElapsed = "minutesElapsed"
+ val RequestCount = "requestCount"
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EntityType.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EntityType.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EntityType.scala
new file mode 100644
index 0000000..d17d280
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EntityType.scala
@@ -0,0 +1,9 @@
+package org.apache.usergrid.enums
+
+/**
+ * Created by mdunker on 7/20/15.
+ */
+object EntityType {
+ val Trivial = "trivial"
+ val Basic = "basic"
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ScenarioType.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ScenarioType.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ScenarioType.scala
new file mode 100644
index 0000000..52fcbc5
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ScenarioType.scala
@@ -0,0 +1,9 @@
+package org.apache.usergrid.enums
+
+/**
+ * Created by mdunker on 7/20/15.
+ */
+object ScenarioType {
+ val GetAllByCursor = "getAllByCursor"
+ val NameRandomInfinite = "nameRandomInfinite"
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/enums/TokenType.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/TokenType.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/TokenType.scala
new file mode 100644
index 0000000..4d371e1
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/TokenType.scala
@@ -0,0 +1,10 @@
+package org.apache.usergrid.enums
+
+/**
+ * Created by mdunker on 7/20/15.
+ */
+object TokenType {
+ val None = "none"
+ val User = "user"
+ val Management = "management"
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
index aa8c614..8de995e 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Extractors.scala
@@ -22,6 +22,8 @@ package org.apache.usergrid.helpers
import io.gatling.core.Predef._
import io.gatling.core.session._
import io.gatling.http.Predef._
+import org.apache.usergrid.enums._
+import org.apache.usergrid.settings.Settings
/**
* Helper object that will perform extractions
@@ -38,7 +40,6 @@ object Extractors {
}).saveAs(saveAsName)
}
-
/**
* tries to extract the cursor from the session, if it exists, it returns true. if it's the default, returns false
* @param nameInSession The name of the variable in the session
@@ -54,7 +55,7 @@ object Extractors {
*/
def maybeExtractEntities(saveAsName: String) = {
jsonPath("$..entities").ofType[Seq[Any]].transformOption(extract => {
- extract.orElse(Some(Seq()));
+ extract.orElse(Some(Seq()))
}).saveAs(saveAsName)
}
@@ -64,21 +65,69 @@ object Extractors {
* @return
*/
def sequenceHasElements(nameInSession: String): Expression[Boolean] = {
- session => session(nameInSession) != null && session(nameInSession).as[Seq[Any]].length > 0
+ session => session(nameInSession) != null && session(nameInSession).as[Seq[Any]].nonEmpty
}
-
- val ManagementToken: String = Setup.getManagementToken()
-
-
/**
* Get the management token for the admin username and password in settings, then inject it into the session
* under the variable "authToken"
* @return
*/
- def injectStaticTokenToSession(): Expression[Session] = {
- session => session.set("authToken", ManagementToken)
+ def injectManagementTokenIntoSession(): Expression[Session] = {
+ session => session.set("authToken", Setup.getManagementToken())
+ }
+
+ def injectUserTokenIntoSession(): Expression[Session] = {
+ session => session.set("authToken", Setup.getUserToken)
+ }
+
+ // handles different types of tokens
+ def injectTokenIntoSession(): Expression[Session] = {
+ session => session.set("authToken", Setup.getToken())
+ }
+
+ def injectAnonymousAuth(): Expression[Session] = {
+ session => session.set("authType", AuthType.Anonymous)
}
+ def injectBasicAuth(): Expression[Session] = {
+ session => session.set("authType", AuthType.Basic)
+ }
+
+ def injectTokenAuth(): Expression[Session] = {
+ session => session.set("authType", AuthType.Token)
+ }
+
+ // handles different types of auth
+ def injectAuthType(): Expression[Session] = {
+ session => session.set("authType", Settings.authType)
+ }
+
+ /*
+ def injectTokenToSession(authType: String, tokenType: String): Expression[Session] = {
+ session => {
+ if (authType == AuthType.Token && tokenType == TokenType.User) {
+ session.set("authToken", Setup.getUserToken)
+ } else if (authType == AuthType.Token && tokenType == TokenType.Management) {
+ session.set("authToken", Setup.getManagementToken())
+ } else {
+ session.set("authToken", "")
+ }
+ }
+ }
+
+ def injectAuth(authType: String, tokenType: String): Expression[Session] = {
+ session => {
+ if (authType == AuthType.Token && tokenType == TokenType.User) {
+ session.set("authToken", Setup.getUserToken)
+ } else if (authType == AuthType.Token && tokenType == TokenType.Management) {
+ session.set("authToken", Setup.getManagementToken())
+ } else {
+ session.set("authToken", "")
+ }
+ session.set("authType", authType)
+ }
+ }
+ */
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
index fb0bcde..776e0b9 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Setup.scala
@@ -29,111 +29,134 @@ import io.gatling.http.Predef._
import io.gatling.http.request.StringBody
import io.gatling.jsonpath.JsonPath
import org.apache.usergrid.datagenerators.FeederGenerator
+import org.apache.usergrid.enums.TokenType
import org.apache.usergrid.settings.{Settings, Headers}
import scala.collection.mutable.ArrayBuffer
+import scala.util.parsing.json.JSONObject
/**
* Classy class class.
*/
object Setup {
- var token:String = null
+ var managementToken:String = null
val client = new AsyncHttpClient()
+ def getToken(tokenUrl:String, username:String, password:String):String = {
+ val getToken = client
+ .preparePost(tokenUrl)
+ .setBody("{\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"grant_type\":\"password\"}")
+ .setHeader("Cache-Control", "no-cache")
+ .setHeader("Content-Type", "application/json; charset=UTF-8")
+ .build()
+ val response = client.executeRequest(getToken).get()
+ val mapper = new ObjectMapper()
+ val tree = mapper.readTree(response.getResponseBody)
+ tree.get("access_token").asText()
+ }
+
+ def getManagementToken():String = {
+ if(managementToken == null) {
+ managementToken = getToken(Settings.baseUrl + "/management/token", Settings.adminUser, Settings.adminPassword)
+ println("Management token is "+managementToken)
+ }
+ managementToken
+ }
+
+ def getUserToken:String = {
+ getToken(Settings.baseAppUrl + "/token", Settings.appUser, Settings.appUserPassword)
+ }
+
+ def getToken():String = {
+ var token = ""
+ if (Settings.tokenType == TokenType.Management) token = getManagementToken()
+ if (Settings.tokenType == TokenType.User) token = getUserToken
+
+ token
+ }
+
def setupOrg(): Integer = {
val createOrgPost = client
.preparePost(Settings.baseUrl + "/management/organizations")
- .setHeader("Cache-Control", "no-cache")
+ .setHeader("Cache-Control", "no-cache")
.setHeader("Content-Type", "application/json; charset=UTF-8")
- .setBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"" + Settings.admin + "\",\"name\":\"" + Settings.admin + "\",\"email\":\"" + Settings.admin + "@apigee.com\",\"password\":\"" + Settings.password + "\"}")
- .build()
+ .setBody(Utils.toJSONStr(Map(
+ "organization" -> Settings.org,
+ "username" -> Settings.adminUser,
+ "name" -> Settings.adminUser,
+ "email" -> (Settings.adminUser + "@apigee.com"),
+ "password" -> Settings.adminPassword
+ )))
+ .build()
+
val orgResponse = client.executeRequest(createOrgPost).get()
- printResponse("POST ORG",orgResponse.getStatusCode,orgResponse.getResponseBody())
- return orgResponse.getStatusCode
+
+ printResponse("POST ORG",orgResponse.getStatusCode,orgResponse.getResponseBody)
+
+ orgResponse.getStatusCode
}
- def setupApplication():Integer = {
- val authToken = getManagementToken()
+ def setupApplication(): Integer = {
+
val createAppPost = client
- .preparePost(Settings.baseUrl + "/management/organizations/"+Settings.org+"/applications")
- .setBody("{\"name\":\"" + Settings.app + "\"}")
+ .preparePost(Settings.baseUrl + "/management/organizations/" + Settings.org + "/applications")
+ .setBody(Utils.toJSONStr(Map("name" -> Settings.app)))
.setHeader("Cache-Control", "no-cache")
.setHeader("Content-Type", "application/json; charset=UTF-8")
- .setHeader("Authorization","Bearer "+authToken)
+ .setHeader("Authorization", "Bearer " + getManagementToken)
.build()
val appResponse = client.executeRequest(createAppPost).get();
- printResponse("POST Application",appResponse.getStatusCode, appResponse.getResponseBody())
- return appResponse.getStatusCode
+ val statusCode = appResponse.getStatusCode
+ printResponse("POST APP",statusCode, appResponse.getResponseBody)
+
+ statusCode
}
def setupNotifier():Integer = {
- val authToken = getManagementToken()
val createNotifier = client
.preparePost(Settings.baseAppUrl + "/notifiers")
- .setBody("{\"name\":\"" + Settings.pushNotifier + "\",\"provider\":\"" + Settings.pushProvider + "\"}")
+ .setBody(Utils.toJSONStr(Map("name" -> Settings.pushNotifier, "provider" -> Settings.pushProvider)))
.setHeader("Cache-Control", "no-cache")
.setHeader("Content-Type", "application/json; charset=UTF-8")
- .setHeader("Authorization","Bearer "+authToken)
+ .setHeader("Authorization","Bearer " + getManagementToken)
.build()
val notifierResponse = client.executeRequest(createNotifier).get();
printResponse("POST Notifier", notifierResponse.getStatusCode ,notifierResponse.getResponseBody())
- return notifierResponse.getStatusCode
- }
-
- def getManagementToken():String = {
- if(token == null) {
- val getToken = client
- .preparePost(Settings.baseUrl + "/management/token")
- .setBody("{\"username\":\"" + Settings.admin + "\",\"password\":\"" + Settings.password + "\",\"grant_type\":\"password\"}")
- .setHeader("Cache-Control", "no-cache")
- .setHeader("Content-Type", "application/json; charset=UTF-8")
- .build()
- val response = client.executeRequest(getToken).get()
- val omapper = new ObjectMapper();
- val tree = omapper.readTree(response.getResponseBody())
- val node = tree.get("access_token");
- token = node.asText()
- println("Token is "+token)
- }
- return token
+ notifierResponse.getStatusCode
}
def setupUsers() = {
- if (!Settings.skipSetup) {
- val userFeeder = Settings.getUserFeeder()
- val numUsers = userFeeder.length
- println(s"setupUsers: Sending requests for $numUsers users")
-
- val list: ArrayBuffer[ListenableFuture[Response]] = new ArrayBuffer[ListenableFuture[Response]]
- var successCount: Int = 0;
- def purgeList = {
- list.foreach(f => {
- val response = f.get()
- if (response.getStatusCode != 200) {
- printResponse("Post User", response.getStatusCode, response.getResponseBody())
- } else {
- successCount += 1
- }
- })
- list.clear()
- }
- userFeeder.foreach(user => {
- list += setupUser(user);
- if(list.length == Integer.getInteger("purgeUsers",100)){
- purgeList
+ val userFeeder = Settings.getUserFeeder()
+ val numUsers = userFeeder.length
+ println(s"setupUsers: Sending requests for $numUsers users")
+
+ val list: ArrayBuffer[ListenableFuture[Response]] = new ArrayBuffer[ListenableFuture[Response]]
+ var successCount: Int = 0
+ def purgeList() = {
+ list.foreach(f => {
+ val response = f.get()
+ if (response.getStatusCode != 200) {
+ printResponse("Post User", response.getStatusCode, response.getResponseBody())
+ } else {
+ successCount += 1
}
- });
-
- println(s"setupUsers: Received $successCount successful responses out of $numUsers requests.")
- } else {
- println("Skipping Adding Users due to skipSetup=true")
+ })
+ list.clear()
}
+ userFeeder.foreach(user => {
+ list += setupUser(user)
+ if (list.length == Integer.getInteger("purgeUsers",100)) {
+ purgeList()
+ }
+ })
+
+ println(s"setupUsers: Received $successCount successful responses out of $numUsers requests.")
}
def setupUser(user:Map[String,String]):ListenableFuture[Response] = {
@@ -165,14 +188,56 @@ object Setup {
.setHeader("Authorization","Bearer "+authToken)
.build()
- return client.executeRequest(createUser)
+ client.executeRequest(createUser)
+ }
+ def setupEntitiesCollection(numEntities: Int, entityType: String, prefix: String, seed: Int = 1) = {
+ val entitiesFeeder = FeederGenerator.generateCustomEntityFeeder(numEntities, entityType, prefix, seed)
+ val purgeUsers = Integer.getInteger("purgeUsers", 100)
+
+ val list: ArrayBuffer[ListenableFuture[Response]] = new ArrayBuffer[ListenableFuture[Response]]
+ var successCount: Int = 0;
+ def purgeList(): Unit = {
+ list.foreach(f => {
+ val response = f.get()
+ if (response.getStatusCode != 200) {
+ printResponse("Post Entity", response.getStatusCode, response.getResponseBody)
+ } else {
+ successCount += 1
+ }
+ })
+ list.clear()
+ }
+ entitiesFeeder.foreach(payload => {
+ //println("setupEntitiesCollection: payload=" + payload)
+ list += setupEntity(payload)
+ if(list.length == purgeUsers) {
+ purgeList()
+ }
+ })
+
+ // purgeList()
+
+ println(s"setupEntitiesCollection: Received $successCount successful responses out of $numEntities requests.")
+ }
+
+ def setupEntity(payload: String):ListenableFuture[Response] = {
+ val authToken = getManagementToken()
+ val createEntity = client
+ .preparePost(Settings.baseAppUrl + "/" + Settings.collectionType)
+ .setBody(payload)
+ .setBodyEncoding("UTF-8")
+ .setHeader("Authorization", "Bearer " + authToken)
+ .setHeader("Content-Type", "application/json; charset=UTF-8")
+ .build()
+ //println("setupEntity: baseAppUrl=" + Settings.baseAppUrl + ", collectionType=" + Settings.collectionType + ", payload=" + payload)
+
+ client.executeRequest(createEntity)
}
def printResponse(caller:String, status:Int, body:String) = {
println(caller + ": status: "+status.toString+" body:"+body)
-
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Utils.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Utils.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Utils.scala
new file mode 100755
index 0000000..82061d6
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Utils.scala
@@ -0,0 +1,100 @@
+/*
+ * 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.helpers
+
+import scala.util.Random
+import scala.util.parsing.json.JSONObject
+
+ /**
+ *
+ * Utility for creating various data elements
+ *
+ */
+object Utils {
+
+ private val RNG = new Random(System.currentTimeMillis())
+
+ /**
+ * Generate a new uuid and replace the '-' with empty
+ */
+ def generateUUIDString(): String = {
+ java.util.UUID.randomUUID.toString.replace("-", "")
+ }
+
+ /**
+ * Generate a unique string with a prefix
+ *
+ * @param prefix
+ * @return
+ */
+ def generateUniqueName(prefix : String): String = {
+ prefix + generateUUIDString()
+ }
+
+ // random number in between [a...b]
+ def generateRandomInt(lowerBound: Int, upperBound: Int) = RNG.nextInt(upperBound - lowerBound) + lowerBound
+
+ def generateRandomGeolocation(radius: Double, centerLatitude: Double, centerLongitude: Double):Map[String, String] = {
+
+ val rd = radius / 111300 // Convert Radius from meters to degrees.
+ val u = RNG.nextFloat()
+ val v = RNG.nextFloat()
+ val q = math.sqrt(u) * rd
+ val w = q * rd
+ val t = 2 * math.Pi * v
+ val x = math.cos(t) * w
+ val y = math.sin(t) * w
+ val xp = x/math.cos(centerLatitude)
+ val latitude = (y + centerLatitude).toString
+ val longitude = (xp + centerLongitude).toString
+ val geolocation: Map[String, String] = Map("latitude"->latitude,"longitude"->longitude)
+
+ geolocation
+ }
+
+ def generateRandomQueryString: String = {
+
+ val queryParams = Array("age", "height", "weight")
+ var queryString = ""
+
+ for (numParams <- 1 to generateRandomInt(1, queryParams.length)) {
+ queryString = "age=" + Utils.generateRandomInt(18, 65).toString
+ if (numParams == 2) {
+ queryString += "%20AND%20height=" + Utils.generateRandomInt(48, 84).toString
+ } else if (numParams == 3) {
+ queryString += "%20AND%20weight=" + Utils.generateRandomInt(120, 350).toString
+ }
+ }
+
+ queryString
+ }
+
+ def randomEntityNameUrl(prefix: String, numEntities: Int, seed: Int, baseUrl: String): String = {
+ val randomVal = generateRandomInt(seed, seed+numEntities-1)
+
+ baseUrl + "/" + prefix.concat(randomVal.toString)
+ }
+
+ def createRandomPushNotifierName:String = {
+ Utils.generateUniqueName("notifier")
+ }
+
+ def toJSONStr(objectMap: Map[String, Any]):String = {
+ JSONObject(objectMap).toString()
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
index 8faf8c7..4150513 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
@@ -37,7 +37,7 @@ object ApplicationScenarios {
val createApplication = exec(http("Create Application")
.post(Settings.baseUrl + "/management/organizations/"+Settings.org+"/applications")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.body(StringBody("{\"name\":\"" + Settings.app + "\"}"))
.check(status.in(200 to 204))
@@ -45,7 +45,7 @@ object ApplicationScenarios {
val checkApplication = exec(http("Get Application")
.get(Settings.baseAppUrl)
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.saveAs("applicationStatus"))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
index 07e11fe..b2827bb 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
@@ -26,7 +26,7 @@ import io.gatling.http.Predef._
val postUserConnection = exec(
http("POST connection")
.post("/users/${user1}/likes/users/${user2}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
@@ -34,14 +34,14 @@ import io.gatling.http.Predef._
val postUserToDeviceConnection = exec(
http("Connect user with device")
.post("/users/${username}/devices/${deviceId}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
val postConnection = exec(
http("Connect user with device")
.post("/${connectionName}/${entityId}/${connectionType}/${entityId}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
index 4abd8cb..a8a3d9c 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
@@ -46,7 +46,7 @@ object DeviceScenarios {
*/
val postDeviceWithNotifier = exec(http("Create device with notifier")
.post("/devices")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.body(StringBody("""{"deviceModel":"Fake Device",
"deviceOSVerion":"Negative Version",
"""" + notifier + """.notifier.id":"${entityName}"}"""))
@@ -55,7 +55,7 @@ object DeviceScenarios {
val postDeviceWithNotifier400ok = exec(http("Create device with notifier")
.post("/devices")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.body(StringBody("""{"name":"${entityName}",
"deviceModel":"Fake Device",
"deviceOSVerion":"Negative Version",
@@ -70,7 +70,7 @@ object DeviceScenarios {
//try to do a GET on device name, if it 404's create it
http("Check and create device")
.get("/users/${username}/devices")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(jsonPath("$.entities").exists, jsonPath("$.entities").saveAs("devices"))
)
.exec(session =>{
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
new file mode 100644
index 0000000..844eb82
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
@@ -0,0 +1,131 @@
+/*
+ * 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.enums.{EndConditionType, AuthType}
+import org.apache.usergrid.helpers.Extractors._
+import org.apache.usergrid.helpers.Utils
+import org.apache.usergrid.settings.{Headers, Settings}
+
+/**
+ * Provides CRUD methods for custom entities
+ *
+ *
+ *
+ */
+object EntityCollectionScenarios {
+
+ //The value for the cursor
+ val SessionVarCursor: String = "cursor"
+
+ def entityGetUrl(useCursor: Boolean): String = {
+ val url = Settings.baseAppUrl + "/" + Settings.collectionType + "?dummy" +
+ (if (useCursor) "&cursor=${" + SessionVarCursor + "}" else "") +
+ (if (Settings.searchLimit > 0) "&limit=" + Settings.searchLimit.toString() else "") +
+ (if (Settings.searchQuery != "") "&ql=" + Settings.searchQuery else "")
+
+ url
+ }
+
+ def entityGetByNameUrl(entityName: String): String = {
+ val url = Settings.baseCollectionUrl + "/" + entityName
+
+ url
+ }
+
+ def randomEntityNameUrl(prefix: String = Settings.entityPrefix, numEntities: Int = Settings.numEntities, seed: Int = Settings.entitySeed): String = {
+ Utils.randomEntityNameUrl(prefix, numEntities, seed, Settings.baseCollectionUrl)
+ }
+
+ val getEntitiesWithoutCursor = exec(
+ http("GET entities")
+ .get(entityGetUrl(false))
+ .headers(Headers.authToken)
+ .check(status.is(200), maybeExtractCursor(SessionVarCursor))
+ )
+
+ val getEntitiesWithCursor = exec(
+ http("GET entities")
+ .get(entityGetUrl(true))
+ .headers(Headers.authToken)
+ .check(status.is(200), maybeExtractCursor(SessionVarCursor))
+ )
+
+ val getEntityPagesToEnd = scenario("Get all entities")
+ .exec(injectTokenIntoSession())
+ .exec(injectAuthType())
+ .doIfOrElse(session => Settings.endConditionType == EndConditionType.MinutesElapsed) {
+ asLongAs(session => (System.currentTimeMillis() - Settings.testStartTime) < Settings.endMinutes*60*1000,"loopCounter",true) {
+ exec(getEntitiesWithoutCursor)
+ .asLongAs(stringParamExists(SessionVarCursor)) {
+ exec(getEntitiesWithCursor)
+ }
+ }
+ } {
+ repeat(Settings.endRequestCount) {
+ exec(getEntitiesWithoutCursor)
+ .asLongAs(stringParamExists(SessionVarCursor)) {
+ exec(getEntitiesWithCursor)
+ }
+ }
+ }
+ //.exec(sessionFunction => { sessionFunction })
+
+ val getRandomEntityAnonymous = exec(
+ http("GET entity by name (anonymous)")
+ .get(_ => randomEntityNameUrl())
+ .headers(Headers.authAnonymous)
+ .check(status.is(200))
+ )
+
+ val getRandomEntityWithToken = exec(
+ http("GET entity by name (token)")
+ .get(_ => randomEntityNameUrl())
+ .headers(Headers.authToken)
+ .check(status.is(200))
+ )
+
+ val getRandomEntitiesByName = scenario("Get entities by name randomly")
+ .exec(injectTokenIntoSession())
+ .exec(injectAuthType())
+ .doIfOrElse(session => Settings.endConditionType == EndConditionType.MinutesElapsed) {
+ asLongAs(session => (System.currentTimeMillis() - Settings.testStartTime) < Settings.endMinutes*60*1000) {
+ doIfOrElse(session => Settings.authType == AuthType.Anonymous) {
+ exec(getRandomEntityAnonymous)
+ } {
+ exec(getRandomEntityWithToken)
+ }
+ }
+ } {
+ repeat(Settings.endRequestCount) {
+ doIfOrElse(session => Settings.authType == AuthType.Anonymous) {
+ exec(getRandomEntityAnonymous)
+ } {
+ exec(getRandomEntityWithToken)
+ }
+ }
+ }
+
+ /*
+ val createEntityBatchScenario = scenario("Create custom entities")
+ .exec(injectStaticTokenToSession())
+ .feed(FeederGenerator.generateCustomEntityCreateFeeder(Settings.entityPrefix, Settings.numEntities))
+ .exec(EntityScenarios.postEntity)
+ */
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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 c3af32d..dd21e3c 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
@@ -19,55 +19,65 @@ 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}
+import org.apache.usergrid.helpers.{Extractors,Utils}
+import org.apache.usergrid.settings.{Headers, Settings}
import scala.util.parsing.json.JSONObject
/**
* Provides CRUD methods for custom entities
- *
- *
- *
*/
+
object EntityScenarios {
val getEntity = exec(
http("GET custom entity")
.get(Settings.baseAppUrl+"/${collectionType}/${entityName}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authAnonymous)
.check(status.is(200))
)
+ // not sure why I have to put stringToExpression -- thought String -> Expression[String] conversion would be automatic
val putEntity = exec(
http("Put custom entity")
- .put(Settings.baseAppUrl+"/"+ Settings.collectionType+"/${entityName}")
+ .put(stringToExpression(Settings.baseAppUrl + "/${collectionType}/${entityName}"))
.body(StringBody("""${entity}"""))
- .headers(Headers.jsonAnonymous)
+ .headers(Headers.auth("${authType}"))
.check(status.is(200))
)
val deleteEntity = exec(
http("DELETE custom entity")
- .get(Settings.baseAppUrl+"/${collectionType}/${entityName}")
- .headers(Headers.jsonAuthorized)
+ .get(Settings.baseAppUrl + "/${collectionType}/${entityName}")
+ .headers(Headers.auth("${authType}"))
.check(status.is(200))
)
val postEntity = exec(
http("Post custom entity")
- .post(Settings.baseAppUrl+"/"+ Settings.collectionType)
+ .post(stringToExpression(Settings.baseAppUrl + "/${collectionType}"))
.body(StringBody("""${entity}"""))
- .headers(Headers.jsonAnonymous)
+ .headers(Headers.auth("${authType}"))
.check(status.is(200))
)
+ /*
val postEntityWithToken = exec(
http("Post custom entity")
- .post(Settings.baseAppUrl+"/"+ Settings.collectionType)
+ .post(stringToExpression(Settings.baseAppUrl + "/${collectionType}"))
+ .body(StringBody("""${entity}"""))
+ .headers(Headers.authToken)
+ .check(status.is(200))
+ )
+
+ val postEntityWithBasicAuth = exec(
+ http("Post custom entity")
+ .post(stringToExpression(Settings.baseAppUrl + "/${collectionType}"))
.body(StringBody("""${entity}"""))
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authBasic)
.check(status.is(200))
)
+ */
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
index d5ce7c7..85c6855 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
@@ -18,30 +18,31 @@
import io.gatling.core.Predef._
import io.gatling.http.Predef._
- import org.apache.usergrid.settings.{Headers, Utils, Settings}
+import org.apache.usergrid.helpers.Utils
+import org.apache.usergrid.settings.{Headers, Settings}
- object GeoScenarios {
+object GeoScenarios {
val getGeolocation = exec(
http("GET geolocated user")
- .get("/users?ql=location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
- .headers(Headers.jsonAuthorized)
+ .get("/users?ql=location%20within%20" + Settings.geoSearchRadius + "%20of%20${latitude},${longitude}")
+ .headers(Headers.authToken)
.check(status.is(200))
)
val getGeolocationWithQuery = exec(
http("GET geolocated user with query")
- .get("/users?ql=${queryParams}%20AND%20location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
- .headers(Headers.jsonAuthorized)
+ .get("/users?ql=${queryParams}%20AND%20location%20within%20" + Settings.geoSearchRadius + "%20of%20${latitude},${longitude}")
+ .headers(Headers.authToken)
.check(status.is(200))
)
val updateGeolocation = exec(
http("PUT user location")
- .put("/users/user" + Utils.generateRandomInt(1, Settings.numUsers))
+ .put(stringToExpression("/users/user" + Utils.generateRandomInt(1, Settings.totalUsers)))
.body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"}}"))
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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 61b2605..92998d0 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
@@ -28,6 +28,7 @@ import scala.io.Source
import org.apache.usergrid.settings.{Headers, Settings}
+
/**
*
* Creates a new device
@@ -56,14 +57,14 @@ object NotificationScenarios {
val sendNotification = exec(http("Send Single Notification")
.post("/devices/${entityName}/notifications")
.body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
val sendNotificationToUser= exec(http("Send Notification to All Devices")
.post("/users/${userId}/notifications")
.body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
index 55c3d52..b2e32e5 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
@@ -38,7 +38,7 @@ import io.gatling.http.Predef._
*
*/
object NotifierScenarios {
-
+
val notifier = Settings.pushNotifier
val provider = Settings.pushProvider
val org = Settings.org
@@ -56,13 +56,13 @@ object NotifierScenarios {
.exec(http("Create Notifier")
.post(Settings.baseAppUrl+"/notifiers")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.body(StringBody("{\"name\":\"" + notifier + "\",\"provider\":\"" + provider + "\"}"))
.check(status.in(200 to 400)))
val checkNotifier = exec(http("Get Notifier")
.get(Settings.baseAppUrl+"/notifiers/"+notifier)
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200),status.saveAs("notifierStatus"))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
index 873759b..1cdc25c 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
@@ -38,8 +38,8 @@ object OrganizationScenarios {
val createOrgAndAdmin =
exec(http("Create Organization")
.post(Settings.baseUrl + "/management/organizations")
- .headers(Headers.jsonAnonymous)
- .body(StringBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"" + Settings.admin + "\",\"name\":\"${entityName}\",\"email\":\"${entityName}@apigee.com\",\"password\":\"" + Settings.password + "\"}"))
+ .headers(Headers.authAnonymous)
+ .body(StringBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"" + Settings.adminUser + "\",\"name\":\"${entityName}\",\"email\":\"${entityName}@apigee.com\",\"password\":\"" + Settings.adminPassword + "\"}"))
.check(status.in(200 to 400))
)
val createOrgBatch =
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
index 73ba3a9..4385797 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
@@ -41,9 +41,9 @@ import io.gatling.core.Predef._
object TokenScenarios {
val getManagementToken = exec(http("POST Org Token")
.post(Settings.baseUrl+"/management/token")
- .headers(Headers.jsonAnonymous)
+ .headers(Headers.authAnonymous)
//pass in the the username and password, store the "access_token" json response element as the var "authToken" in the session
- .body(StringBody("{\"username\":\"" + Settings.admin + "\",\"password\":\""+Settings.password+"\",\"grant_type\":\"password\"}"))
+ .body(StringBody("{\"username\":\"" + Settings.adminUser + "\",\"password\":\""+Settings.adminPassword+"\",\"grant_type\":\"password\"}"))
.check(jsonPath("$.access_token").find(0).saveAs("authToken"))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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 c589365..a55f66a 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
@@ -21,8 +21,9 @@ import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.http.request.StringBody
import org.apache.usergrid.datagenerators.FeederGenerator
-import org.apache.usergrid.settings.{Headers, Settings, Utils}
+import org.apache.usergrid.settings.{Headers, Settings}
import org.apache.usergrid.helpers.Extractors._
+import org.apache.usergrid.helpers.Utils
object UserScenarios {
@@ -46,7 +47,7 @@ object UserScenarios {
val getRandomUser = exec(
http("GET user")
.get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200))
)
@@ -54,7 +55,7 @@ object UserScenarios {
val getUserByUsername = exec(
http("GET user")
.get("/users/${username}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.saveAs(SessionVarUserStatus), jsonPath("$..entities[0]").exists, jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
)
@@ -85,11 +86,11 @@ object UserScenarios {
exec(postUser)
}
-
+
val putUser = exec(
http("PUT geolocated Users")
.put("/users/${username}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.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}",
@@ -97,12 +98,12 @@ object UserScenarios {
.check(status.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
)
-
+
val deleteUser = exec(
http("DELETE geolocated Users")
.delete("/users/${username}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.in(Seq(200,404)))
)
@@ -118,7 +119,7 @@ object UserScenarios {
val getUsersWithoutCursor = exec(
http("GET user")
.get("/users")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200), maybeExtractEntities(SessionVarUsers), maybeExtractCursor(SessionVarCursor))
)
@@ -129,7 +130,7 @@ object UserScenarios {
val getUsersWithCursor = exec(
http("GET user")
.get("/users?cursor=${" + SessionVarCursor + "}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200), maybeExtractEntities(SessionVarUsers), maybeExtractCursor(SessionVarCursor))
) /**
* Debugging block
@@ -146,7 +147,7 @@ object UserScenarios {
val deleteUserByUsername = exec(
http("DELETE user")
.delete("/users/${username}")
- .headers(Headers.jsonAuthorized)
+ .headers(Headers.authToken)
.check(status.is(200), jsonPath("$..entities[0].uuid").saveAs(SessionVarUserId))
)
@@ -176,21 +177,21 @@ object UserScenarios {
/**
* Puts a new user every time
*/
- val putUsersInfinitely = scenario("Put Users").exec(injectStaticTokenToSession)
+ val putUsersInfinitely = scenario("Put Users").exec(injectManagementTokenIntoSession)
.feed(Settings.getInfiniteUserFeeder())
.exec(putUser)
/**
* Deletes user every time
*/
- val deleteUsersInfinitely = scenario("Delete Users").exec(injectStaticTokenToSession)
+ val deleteUsersInfinitely = scenario("Delete Users").exec(injectManagementTokenIntoSession)
.feed(Settings.getInfiniteUserFeeder())
.exec(deleteUser)
/**
* Get the users a page at a time until exhausted
*/
- val getUserPagesToEnd = scenario("Get User Pages").exec(injectStaticTokenToSession)
+ val getUserPagesToEnd = scenario("Get User Pages").exec(injectManagementTokenIntoSession)
//get users without a cursor
.exec(getUsersWithoutCursor)
//as long as we have a cursor, keep getting results
@@ -200,7 +201,7 @@ object UserScenarios {
sessionFunction
})
- val getUsersByUsername = scenario("Get User By Username").exec(injectStaticTokenToSession)
+ val getUsersByUsername = scenario("Get User By Username").exec(injectManagementTokenIntoSession)
.feed(Settings.getInfiniteUserFeeder())
//get users without a cursor
.exec(getUserByUsername)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
index 6cd6f2e..db6062f 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
@@ -16,6 +16,7 @@
*/
package org.apache.usergrid.settings
+ import org.apache.usergrid.enums.AuthType
import org.apache.usergrid.helpers.Setup
/**
@@ -26,7 +27,7 @@ object Headers {
/**
* Headers for anonymous posts
*/
- val jsonAnonymous = Map(
+ val authAnonymous = Map(
"Cache-Control" -> """no-cache""",
"Content-Type" -> """application/json; charset=UTF-8"""
)
@@ -34,14 +35,29 @@ object Headers {
/**
* Headers for authorized users with token and json content type
*/
- val jsonAuthorized = Map(
+ val authToken = Map(
"Cache-Control" -> """no-cache""",
"Content-Type" -> """application/json; charset=UTF-8""",
"Authorization" -> "Bearer ${authToken}"
)
+ /**
+ * Headers for basic auth
+ */
+ val authBasic = Map(
+ "Cache-Control" -> """no-cache""",
+ "Content-Type" -> """application/json; charset=UTF-8""",
+ "Authorization" -> ("Basic " + Settings.appUserBase64)
+ )
-
+ /**
+ * Header selector
+ */
+ def auth(authType:String): Map[String, String] = {
+ if (authType == AuthType.Basic) authBasic
+ else if (authType == AuthType.Token) authToken
+ else authAnonymous
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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 2619cad..75bed58 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
@@ -16,61 +16,87 @@
*/
package org.apache.usergrid.settings
+import java.nio.charset.StandardCharsets
+import java.util.Base64
+
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import org.apache.usergrid.datagenerators.FeederGenerator
+import org.apache.usergrid.enums._
import scala.concurrent.duration._
object Settings {
- // Target settings
- val org = System.getProperty("org")
- val app = System.getProperty("app")
- val admin = System.getProperty("adminUser")
- val password = System.getProperty("adminPassword")
- val baseUrl = System.getProperty("baseurl")
+ // load configuration settings via property or default
+ val org = System.getProperty(ConfigProperties.Org)
+ val app = System.getProperty(ConfigProperties.App)
+ val adminUser = System.getProperty(ConfigProperties.AdminUser)
+ val adminPassword = System.getProperty(ConfigProperties.AdminPassword)
+ val baseUrl = System.getProperty(ConfigProperties.BaseUrl)
val baseAppUrl = baseUrl + "/" + org + "/" + app
val httpConf = http.baseURL(baseAppUrl)
-
- val skipSetup:Boolean = System.getProperty("skipSetup") == "true"
- val duration:Int = Integer.getInteger("duration", 300).toInt // in seconds
-
-
-
- // Simulation settings
- val maxPossibleUsers:Int = Integer.getInteger("maxPossibleUsers", 1).toInt
- val numUsers:Int = maxPossibleUsers
- val userSeed:Int = Integer.getInteger("userSeed",1).toInt
-
- val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
- val numDevices:Int = Integer.getInteger("numDevices", 4000).toInt
-
- 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
+ val authType = System.getProperty(ConfigProperties.AuthType, AuthType.Anonymous)
+ val tokenType = System.getProperty(ConfigProperties.TokenType, TokenType.User)
+
+ val skipSetup:Boolean = System.getProperty(ConfigProperties.SkipSetup) == "true"
+ val createOrg:Boolean = System.getProperty(ConfigProperties.CreateOrg) == "true"
+ val createApp:Boolean = System.getProperty(ConfigProperties.CreateApp) != "false"
+ val loadEntities:Boolean = System.getProperty(ConfigProperties.LoadEntities) != "false"
+ val scenarioType = System.getProperty(ConfigProperties.ScenarioType, ScenarioType.NameRandomInfinite)
+
+ val rampUsers:Int = Integer.getInteger(ConfigProperties.RampUsers, 0).toInt
+ val constantUsersPerSec:Int = Integer.getInteger(ConfigProperties.ConstantUsersPerSec, 0).toInt // users to add per second during constant injection
+ val constantUsersDuration:Int = Integer.getInteger(ConfigProperties.ConstantUsersDuration, 10).toInt // number of seconds
+ val totalUsers:Int = rampUsers + (constantUsersPerSec * constantUsersDuration)
+ val userSeed:Int = Integer.getInteger(ConfigProperties.UserSeed,1).toInt
+ val appUser = System.getProperty(ConfigProperties.AppUser)
+ val appUserPassword = System.getProperty(ConfigProperties.AppUserPassword)
+ val appUserBase64 = Base64.getEncoder.encodeToString((appUser + ":" + appUserPassword).getBytes(StandardCharsets.UTF_8))
+
+ val numEntities:Int = Integer.getInteger(ConfigProperties.NumEntities, 5000).toInt
+ val numDevices:Int = Integer.getInteger(ConfigProperties.NumDevices, 4000).toInt
+
+ val collectionType = System.getProperty(ConfigProperties.CollectionType, "customentities")
+ val baseCollectionUrl = baseAppUrl + "/" + collectionType
+
+ val rampTime:Int = Integer.getInteger(ConfigProperties.RampTime, 0).toInt // in seconds
+ val throttle:Int = Integer.getInteger(ConfigProperties.Throttle, 50).toInt // in seconds
+ val rpsTarget:Int = Integer.getInteger(ConfigProperties.RpsTarget, 50).toInt // requests per second target
+ val rpsRampTime:Int = Integer.getInteger(ConfigProperties.RpsRampTime, 10).toInt // in seconds
+ val holdDuration:Int = Integer.getInteger(ConfigProperties.HoldDuration, 300).toInt // in seconds
// Geolocation settings
val centerLatitude:Double = 37.442348 // latitude of center point
val centerLongitude:Double = -122.138268 // longitude of center point
val userLocationRadius:Double = 32000 // location of requesting user in meters
- val geosearchRadius:Int = 8000 // search area in meters
+ val geoSearchRadius:Int = 8000 // search area in meters
// Push Notification 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 up to $maxPossibleUsers users per sec")
-
- def getUserFeeder():Array[Map[String, String]]= {
- val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude)
- return userFeeder
+ val pushNotifier = System.getProperty(ConfigProperties.PushNotifier, "loadNotifier")
+ val pushProvider = System.getProperty(ConfigProperties.PushProvider, "noop")
+
+ // Large Entity Collection settings
+ val entityPrefix = System.getProperty(ConfigProperties.EntityPrefix, "entity")
+ val entityType = System.getProperty(ConfigProperties.EntityType, EntityType.Basic) // basic/trivial/?
+ val entitySeed = Integer.getInteger(ConfigProperties.EntitySeed, 1).toInt
+ val searchLimit = Integer.getInteger(ConfigProperties.SearchLimit, 0).toInt
+ val searchQuery = System.getProperty(ConfigProperties.SearchQuery, "")
+ val endConditionType = System.getProperty(ConfigProperties.EndConditionType, EndConditionType.MinutesElapsed)
+ val endMinutes = Integer.getInteger(ConfigProperties.EndMinutes, 10).toInt
+ val endRequestCount = Integer.getInteger(ConfigProperties.EndRequestCount, 10).toInt
+
+ def getUserFeeder():Array[Map[String, String]]= {
+ FeederGenerator.generateUserWithGeolocationFeeder(totalUsers, userLocationRadius, centerLatitude, centerLongitude)
}
def getInfiniteUserFeeder():Iterator[Map[String, String]]= {
- val userFeeder = FeederGenerator.generateUserWithGeolocationFeederInfinite(Settings.userSeed, userLocationRadius, centerLatitude, centerLongitude,maxPossibleUsers)
- return userFeeder
+ FeederGenerator.generateUserWithGeolocationFeederInfinite(userSeed, userLocationRadius, centerLatitude, centerLongitude)
}
+ var testStartTime = System.currentTimeMillis()
+
+ def setTestStartTime(): Unit = {
+ testStartTime = System.currentTimeMillis()
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
deleted file mode 100755
index 8997d8c..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.settings
-
-import scala.util.Random
-import scala.math
-import Array._
-
-/**
- *
- * Utility for creating various data elements
- *
- */
-object Utils {
-
- private val RNG = new Random
-
- /**
- * Generate a new uuid and replace the '-' with empty
- */
- def generateUUIDString(): String = {
- return java.util.UUID.randomUUID.toString.replace("-", "")
- }
-
- /**
- * Generate a unique string with a prefix
- *
- * @param prefix
- * @return
- */
- def generateUniqueName(prefix : String): String = {
- return prefix + generateUUIDString()
- }
-
- // random number in between [a...b]
- def generateRandomInt(lowerBound: Int, upperBound: Int) = RNG.nextInt(upperBound - lowerBound) + lowerBound
-
- def generateRandomGeolocation(radius: Double, centerLatitude: Double, centerLongitude: Double):Map[String, String] = {
-
- var rd = radius / 111300 // Convert Radius from meters to degrees.
- var u = RNG.nextFloat()
- var v = RNG.nextFloat()
- var q = math.sqrt(u) * rd
- var w = q * rd
- var t = 2 * math.Pi * v
- var x = math.cos(t) * w
- var y = math.sin(t) * w
- var xp = x/math.cos(centerLatitude)
- var latitude = (y + centerLatitude).toString
- var longitude = (xp + centerLongitude).toString
- var geolocation: Map[String, String] = Map("latitude"->latitude,"longitude"->longitude)
-
- return geolocation
- }
-
- def generateRandomQueryString: String = {
-
- val queryParams = Array("age", "height", "weight")
- var queryString = ""
-
- for (numParams <- 1 to generateRandomInt(1, queryParams.length)) {
- queryString = "age=" + Utils.generateRandomInt(18, 65).toString
- if (numParams == 2) {
- queryString += "%20AND%20height=" + Utils.generateRandomInt(48, 84).toString
- } else if (numParams == 3) {
- queryString += "%20AND%20weight=" + Utils.generateRandomInt(120, 350).toString
- }
- }
-
- return queryString
- }
-
- def createRandomPushNotifier:String = {
- return Utils.generateUniqueName("notifier")
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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
deleted file mode 100644
index a9cfd10..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AppSimulation.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * * 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.NotificationScenarios
-import org.apache.usergrid.settings.Settings
-import scala.annotation.switch
-import scala.concurrent.duration._
-
-/**
- * Classy class class.
- */
-class AppSimulation extends Simulation {
- println("Begin setup")
- Setup.setupNotifier()
- println("End Setup")
-
- setUp(
- NotificationScenarios.createScenario
- .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/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConfigurableSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConfigurableSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConfigurableSimulation.scala
new file mode 100755
index 0000000..7a55577
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConfigurableSimulation.scala
@@ -0,0 +1,73 @@
+/*
+ * 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 org.apache.usergrid.enums.ScenarioType
+import org.apache.usergrid.helpers.Setup
+import org.apache.usergrid.scenarios.EntityCollectionScenarios
+import org.apache.usergrid.settings.Settings
+
+/**
+ * Configurable simulations.
+ *
+ * Configuration items:
+ * skipSetup, createOrg, org, createApp, app, adminUser, adminPassword, baseUrl,
+ * numEntities, entityType, entityPrefix, entitySeed, rampUsers, rampTime,
+ * constantUsersPerSec, constantUsersDuration, collectionType, scenarioType
+ *
+ * getAllByCursor scenario: searchQuery, searchLimit
+ */
+class ConfigurableSimulation extends Simulation {
+ before(
+ if (!Settings.skipSetup) {
+ println("Begin setup")
+ if (Settings.createOrg) Setup.setupOrg()
+ if (Settings.createApp) Setup.setupApplication()
+ if (Settings.loadEntities) Setup.setupEntitiesCollection(Settings.numEntities, Settings.entityType, Settings.entityPrefix, Settings.entitySeed)
+ } else {
+ println("Skipping setup")
+ }
+ )
+
+
+
+ Settings.setTestStartTime()
+ if (Settings.scenarioType == ScenarioType.GetAllByCursor) {
+ setUp(
+ EntityCollectionScenarios.getEntityPagesToEnd
+ .inject(
+ rampUsers(Settings.rampUsers) over Settings.rampTime,
+ constantUsersPerSec(Settings.constantUsersPerSec) during Settings.constantUsersDuration
+
+ ).protocols(Settings.httpConf.acceptHeader("application/json"))
+ )
+ } else if (Settings.scenarioType == ScenarioType.NameRandomInfinite) {
+ setUp(
+ EntityCollectionScenarios.getRandomEntitiesByName
+ .inject(
+ rampUsers(Settings.rampUsers) over Settings.rampTime,
+ constantUsersPerSec(Settings.constantUsersPerSec) during Settings.constantUsersDuration
+
+ ).protocols(Settings.httpConf.acceptHeader("application/json"))
+ )
+ } else {
+ println(s"scenarioType ${Settings.scenarioType} not found.")
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConnectionsSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConnectionsSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConnectionsSimulation.scala
deleted file mode 100644
index 3756f84..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConnectionsSimulation.scala
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *
- * * 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.{ConnectionScenarios, NotificationScenarios}
-import org.apache.usergrid.settings.Settings
-import scala.concurrent.duration._
-
-/**
- * Classy class class.
- */
-class ConnectionsSimulation extends Simulation{
-
- if(!Settings.skipSetup) {
- println("Begin setup")
- Setup.setupOrg()
- Setup.setupApplication()
- Setup.setupNotifier()
- Setup.setupUsers()
- println("End Setup")
- }else{
- println("Skipping Setup")
- }
-
- setUp(
- ConnectionScenarios.createScenario
- .inject(constantUsersPerSec(Settings.maxPossibleUsers) 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))
- .protocols( Settings.httpConf.acceptHeader("application/json"))
- )
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala
deleted file mode 100644
index bcfbe2d..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/DeleteUsersSimulation.scala
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * * 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
-import org.apache.usergrid.settings.Settings
-
-/**
- * Deletes application users continually to an application. Expects the following parameters
- *
- * -DmaxPossibleUsers : The maximum number of users to be making requests as fast as possible. Think of this as conccurrent users in the system
- * -DrampTime: The amount of time (in seconds) to allow for maxPossibleUsers to be reached. This will add new users linearlly
- * -Dduration: The amount of time (in seconds) to continue to perform requests up with the maxPossibleUsers
- */
-class DeleteUsersSimulation extends Simulation {
-
- println("Begin setup")
- Setup.setupOrg()
- Setup.setupApplication()
- println("End Setup")
-
-
- setUp(
- UserScenarios.deleteUsersInfinitely
- .inject(
- /**
- * injection steps take from this forum post
- * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
- */
- rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
- constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
-
- )).protocols(Settings.httpConf.acceptHeader("application/json"))
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
deleted file mode 100644
index 6e0ba81..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.http.Predef._
- import org.apache.usergrid.datagenerators.FeederGenerator
- import org.apache.usergrid.scenarios.UserScenarios
- import org.apache.usergrid.settings.Settings
- import scala.concurrent.duration._
-
-class GetEntitySimulation extends Simulation {
-
- // Target settings
- val httpConf = Settings.httpConf
-
- // Simulation settings
- val numUsers:Int = Settings.numUsers
- val numEntities:Int = Settings.numEntities
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
-
- val feeder = FeederGenerator.generateEntityNameFeeder("user", numEntities)
-
- val scnToRun = scenario("GET entity")
- .exec(UserScenarios.getRandomUser)
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf)).maxDuration(Settings.duration)
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
deleted file mode 100755
index 5d76ca0..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUserPagesSimulation.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 org.apache.usergrid.helpers.Setup
-import org.apache.usergrid.scenarios.UserScenarios
-import org.apache.usergrid.settings.Settings
-
-/**
- * Posts application users continually to an application. Expects the following parameters
- *
- * -DmaxPossibleUsers : The maximum number of users to be making requests as fast as possible. Think of this as conccurrent users in the system
- * -DrampTime: The amount of time (in seconds) to allow for maxPossibleUsers to be reached. This will add new users linearlly
- * -Dduration: The amount of time (in seconds) to continue to perform requests up with the maxPossibleUsers
- */
-class GetUserPagesSimulation extends Simulation {
-
- println("Begin setup")
- Setup.setupOrg()
- Setup.setupApplication()
- println("End Setup")
-
-
- setUp(
- UserScenarios.getUserPagesToEnd
- .inject(
- /**
- * injection steps take from this forum post
- * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
- */
- rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
- constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
-
- )).protocols(Settings.httpConf.acceptHeader("application/json"))
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
deleted file mode 100755
index a088e27..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetUsersSimulation.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 org.apache.usergrid.helpers.Setup
-import org.apache.usergrid.scenarios.UserScenarios
-import org.apache.usergrid.settings.Settings
-
-/**
- * Posts application users continually to an application. Expects the following parameters
- *
- * -DmaxPossibleUsers : The maximum number of users to be making requests as fast as possible. Think of this as conccurrent users in the system
- * -DrampTime: The amount of time (in seconds) to allow for maxPossibleUsers to be reached. This will add new users linearlly
- * -Dduration: The amount of time (in seconds) to continue to perform requests up with the maxPossibleUsers
- */
-class GetUsersSimulation extends Simulation {
-
- println("Begin setup")
- Setup.setupOrg()
- Setup.setupApplication()
- println("End Setup")
-
-
- setUp(
- UserScenarios.getUsersByUsername
- .inject(
- /**
- * injection steps take from this forum post
- * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
- */
- rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
- constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
-
- )).protocols(Settings.httpConf.acceptHeader("application/json"))
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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
deleted file mode 100644
index ef972ed..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostCustomEntitySimulation.scala
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *
- * * 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.{Utils, Headers, 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 PostCustomEntitySimulation 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.generateCustomEntityInfinite(0)
- val httpConf = Settings.httpConf
-
- val scnToRun = scenario("POST custom entities")
- .feed(feeder)
- .exec(EntityScenarios.postEntity)
-
- /*
- 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)
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c499e421/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
deleted file mode 100755
index 5184e92..0000000
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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 org.apache.usergrid.helpers.Setup
-import org.apache.usergrid.scenarios.UserScenarios
-import org.apache.usergrid.settings.Settings
-
-/**
- * Posts application users continually to an application. Expects the following parameters
- *
- * -DmaxPossibleUsers : The maximum number of users to be making requests as fast as possible. Think of this as conccurrent users in the system
- * -DrampTime: The amount of time (in seconds) to allow for maxPossibleUsers to be reached. This will add new users linearlly
- * -Dduration: The amount of time (in seconds) to continue to perform requests up with the maxPossibleUsers
- */
-class PostUsersSimulation extends Simulation {
-
- println("Begin setup")
- Setup.setupOrg()
- Setup.setupApplication()
- println("End Setup")
-
-
- setUp(
- UserScenarios.postUsersInfinitely
- .inject(
- /**
- * injection steps take from this forum post
- * https://groups.google.com/forum/#!topic/gatling/JfYHaWCbA-w
- */
- rampUsers(Settings.maxPossibleUsers) over Settings.rampTime,
- constantUsersPerSec(Settings.maxPossibleUsers) during Settings.duration
-
- )).protocols(Settings.httpConf.acceptHeader("application/json"))
-
-}