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:58 UTC
[14/21] incubator-usergrid git commit: USERGRID-871: clean up
settings + overall cleanup
USERGRID-871: clean up settings + overall cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/af446bee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/af446bee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/af446bee
Branch: refs/heads/two-dot-o-dev
Commit: af446bee546bc8378ffde17014bfbe77c69b6528
Parents: bfc2be2
Author: Mike Dunker <md...@apigee.com>
Authored: Wed Jul 29 18:27:49 2015 -0700
Committer: Mike Dunker <md...@apigee.com>
Committed: Wed Jul 29 18:27:49 2015 -0700
----------------------------------------------------------------------
stack/loadtests/runCollectionQueryTest.sh | 4 +-
stack/loadtests/runDeleteEntities.sh | 6 +-
stack/loadtests/runLoadEntities.sh | 18 +-
stack/loadtests/runRandomEntityByNameTest.sh | 4 +-
stack/loadtests/runRandomEntityByUuidTest.sh | 99 ++++++++
stack/loadtests/runUpdateEntities.sh | 6 +-
.../datagenerators/EntityDataGenerator.scala | 2 +-
.../datagenerators/FeederGenerator.scala | 3 +
.../usergrid/enums/ConfigProperties.scala | 71 +++++-
.../apache/usergrid/enums/ScenarioType.scala | 3 +-
.../apache/usergrid/helpers/Extractors.scala | 8 +-
.../org/apache/usergrid/helpers/Setup.scala | 85 ++++---
.../org/apache/usergrid/helpers/Utils.scala | 13 +-
.../scenarios/ApplicationScenarios.scala | 6 +-
.../scenarios/ConnectionScenarios.scala | 2 +-
.../usergrid/scenarios/DeviceScenarios.scala | 17 +-
.../scenarios/EntityCollectionScenarios.scala | 132 ++++++++---
.../usergrid/scenarios/EntityScenarios.scala | 12 +-
.../usergrid/scenarios/GeoScenarios.scala | 4 +-
.../scenarios/NotificationScenarios.scala | 14 +-
.../usergrid/scenarios/NotifierScenarios.scala | 10 +-
.../scenarios/OrganizationScenarios.scala | 8 +-
.../usergrid/scenarios/TokenScenarios.scala | 6 +-
.../usergrid/scenarios/UserScenarios.scala | 14 +-
.../org/apache/usergrid/settings/Settings.scala | 223 +++++++++++++------
.../simulations/ConfigurableSimulation.scala | 13 +-
.../deprecated/PostCustomEntitySimulation.scala | 6 +-
.../deprecated/PutCustomEntitySimulation.scala | 6 +-
stack/loadtests/src/test/resources/dummy.csv | 1 +
.../src/test/resources/logback-test.xml | 6 +-
stack/loadtests/src/test/resources/logback.xml | 4 +-
31 files changed, 566 insertions(+), 240 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/runCollectionQueryTest.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runCollectionQueryTest.sh b/stack/loadtests/runCollectionQueryTest.sh
index 7d1779c..9882cf2 100755
--- a/stack/loadtests/runCollectionQueryTest.sh
+++ b/stack/loadtests/runCollectionQueryTest.sh
@@ -41,7 +41,7 @@ ORG=gatling
CREATE_APP=false
#APP=$(date +%s)
APP=millionentities
-COLLECTION_TYPE=basicentities
+COLLECTION=basicentities
SCENARIO_TYPE=getAllByCursor
LOAD_ENTITIES=false
NUM_ENTITIES=10000
@@ -76,7 +76,7 @@ mvn gatling:execute -Dorg=usergrid \
-DrampTime=${RAMP_TIME} \
-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \
-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \
--DcollectionType=${COLLECTION_TYPE} \
+-Dcollection=${COLLECTION} \
-DscenarioType=${SCENARIO_TYPE} \
-DauthType=${AUTH_TYPE} \
-DtokenType=${TOKEN_TYPE} \
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/runDeleteEntities.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runDeleteEntities.sh b/stack/loadtests/runDeleteEntities.sh
index 1ca557e..0883fa8 100755
--- a/stack/loadtests/runDeleteEntities.sh
+++ b/stack/loadtests/runDeleteEntities.sh
@@ -41,12 +41,12 @@ CREATE_ORG=false
ORG=gatling
CREATE_APP=false
APP=millionentities
-COLLECTION_TYPE=trivialentities
+COLLECTION=trivialentities
SCENARIO_TYPE=deleteEntities
# don't load entities as part of setup
LOAD_ENTITIES=false
-SKIP_SETUP=TRUE
+SKIP_SETUP=true
#SEARCH_QUERY=order%20by%20specials%20desc
#SEARCH_LIMIT=1000
ENTITY_TYPE=trivial
@@ -78,7 +78,7 @@ mvn gatling:execute \
-DrampTime=${RAMP_TIME} \
-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \
-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \
--DcollectionType=${COLLECTION_TYPE} \
+-Dcollection=${COLLECTION} \
-DscenarioType=${SCENARIO_TYPE} \
-DauthType=${AUTH_TYPE} \
-DtokenType=${TOKEN_TYPE} \
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/runLoadEntities.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runLoadEntities.sh b/stack/loadtests/runLoadEntities.sh
index e166c58..1471d70 100755
--- a/stack/loadtests/runLoadEntities.sh
+++ b/stack/loadtests/runLoadEntities.sh
@@ -19,7 +19,7 @@ die() { echo "$@" 1>&2 ; exit 1; }
#This is a script to simplify running gatling tests. It will default several parameters, invoke the maven plugins
#Then aggregate the results
####
-[ "$#" -ge 8 ] || die "At least 8 arguments required, $# provided. Example is $0 URL RAMP_USERS RAMP_TIME(seconds) CONSTANT_USERS_PER_SEC, CONSTANT_USERS_DURATION(seconds) NUM_ENTITIES ENTITY_WORKER_NUM ENTITY_WORKER_COUNT"
+[ "$#" -ge 8 ] || die "At least 8 arguments required, $# provided. Example is $0 URL RAMP_USERS RAMP_TIME(seconds) CONSTANT_USERS_PER_SEC, CONSTANT_USERS_DURATION(seconds) NUM_ENTITIES ENTITY_WORKER_NUM ENTITY_WORKER_COUNT [UUID_FILENAME]"
URL="$1"
RAMP_USERS="$2"
@@ -29,8 +29,9 @@ CONSTANT_USERS_DURATION="$5"
NUM_ENTITIES="$6"
ENTITY_WORKER_NUM="$7"
ENTITY_WORKER_COUNT="$8"
+UUID_FILENAME="$9"
-shift 8
+shift 9
#Compile everything
mvn compile
@@ -39,16 +40,17 @@ mvn compile
#APP=$(date +%s)
ADMIN_USER=superuser
ADMIN_PASSWORD=test
-CREATE_ORG=true
+CREATE_ORG=false
ORG=gatling
-CREATE_APP=true
+CREATE_APP=false
APP=millionentities
-COLLECTION_TYPE=trivialentities
+COLLECTION=trivialentities
+SANDBOX_COLLECTION=true
SCENARIO_TYPE=loadEntities
# don't load entities as part of setup
LOAD_ENTITIES=false
-SKIP_SETUP=FALSE
+SKIP_SETUP=false
#SEARCH_QUERY=order%20by%20specials%20desc
#SEARCH_LIMIT=1000
ENTITY_TYPE=trivial
@@ -80,7 +82,7 @@ mvn gatling:execute \
-DrampTime=${RAMP_TIME} \
-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \
-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \
--DcollectionType=${COLLECTION_TYPE} \
+-Dcollection=${COLLECTION} \
-DscenarioType=${SCENARIO_TYPE} \
-DauthType=${AUTH_TYPE} \
-DtokenType=${TOKEN_TYPE} \
@@ -89,6 +91,8 @@ mvn gatling:execute \
-DendRequestCount=${END_REQUEST_COUNT} \
-DentityWorkerCount=${ENTITY_WORKER_COUNT} \
-DentityWorkerNum=${ENTITY_WORKER_NUM} \
+-DuuidFilename=${UUID_FILENAME} \
+-DsandboxCollection=${SANDBOX_COLLECTION} \
-Dgatling.simulationClass=org.apache.usergrid.simulations.ConfigurableSimulation
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/runRandomEntityByNameTest.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runRandomEntityByNameTest.sh b/stack/loadtests/runRandomEntityByNameTest.sh
index dd98aa6..5967a1b 100755
--- a/stack/loadtests/runRandomEntityByNameTest.sh
+++ b/stack/loadtests/runRandomEntityByNameTest.sh
@@ -40,7 +40,7 @@ CREATE_ORG=false
ORG=gatling
CREATE_APP=false
APP=millionentities
-COLLECTION_TYPE=trivialentities
+COLLECTION=trivialentities
SCENARIO_TYPE=nameRandomInfinite
LOAD_ENTITIES=false
NUM_ENTITIES=10000
@@ -76,7 +76,7 @@ mvn gatling:execute \
-DrampTime=${RAMP_TIME} \
-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \
-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \
--DcollectionType=${COLLECTION_TYPE} \
+-Dcollection=${COLLECTION} \
-DscenarioType=${SCENARIO_TYPE} \
-DauthType=${AUTH_TYPE} \
-DtokenType=${TOKEN_TYPE} \
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/runRandomEntityByUuidTest.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runRandomEntityByUuidTest.sh b/stack/loadtests/runRandomEntityByUuidTest.sh
new file mode 100755
index 0000000..4a83eb5
--- /dev/null
+++ b/stack/loadtests/runRandomEntityByUuidTest.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+#
+# Licensed 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.
+#
+
+die() { echo "$@" 1>&2 ; exit 1; }
+
+####
+#This is a script to simplify running gatling tests. It will default several parameters, invoke the maven plugins
+#Then aggregate the results
+####
+[ "$#" -ge 6 ] || die "At least 6 arguments required, $# provided. Example is $0 URL RAMP_USERS RAMP_TIME(seconds) CONSTANT_USERS_PER_SEC, CONSTANT_USERS_DURATION(seconds) UUID_FILENAME"
+
+URL="$1"
+RAMP_USERS="$2"
+RAMP_TIME="$3"
+CONSTANT_USERS_PER_SEC="$4"
+CONSTANT_USERS_DURATION="$5"
+UUID_FILENAME="$6"
+
+shift 6
+
+#Compile everything
+mvn compile
+
+#Set the app id to be a date epoch for uniqueness
+#APP=$(date +%s)
+ADMIN_USER=superuser
+ADMIN_PASSWORD=test
+CREATE_ORG=false
+ORG=gatling
+CREATE_APP=false
+APP=millionentities
+COLLECTION=trivialentities
+SCENARIO_TYPE=uuidRandomInfinite
+LOAD_ENTITIES=false
+NUM_ENTITIES=10000
+SKIP_SETUP=false
+#SEARCH_QUERY=order%20by%20specials%20desc
+#SEARCH_LIMIT=1000
+ENTITY_TYPE=trivial
+ENTITY_PREFIX=trivial
+ENTITY_SEED=1
+AUTH_TYPE=anonymous
+TOKEN_TYPE=management
+END_CONDITION_TYPE=minutesElapsed
+#END_CONDITION_TYPE=requestCount
+END_MINUTES=2
+END_REQUEST_COUNT=100
+
+#Execute the test
+mvn gatling:execute \
+-DskipSetup=${SKIP_SETUP} \
+-DcreateOrg=${CREATE_ORG} \
+-Dorg=${ORG} \
+-DcreateApp=${CREATE_APP} \
+-Dapp=${APP} \
+-Dbaseurl=${URL} \
+-DadminUser=${ADMIN_USER} \
+-DadminPassword=${ADMIN_PASSWORD} \
+-DloadEntities=${LOAD_ENTITIES} \
+-DnumEntities=${NUM_ENTITIES} \
+-DentityType=${ENTITY_TYPE} \
+-DentityPrefix=${ENTITY_PREFIX} \
+-DentitySeed=${ENTITY_SEED} \
+-DrampUsers=${RAMP_USERS} \
+-DrampTime=${RAMP_TIME} \
+-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \
+-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \
+-Dcollection=${COLLECTION} \
+-DscenarioType=${SCENARIO_TYPE} \
+-DauthType=${AUTH_TYPE} \
+-DtokenType=${TOKEN_TYPE} \
+-DendConditionType=${END_CONDITION_TYPE} \
+-DendMinutes=${END_MINUTES} \
+-DendRequestCount=${END_REQUEST_COUNT} \
+-DuuidFilename=${UUID_FILENAME} \
+-Dgatling.simulationClass=org.apache.usergrid.simulations.ConfigurableSimulation
+
+
+
+#Now move all the reports
+#AGGREGATE_DIR="target/aggregate-$(date +%s)"
+
+#mkdir -p ${AGGREGATE_DIR}
+
+#copy to the format of target/aggregate(date)/(simnulationame)-simulation.log
+#find target -name "simulation.log" -exec cp {} ${AGGREGATE_DIR}/$(basename $(dirname {} ))-simulation.log \;
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/runUpdateEntities.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runUpdateEntities.sh b/stack/loadtests/runUpdateEntities.sh
index 0963a2d..85d529d 100755
--- a/stack/loadtests/runUpdateEntities.sh
+++ b/stack/loadtests/runUpdateEntities.sh
@@ -41,12 +41,12 @@ CREATE_ORG=false
ORG=gatling
CREATE_APP=false
APP=millionentities
-COLLECTION_TYPE=trivialentities
+COLLECTION=trivialentities
SCENARIO_TYPE=updateEntities
# don't load entities as part of setup
LOAD_ENTITIES=false
-SKIP_SETUP=TRUE
+SKIP_SETUP=true
#SEARCH_QUERY=order%20by%20specials%20desc
#SEARCH_LIMIT=1000
ENTITY_TYPE=trivial
@@ -78,7 +78,7 @@ mvn gatling:execute \
-DrampTime=${RAMP_TIME} \
-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \
-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \
--DcollectionType=${COLLECTION_TYPE} \
+-Dcollection=${COLLECTION} \
-DscenarioType=${SCENARIO_TYPE} \
-DauthType=${AUTH_TYPE} \
-DtokenType=${TOKEN_TYPE} \
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 f9fa4fc..cd359b7 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
@@ -45,7 +45,7 @@ object EntityDataGenerator {
Map(
- "username" -> "user".concat(userId.toString),
+ "username" -> "user".concat(userId),
"profileId" -> Utils.generateRandomInt(10000, 1000000).toString,
"displayName" -> Utils.generateRandomInt(10000, 1000000).toString,
"showAge" -> Utils.generateRandomInt(0, 1).toString,
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 1c80822..f218b5b 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
@@ -65,6 +65,7 @@ object FeederGenerator {
val geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
val blockLists: Map[String, String] = EntityDataGenerator.generateBlockUserLists(1)
+ // merge maps
user ++ geolocation ++ blockLists
}
@@ -224,6 +225,8 @@ object FeederGenerator {
val entityUrl = Settings.baseCollectionUrl + "/" + entityName
val validEntity = if (i >= numEntities) "no" else "yes"
+ // println(entityName)
+
Map("entityName" -> entityName, "entity" -> entity, "entityUrl" -> entityUrl, "validEntity" -> validEntity, "entityNum" -> (i+1).toString)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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
index 855a7ae..7e6cf55 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ConfigProperties.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ConfigProperties.scala
@@ -1,5 +1,7 @@
package org.apache.usergrid.enums
+import java.util.Date
+
/**
* Created by mdunker on 7/20/15.
*/
@@ -24,7 +26,7 @@ object ConfigProperties {
val AppUserPassword = "appUserPassword"
val NumEntities = "numEntities"
val NumDevices = "numDevices"
- val CollectionType = "collectionType"
+ val Collection = "collection"
val RampTime = "rampTime"
val Throttle = "throttle"
val RpsTarget = "rpsTarget"
@@ -48,14 +50,75 @@ object ConfigProperties {
val UpdateValue = "updateValue"
val EntityWorkerCount = "entityWorkerCount"
val EntityWorkerNum = "entityWorkerNum"
+ val UuidFilename = "uuidFilename"
+ val SandboxCollection = "sandboxCollection"
+ val PurgeUsers = "purgeUsers"
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,OrgCreationUsername,OrgCreationName,
- OrgCreationEmail,OrgCreationPassword,UpdateProperty,UpdateValue,EntityWorkerCount,EntityWorkerNum)
+ NumDevices,Collection,RampTime,Throttle,RpsTarget,RpsRampTime,HoldDuration,PushNotifier,PushProvider,EntityPrefix,
+ EntityType,EntitySeed,SearchLimit,SearchQuery,EndConditionType,EndMinutes,EndRequestCount,OrgCreationUsername,
+ OrgCreationName,OrgCreationEmail,OrgCreationPassword,UpdateProperty,UpdateValue,EntityWorkerCount,EntityWorkerNum,
+ UuidFilename,SandboxCollection,PurgeUsers)
def isValid(str: String): Boolean = {
Values.contains(str)
}
+
+ // defaults for all the configuration items
+ def getDefault(cfg: String): Any = {
+ if (isValid(cfg)) {
+ cfg match {
+ case Org => ""
+ case App => ""
+ case AdminUser => ""
+ case AdminPassword => ""
+ case BaseUrl => ""
+ case AuthType => org.apache.usergrid.enums.AuthType.Anonymous
+ case TokenType => org.apache.usergrid.enums.TokenType.User
+ case SkipSetup => false
+ case CreateOrg => false
+ case CreateApp => false
+ case LoadEntities => false
+ case ScenarioType => org.apache.usergrid.enums.ScenarioType.NameRandomInfinite
+ case RampUsers => 0
+ case ConstantUsersPerSec => 0
+ case ConstantUsersDuration => 10
+ case UserSeed => 1
+ case AppUser => ""
+ case AppUserPassword => ""
+ case NumEntities => 5000
+ case NumDevices => 4000
+ case Collection => "customentities"
+ case RampTime => 0
+ case Throttle => 50
+ case RpsTarget => 50
+ case RpsRampTime => 10
+ case HoldDuration => 300
+ case PushNotifier => "loadNotifier"
+ case PushProvider => "noop"
+ case EntityPrefix => "entity"
+ case EntityType => org.apache.usergrid.enums.EntityType.Basic
+ case EntitySeed => 1
+ case SearchLimit => 0
+ case SearchQuery => ""
+ case EndConditionType => org.apache.usergrid.enums.EndConditionType.MinutesElapsed
+ case EndMinutes => 10
+ case EndRequestCount => 1000
+ case OrgCreationUsername => "" // actual default is {org}_admin
+ case OrgCreationName => "" // actual default is {org}_admin
+ case OrgCreationEmail => "" // actual default is {org}_admin@usergrid.com
+ case OrgCreationPassword => "test"
+ case UpdateProperty => "updateProp"
+ case UpdateValue => new Date().toString
+ case EntityWorkerCount => 0
+ case EntityWorkerNum => 0
+ case UuidFilename => "dummy.csv"
+ case SandboxCollection => false
+ case PurgeUsers => 100
+ }
+ } else {
+ null
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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
index 7dca619..db9a3af 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ScenarioType.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/ScenarioType.scala
@@ -6,8 +6,9 @@ object ScenarioType {
val LoadEntities = "loadEntities"
val DeleteEntities = "deleteEntities"
val UpdateEntities = "updateEntities"
+ val UuidRandomInfinite = "uuidRandomInfinite"
- val Values = Seq(GetAllByCursor,NameRandomInfinite,LoadEntities,DeleteEntities,UpdateEntities)
+ val Values = Seq(GetAllByCursor,NameRandomInfinite,LoadEntities,DeleteEntities,UpdateEntities,UuidRandomInfinite)
def isValid(str: String): Boolean = {
Values.contains(str)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 f8aad98..120d790 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
@@ -43,7 +43,7 @@ object Extractors {
/**
* Will extract the uuid from the create response. If the uuid is not present, an empty string will be set
*/
- def extractUuid(saveAsName: String) = {
+ def extractCreateUuid(saveAsName: String) = {
jsonPath("$.entities[0].uuid").transformOption(extract => {
//it may or may not be present. If it is, save it, otherwise save it as an empty string
extract.orElse(Some(""))
@@ -83,8 +83,8 @@ object Extractors {
* under the variable "authToken"
* @return
*/
- def injectManagementTokenIntoSession(): Expression[Session] = {
- session => session.set("authToken", Setup.getManagementToken())
+ def injectManagementTokenIntoSession: Expression[Session] = {
+ session => session.set("authToken", Setup.getManagementToken)
}
def injectUserTokenIntoSession(): Expression[Session] = {
@@ -93,7 +93,7 @@ object Extractors {
// handles different types of tokens
def injectTokenIntoSession(): Expression[Session] = {
- session => session.set("authToken", Setup.getToken())
+ session => session.set("authToken", Setup.getToken)
}
def injectAnonymousAuth(): Expression[Session] = {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 d90353a..727c295 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
@@ -35,7 +35,11 @@ object Setup {
def getToken(tokenUrl:String, username:String, password:String):String = {
val getToken = client
.preparePost(tokenUrl)
- .setBody("{\"username\":\"" + username + "\",\"password\":\"" + password + "\",\"grant_type\":\"password\"}")
+ .setBody(Utils.toJSONStr(Map(
+ "username" -> username,
+ "password" -> password,
+ "grant_type" -> "password"
+ )))
.setHeader("Cache-Control", "no-cache")
.setHeader("Content-Type", "application/json; charset=UTF-8")
.build()
@@ -45,21 +49,21 @@ object Setup {
tree.get("access_token").asText()
}
- def getManagementToken():String = {
+ def getManagementToken:String = {
if(managementToken == null) {
- managementToken = getToken(Settings.baseUrl + "/management/token", Settings.adminUser, Settings.adminPassword)
+ managementToken = getToken(s"${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)
+ getToken(s"${Settings.baseAppUrl}/token", Settings.appUser, Settings.appUserPassword)
}
- def getToken():String = {
+ def getToken:String = {
var token = ""
- if (Settings.tokenType == TokenType.Management) token = getManagementToken()
+ if (Settings.tokenType == TokenType.Management) token = getManagementToken
if (Settings.tokenType == TokenType.User) token = getUserToken
token
@@ -68,7 +72,7 @@ object Setup {
def setupOrg(): Integer = {
val createOrgPost = client
- .preparePost(Settings.baseUrl + "/management/organizations")
+ .preparePost(s"${Settings.baseUrl}/management/organizations")
.setHeader("Cache-Control", "no-cache")
.setHeader("Content-Type", "application/json; charset=UTF-8")
.setBody(Utils.toJSONStr(Map(
@@ -82,7 +86,7 @@ object Setup {
val orgResponse = client.executeRequest(createOrgPost).get()
- printResponse("POST ORG",orgResponse.getStatusCode,orgResponse.getResponseBody)
+ printResponse("POST ORG", orgResponse.getStatusCode, orgResponse.getResponseBody)
orgResponse.getStatusCode
}
@@ -90,17 +94,35 @@ object Setup {
def setupApplication(): Integer = {
val createAppPost = client
- .preparePost(Settings.baseUrl + "/management/organizations/" + Settings.org + "/applications")
+ .preparePost(s"${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 " + getManagementToken)
+ .setHeader("Authorization", s"Bearer $getManagementToken")
.build()
- val appResponse = client.executeRequest(createAppPost).get();
+ val appResponse = client.executeRequest(createAppPost).get()
val statusCode = appResponse.getStatusCode
- printResponse("POST APP",statusCode, appResponse.getResponseBody)
+ printResponse("POST APP", statusCode, appResponse.getResponseBody)
+
+ statusCode
+ }
+
+ def sandboxCollection(): Integer = {
+
+ val sandboxCollectionPost = client
+ .preparePost(s"${Settings.baseAppUrl}/roles/guest/permissions")
+ .setBody(Utils.toJSONStr(Map("permission" -> s"GET,PUT,POST,DELETE:/${Settings.collection}/**")))
+ .setHeader("Cache-Control", "no-cache")
+ .setHeader("Content-Type", "application/json; charset=UTF-8")
+ .setHeader("Authorization", s"Bearer $getManagementToken")
+ .build()
+
+ val response = client.executeRequest(sandboxCollectionPost).get()
+
+ val statusCode = response.getStatusCode
+ printResponse("SANDBOX COLLECTION", statusCode, response.getResponseBody)
statusCode
}
@@ -108,21 +130,21 @@ object Setup {
def setupNotifier():Integer = {
val createNotifier = client
- .preparePost(Settings.baseAppUrl + "/notifiers")
+ .preparePost(s"${Settings.baseAppUrl}/notifiers")
.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 " + getManagementToken)
+ .setHeader("Authorization", s"Bearer $getManagementToken")
.build()
- val notifierResponse = client.executeRequest(createNotifier).get();
- printResponse("POST Notifier", notifierResponse.getStatusCode ,notifierResponse.getResponseBody())
+ val notifierResponse = client.executeRequest(createNotifier).get()
+ printResponse("POST Notifier", notifierResponse.getStatusCode ,notifierResponse.getResponseBody)
notifierResponse.getStatusCode
}
def setupUsers() = {
- val userFeeder = Settings.getUserFeeder()
+ val userFeeder = Settings.getUserFeeder
val numUsers = userFeeder.length
println(s"setupUsers: Sending requests for $numUsers users")
@@ -132,7 +154,7 @@ object Setup {
list.foreach(f => {
val response = f.get()
if (response.getStatusCode != 200) {
- printResponse("Post User", response.getStatusCode, response.getResponseBody())
+ printResponse("Post User", response.getStatusCode, response.getResponseBody)
} else {
successCount += 1
}
@@ -141,7 +163,7 @@ object Setup {
}
userFeeder.foreach(user => {
list += setupUser(user)
- if (list.length == Integer.getInteger("purgeUsers",100)) {
+ if (list.length == Settings.purgeUsers) {
purgeList()
}
})
@@ -170,12 +192,12 @@ object Setup {
"displayName":"$displayName","age":"$age","seen":"$seen","weight":"$weight",
"height":"$height","aboutMe":"$aboutMe","profileId":"$profileId","headline":"$headline",
"showAge":"$showAge","relationshipStatus":"$relationshipStatus","ethnicity":"$ethnicity","password":"$password"}"""
- val authToken = getManagementToken()
+ val authToken = getManagementToken
val createUser = client
- .preparePost(Settings.baseAppUrl + "/users")
+ .preparePost(s"${Settings.baseAppUrl}/users")
.setBody(body)
.setBodyEncoding("UTF-8")
- .setHeader("Authorization","Bearer "+authToken)
+ .setHeader("Authorization",s"Bearer $authToken")
.build()
client.executeRequest(createUser)
@@ -183,11 +205,10 @@ object Setup {
def setupEntitiesCollection(numEntities: Int, entityType: String, prefix: String, seed: Int = 1) = {
val entitiesFeeder = FeederGenerator.generateCustomEntityArray(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 = {
+ 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) {
@@ -202,7 +223,7 @@ object Setup {
entitiesFeeder.foreach(payload => {
//println("setupEntitiesCollection: payload=" + payload)
list += setupEntity(payload)
- if(list.length == purgeUsers) {
+ if(list.length == Settings.purgeUsers) {
purgeList()
}
})
@@ -213,21 +234,21 @@ object Setup {
}
def setupEntity(payload: String):ListenableFuture[Response] = {
- val authToken = getManagementToken()
+ val authToken = getManagementToken
val createEntity = client
- .preparePost(Settings.baseAppUrl + "/" + Settings.collectionType)
+ .preparePost(Settings.baseCollectionUrl)
.setBody(payload)
.setBodyEncoding("UTF-8")
- .setHeader("Authorization", "Bearer " + authToken)
+ .setHeader("Authorization", s"Bearer $authToken")
.setHeader("Content-Type", "application/json; charset=UTF-8")
.build()
- //println("setupEntity: baseAppUrl=" + Settings.baseAppUrl + ", collectionType=" + Settings.collectionType + ", payload=" + payload)
+ //println("setupEntity: baseAppUrl=" + Settings.baseAppUrl + ", collection=" + Settings.collection + ", payload=" + payload)
client.executeRequest(createEntity)
}
def printResponse(caller:String, status:Int, body:String) = {
- println(caller + ": status: "+status.toString+" body:"+body)
+ println(caller + s"$caller:\nstatus: $status\nbody:\n$body")
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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
index 16ade96..91c8081 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Utils.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/helpers/Utils.scala
@@ -72,11 +72,12 @@ object Utils {
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 = s"age=${Utils.generateRandomInt(18,65).toString}"
+ if (numParams >= 2) {
+ queryString += s"%20AND%20height=${Utils.generateRandomInt(48,84).toString}"
+ }
+ if (numParams >= 3) {
+ queryString += s"%20AND%20weight=${Utils.generateRandomInt(120,350).toString}"
}
}
@@ -86,7 +87,7 @@ object Utils {
def randomEntityNameUrl(prefix: String, numEntities: Int, seed: Int, baseUrl: String): String = {
val randomVal = generateRandomInt(seed, seed+numEntities-1)
- baseUrl + "/" + prefix.concat(randomVal.toString)
+ s"$baseUrl/$prefix$randomVal"
}
def createRandomPushNotifierName:String = {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 44fe118..085af88 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
@@ -36,10 +36,10 @@ import org.apache.usergrid.settings.{Settings, Headers}
object ApplicationScenarios {
val createApplication = exec(http("Create Application")
- .post(Settings.baseUrl + "/management/organizations/"+Settings.org+"/applications")
+ .post(_ => Settings.baseUrl + "/management/organizations/" + Settings.org + "/applications")
.headers(Headers.authToken)
- .body(StringBody("{\"name\":\"" + Settings.app + "\"}"))
- .check(status.in(200 to 204))
+ .body(StringBody(_ => """ { "name": """" + Settings.app + """" } """))
+ .check(status.in(Range(200,204)))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 0ff20a0..56a40bb 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
@@ -52,7 +52,7 @@ object ConnectionScenarios {
.exec( UserScenarios.getUserByUsername)
.repeat(2){
feed(entityNameFeeder)
- .exec( DeviceScenarios.postDeviceWithNotifier)
+ .exec(DeviceScenarios.postDeviceWithNotifier)
.exec(ConnectionScenarios.postUserToDeviceConnection)
}
.exec(session => {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 a8a3d9c..57df0b9 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
@@ -47,20 +47,15 @@ object DeviceScenarios {
val postDeviceWithNotifier = exec(http("Create device with notifier")
.post("/devices")
.headers(Headers.authToken)
- .body(StringBody("""{"deviceModel":"Fake Device",
- "deviceOSVerion":"Negative Version",
- """" + notifier + """.notifier.id":"${entityName}"}"""))
+ .body(StringBody(session => """{ "deviceModel": "Fake Device", "deviceOSVersion": "Negative Version", """" + notifier + """.notifier.id": "${entityName}" }"""))
.check(status.is(200), jsonPath("$..entities[0]").exists , jsonPath("$..entities[0].uuid").exists , jsonPath("$..entities[0].uuid").saveAs("deviceId")))
val postDeviceWithNotifier400ok = exec(http("Create device with notifier")
.post("/devices")
.headers(Headers.authToken)
- .body(StringBody("""{"name":"${entityName}",
- "deviceModel":"Fake Device",
- "deviceOSVerion":"Negative Version",
- "${notifier}.notifier.id":"${entityName}"}"""))
- .check(status.in(200 to 400), jsonPath("$.entities[0].uuid").saveAs("deviceId")))
+ .body(StringBody(session => """{ "name":"${entityName}", "deviceModel":"Fake Device", "deviceOSVersion":"Negative Version", """" + notifier + """.notifier.id":"${entityName}" }"""))
+ .check(status.in(Range(200, 400)), jsonPath("$.entities[0].uuid").saveAs("deviceId")))
/**
@@ -79,11 +74,11 @@ object DeviceScenarios {
} )
//create the device if we got a 404
.doIf("${devices}","[]") {
- exec(session =>{
+ /*exec(session =>{
println("adding devices")
session
- } )
- .exec(postDeviceWithNotifier)
+ } )*/
+ exec(postDeviceWithNotifier)
.exec(ConnectionScenarios.postUserToDeviceConnection)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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
index 1fa1c07..4e37842 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/EntityCollectionScenarios.scala
@@ -17,6 +17,7 @@
package org.apache.usergrid.scenarios
import io.gatling.core.Predef._
+import io.gatling.core.feeder.RecordSeqFeederBuilder
import io.gatling.http.Predef._
import org.apache.usergrid.datagenerators.FeederGenerator
import org.apache.usergrid.enums.{EndConditionType, AuthType}
@@ -37,16 +38,17 @@ object EntityCollectionScenarios {
val SessionVarUuid: String = "createUuid"
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 "")
+ val url = s"/${Settings.collection}?" +
+ (if (useCursor) "cursor=${" + SessionVarCursor + "}&" else "") +
+ (if (Settings.searchQuery != "") s"ql=${Settings.searchQuery}&" else "") +
+ (if (Settings.searchLimit > 0) s"limit=${Settings.searchLimit}&" else "")
- url
+ // remove trailing & or ?
+ url.dropRight(1)
}
def entityGetByNameUrl(entityName: String): String = {
- val url = Settings.baseCollectionUrl + "/" + entityName
+ val url = s"/${Settings.collection}/$entityName"
url
}
@@ -55,6 +57,10 @@ object EntityCollectionScenarios {
Utils.randomEntityNameUrl(prefix, numEntities, seed, Settings.baseCollectionUrl)
}
+ def uuidFeeder(): RecordSeqFeederBuilder[String] = {
+ csv(Settings.feedUuidFilename).random
+ }
+
/*
* Loop through entities using cursor
*/
@@ -75,15 +81,15 @@ object EntityCollectionScenarios {
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) {
+ .doIfOrElse(_ => Settings.endConditionType == EndConditionType.MinutesElapsed) {
+ asLongAs(_ => Settings.continueMinutesTest, exitASAP = true) {
exec(getEntitiesWithoutCursor)
.asLongAs(stringParamExists(SessionVarCursor)) {
exec(getEntitiesWithCursor)
}
}
} {
- repeat(Settings.endRequestCount) {
+ repeat(_ => Settings.endRequestCount.toInt) {
exec(getEntitiesWithoutCursor)
.asLongAs(stringParamExists(SessionVarCursor)) {
exec(getEntitiesWithCursor)
@@ -93,18 +99,18 @@ object EntityCollectionScenarios {
//.exec(sessionFunction => { sessionFunction })
/*
- * Get random entities
+ * Get random entities by name
*/
val getRandomEntityAnonymous = exec(
http("GET entity by name (anonymous)")
- .get(_ => randomEntityNameUrl())
+ .get(randomEntityNameUrl())
.headers(Headers.authAnonymous)
.check(status.is(200))
)
val getRandomEntityWithToken = exec(
http("GET entity by name (token)")
- .get(_ => randomEntityNameUrl())
+ .get(randomEntityNameUrl())
.headers(Headers.authToken)
.check(status.is(200))
)
@@ -112,21 +118,69 @@ object EntityCollectionScenarios {
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)
- }
+ .doIfOrElse(_ => Settings.endConditionType == EndConditionType.MinutesElapsed) {
+ asLongAs(_ => Settings.continueMinutesTest) {
+ doIfOrElse(_ => Settings.authType == AuthType.Anonymous) {
+ exec(getRandomEntityAnonymous)
+ } {
+ exec(getRandomEntityWithToken)
+ }
+ }
+ } {
+ repeat(_ => Settings.endRequestCount.toInt) {
+ doIfOrElse(_ => Settings.authType == AuthType.Anonymous) {
+ exec(getRandomEntityAnonymous)
+ } {
+ exec(getRandomEntityWithToken)
+ }
+ }
+ }
+
+ /*
+ * Get random entities by UUID
+ */
+ val getRandomEntityByUuidAnonymous = exec(
+ http("GET entity by UUID (anonymous)")
+ .get("/" + Settings.collection + "/${uuid}")
+ .headers(Headers.authAnonymous)
+ .check(status.is(200))
+ )
+
+ val getRandomEntityByUuidWithToken = exec(
+ http("GET entity by UUID (token)")
+ .get("/" + Settings.collection + "/${uuid}")
+ .headers(Headers.authToken)
+ .check(status.is(200))
+ )
+
+ val getRandomEntitiesByUuid = scenario("Get entities by uuid randomly")
+ .exec(injectTokenIntoSession())
+ .exec(injectAuthType())
+ .doIfOrElse(_ => Settings.endConditionType == EndConditionType.MinutesElapsed) {
+ asLongAs(_ => Settings.continueMinutesTest) {
+ feed(uuidFeeder())
+ /*.exec{
+ session => println(s"UUID: ${session("uuid").as[String]}")
+ session
+ }*/
+ .doIfOrElse(_ => Settings.authType == AuthType.Anonymous) {
+ exec(getRandomEntityByUuidAnonymous)
+ } {
+ exec(getRandomEntityByUuidWithToken)
+ }
}
} {
- repeat(Settings.endRequestCount) {
- doIfOrElse(session => Settings.authType == AuthType.Anonymous) {
- exec(getRandomEntityAnonymous)
- } {
- exec(getRandomEntityWithToken)
- }
+ repeat(_ => Settings.endRequestCount.toInt) {
+ feed(uuidFeeder())
+ /*.exec {
+ session => println(s"UUID: ${session("uuid").as[String]}")
+ session
+ }*/
+ .doIfOrElse(_ => Settings.authType == AuthType.Anonymous) {
+ exec(getRandomEntityByUuidAnonymous)
+ } {
+ exec(getRandomEntityByUuidWithToken)
+ }
}
}
@@ -136,11 +190,15 @@ object EntityCollectionScenarios {
val loadEntity = exec(
doIf("${validEntity}", "yes") {
exec(http("POST load entity")
- .post(Settings.baseCollectionUrl)
+ .post(_ => "/" + Settings.collection)
.headers(Headers.authToken)
.body(StringBody("""${entity}"""))
// 200 for success, 400 if already exists
- .check(status.in(Seq(200))))
+ .check(status.in(Seq(200)), extractCreateUuid(SessionVarUuid)))
+ .exec(session => {
+ Settings.addUuid(session("entityNum").as[String], session(SessionVarUuid).as[String])
+ session
+ })
}
)
@@ -149,12 +207,14 @@ object EntityCollectionScenarios {
.exec(injectAuthType())
.asLongAs(session => session("validEntity").asOption[String].map(validEntity => validEntity != "no").getOrElse[Boolean](true)) {
feed(FeederGenerator.generateCustomEntityFeeder(Settings.numEntities, Settings.entityType, Settings.entityPrefix, Settings.entitySeed))
- .exec{
+ /*.exec{
session => if (session("validEntity").as[String] == "yes") { println("Loading entity #" + session("entityNum").as[String]) }
session
- }
+ }*/
.doIf(session => session("validEntity").as[String] == "yes") {
- exec(loadEntity)
+ tryMax(5) {
+ exec(loadEntity)
+ }
}
}
@@ -177,14 +237,14 @@ object EntityCollectionScenarios {
.exec {
session => if (session("validEntity").as[String] == "yes") { println("Deleting entity #" + session("entityNum").as[String]) }
session
- }
+ }
.doIf(session => session("validEntity").as[String] == "yes") {
- exec(deleteEntity)
- }
+ exec(deleteEntity)
+ }
}
/*
- * Delete entities
+ * Update entities
*/
val updateEntity = exec(
http("UPDATE entity")
@@ -200,10 +260,10 @@ object EntityCollectionScenarios {
.exec(injectAuthType())
.asLongAs(session => session("validEntity").asOption[String].map(validEntity => validEntity != "no").getOrElse[Boolean](true)) {
feed(FeederGenerator.generateCustomEntityFeeder(Settings.numEntities, Settings.entityType, Settings.entityPrefix, Settings.entitySeed))
- .exec {
+ /*.exec {
session => if (session("validEntity").as[String] == "yes") { println("Updating entity #" + session("entityNum").as[String]) }
session
- }
+ }*/
.doIf(session => session("validEntity").as[String] == "yes") {
exec(updateEntity)
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 83a648e..65d0111 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
@@ -31,7 +31,7 @@ object EntityScenarios {
val getEntity = exec(
http("GET custom entity")
- .get(Settings.baseAppUrl+"/${collectionType}/${entityName}")
+ .get("/${collection}/${entityName}")
.headers(Headers.authAnonymous)
.check(status.is(200))
)
@@ -39,7 +39,7 @@ object EntityScenarios {
// not sure why I have to put stringToExpression -- thought String -> Expression[String] conversion would be automatic
val putEntity = exec(
http("Put custom entity")
- .put(stringToExpression(Settings.baseAppUrl + "/${collectionType}/${entityName}"))
+ .put("/${collection}/${entityName}")
.body(StringBody("""${entity}"""))
.headers(Headers.auth("${authType}"))
.check(status.is(200))
@@ -48,14 +48,14 @@ object EntityScenarios {
val deleteEntity = exec(
http("DELETE custom entity")
- .get(Settings.baseAppUrl + "/${collectionType}/${entityName}")
+ .delete("/${collection}/${entityName}")
.headers(Headers.auth("${authType}"))
.check(status.is(200))
)
val postEntity = exec(
http("Post custom entity")
- .post(stringToExpression(Settings.baseAppUrl + "/${collectionType}"))
+ .post("/${collection}")
.body(StringBody("""${entity}"""))
.headers(Headers.auth("${authType}"))
.check(status.is(200))
@@ -64,7 +64,7 @@ object EntityScenarios {
/*
val postEntityWithToken = exec(
http("Post custom entity")
- .post(stringToExpression(Settings.baseAppUrl + "/${collectionType}"))
+ .post("/${collection}")
.body(StringBody("""${entity}"""))
.headers(Headers.authToken)
.check(status.is(200))
@@ -72,7 +72,7 @@ object EntityScenarios {
val postEntityWithBasicAuth = exec(
http("Post custom entity")
- .post(stringToExpression(Settings.baseAppUrl + "/${collectionType}"))
+ .post("/${collection}")
.body(StringBody("""${entity}"""))
.headers(Headers.authBasic)
.check(status.is(200))
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 85c6855..d7b108e 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
@@ -40,8 +40,8 @@ object GeoScenarios {
val updateGeolocation = exec(
http("PUT user location")
- .put(stringToExpression("/users/user" + Utils.generateRandomInt(1, Settings.totalUsers)))
- .body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"}}"))
+ .put(_ => "/users/user" + Utils.generateRandomInt(1, Settings.totalUsers))
+ .body(StringBody("""{ "location": { "latitude": "${latitude}", "longitude": "${longitude}"} }"""))
.headers(Headers.authToken)
.check(status.is(200))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 5471426..738c43a 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
@@ -48,21 +48,21 @@ object NotificationScenarios {
* send the notification now
*/
val sendNotification = exec(http("Send Single Notification")
- .post("/devices/${entityName}/notifications")
- .body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
- .headers(Headers.authToken)
- .check(status.is(200))
- )
+ .post("/devices/${entityName}/notifications")
+ .body(StringBody(_ => """{ "payloads": { """" + notifier + """": "testmessage"} }"""))
+ .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\"}}"))
+ .body(StringBody(_ => """{ "payloads": {"""" + notifier + """": "testmessage"} }"""))
.headers(Headers.authToken)
.check(status.is(200))
)
- val userFeeder = Settings.getInfiniteUserFeeder()
+ val userFeeder = Settings.getInfiniteUserFeeder
val createScenario = scenario("Create Push Notification")
.feed(userFeeder)
.exec(TokenScenarios.getUserToken)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 9718ad3..11f57bd 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
@@ -54,13 +54,13 @@ object NotifierScenarios {
)
.exec(http("Create Notifier")
- .post(Settings.baseAppUrl+"/notifiers")
- .headers(Headers.authToken)
- .body(StringBody("{\"name\":\"" + notifier + "\",\"provider\":\"" + provider + "\"}"))
- .check(status.in(200 to 400)))
+ .post("/notifiers")
+ .headers(Headers.authToken)
+ .body(StringBody(_ => """{ "name": """" + notifier + """", "provider": """" + provider + """"}"""))
+ .check(status.in(Range(200,400))))
val checkNotifier = exec(http("Get Notifier")
- .get(Settings.baseAppUrl+"/notifiers/"+notifier)
+ .get("/notifiers/"+notifier)
.headers(Headers.authToken)
.check(status.is(200),status.saveAs("notifierStatus"))
)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 0c1beef..3e6593d 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
@@ -36,10 +36,10 @@ object OrganizationScenarios {
//register the org with the randomly generated org
val createOrgAndAdmin =
exec(http("Create Organization")
- .post(Settings.baseUrl + "/management/organizations")
+ .post(_ => Settings.baseUrl + "/management/organizations")
.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))
+ .body(StringBody(session => """{ "organization": """" + Settings.org + """", "username": """" + Settings.adminUser + """", "name": "${entityName}", "email": "${entityName}@apigee.com", "password":"""" + Settings.adminPassword + """" }"""))
+ .check(status.in(Range(200,400)))
)
val createOrgBatch =
feed(FeederGenerator.generateRandomEntityNameFeeder("org", 1))
@@ -49,7 +49,7 @@ object OrganizationScenarios {
.exec(NotifierScenarios.createNotifier)
.exec(session => {
// print the Session for debugging, don't do that on real Simulations
- println(session)
+ // println(session)
session
})
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 d0eca02..c7ff4db 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
@@ -39,10 +39,10 @@ import org.apache.usergrid.settings.Settings
object TokenScenarios {
val getManagementToken = exec(http("POST Org Token")
- .post(Settings.baseUrl+"/management/token")
+ .post(_ => Settings.baseUrl + "/management/token")
.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.adminUser + "\",\"password\":\""+Settings.adminPassword+"\",\"grant_type\":\"password\"}"))
+ .body(StringBody(_ => """{ "username": """" + Settings.adminUser + """", "password": """" + Settings.adminPassword + """", "grant_type": "password" }"""))
.check(jsonPath("$.access_token").find(0).saveAs("authToken"))
)
@@ -50,7 +50,7 @@ object TokenScenarios {
exec(
http("POST user token")
.post("/token")
- .body(StringBody("{\"grant_type\":\"password\",\"username\":\"${username}\",\"password\":\"password\"}"))
+ .body(StringBody("""{ "grant_type": "password", "username": "${username}", "password": "password" }"""))
.check(status.is(200),jsonPath("$..access_token").exists,jsonPath("$..access_token").saveAs("authToken"))
)
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 a55f66a..7269af7 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
@@ -68,7 +68,7 @@ object UserScenarios {
exec(
http("POST geolocated Users")
.post("/users")
- .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ .body(StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
"displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
"height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
"showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
@@ -91,7 +91,7 @@ object UserScenarios {
http("PUT geolocated Users")
.put("/users/${username}")
.headers(Headers.authToken)
- .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ .body(StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
"displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
"height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
"showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
@@ -156,7 +156,7 @@ object UserScenarios {
* Logs in as the user, then creates 2 devices if they do not exist
*/
val createUsersWithDevicesScenario = scenario("Create Users")
- .feed(Settings.getInfiniteUserFeeder())
+ .feed(Settings.getInfiniteUserFeeder)
.exec(TokenScenarios.getManagementToken)
.exec(UserScenarios.postUserIfNotExists)
.exec(TokenScenarios.getUserToken)
@@ -170,7 +170,7 @@ object UserScenarios {
* Posts a new user every time
*/
val postUsersInfinitely = scenario("Post Users")
- .feed(Settings.getInfiniteUserFeeder())
+ .feed(Settings.getInfiniteUserFeeder)
.exec(postUser)
@@ -178,14 +178,14 @@ object UserScenarios {
* Puts a new user every time
*/
val putUsersInfinitely = scenario("Put Users").exec(injectManagementTokenIntoSession)
- .feed(Settings.getInfiniteUserFeeder())
+ .feed(Settings.getInfiniteUserFeeder)
.exec(putUser)
/**
* Deletes user every time
*/
val deleteUsersInfinitely = scenario("Delete Users").exec(injectManagementTokenIntoSession)
- .feed(Settings.getInfiniteUserFeeder())
+ .feed(Settings.getInfiniteUserFeeder)
.exec(deleteUser)
/**
@@ -202,7 +202,7 @@ object UserScenarios {
})
val getUsersByUsername = scenario("Get User By Username").exec(injectManagementTokenIntoSession)
- .feed(Settings.getInfiniteUserFeeder())
+ .feed(Settings.getInfiniteUserFeeder)
//get users without a cursor
.exec(getUserByUsername)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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 cca3056..dc7ff73 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,55 +16,89 @@
*/
package org.apache.usergrid.settings
+import java.io.{PrintWriter, FileOutputStream}
import java.nio.charset.StandardCharsets
import java.util.{Date, Base64}
import io.gatling.http.Predef._
+import io.gatling.http.config.HttpProtocolBuilder
import org.apache.usergrid.datagenerators.FeederGenerator
import org.apache.usergrid.enums._
import org.apache.usergrid.helpers.Utils
object Settings {
+ def initStrSetting(cfg: String): String = {
+ val setting = System.getProperty(cfg)
+
+ if (setting != null) setting else ConfigProperties.getDefault(cfg).toString
+ }
+
+ def initBoolSetting(cfg: String): Boolean = {
+ val strSetting = System.getProperty(cfg)
+ val default:Boolean = ConfigProperties.getDefault(cfg).asInstanceOf[Boolean]
+
+ if (strSetting != null) {
+ if (default) // default is true
+ strSetting.toLowerCase != "false"
+ else // default is false
+ strSetting.toLowerCase == "true"
+ } else {
+ default
+ }
+ }
+
+ def initIntSetting(cfg: String): Int = {
+ val integerSetting:Integer = Integer.getInteger(cfg)
+
+ if (integerSetting != null)
+ integerSetting.toInt
+ else
+ ConfigProperties.getDefault(cfg).asInstanceOf[Int]
+ }
+
// 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 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 = !skipSetup && (System.getProperty(ConfigProperties.CreateOrg) == "true")
- val createApp:Boolean = !skipSetup && (System.getProperty(ConfigProperties.CreateApp) != "false")
- val loadEntities:Boolean = !skipSetup && (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 org = initStrSetting(ConfigProperties.Org)
+ val app = initStrSetting(ConfigProperties.App)
+ val adminUser = initStrSetting(ConfigProperties.AdminUser)
+ val adminPassword = initStrSetting(ConfigProperties.AdminPassword)
+
+ private val cfgBaseUrl = initStrSetting(ConfigProperties.BaseUrl)
+ val baseUrl = if (cfgBaseUrl.takeRight(1) == "/") cfgBaseUrl.dropRight(1) else cfgBaseUrl
+ val baseAppUrl:String = baseUrl + "/" + org + "/" + app
+
+ val httpConf: HttpProtocolBuilder = http.baseURL(baseAppUrl)
+ val authType = initStrSetting(ConfigProperties.AuthType)
+ val tokenType = initStrSetting(ConfigProperties.TokenType)
+
+ val skipSetup:Boolean = initBoolSetting(ConfigProperties.SkipSetup)
+ val createOrg:Boolean = !skipSetup && initBoolSetting(ConfigProperties.CreateOrg)
+ val createApp:Boolean = !skipSetup && initBoolSetting(ConfigProperties.CreateApp)
+ val loadEntities:Boolean = !skipSetup && initBoolSetting(ConfigProperties.LoadEntities)
+ val sandboxCollection:Boolean = initBoolSetting(ConfigProperties.SandboxCollection)
+ val scenarioType = initStrSetting(ConfigProperties.ScenarioType)
+
+ val rampUsers:Int = initIntSetting(ConfigProperties.RampUsers)
+ val constantUsersPerSec:Int = initIntSetting(ConfigProperties.ConstantUsersPerSec) // users to add per second during constant injection
+ val constantUsersDuration:Int = initIntSetting(ConfigProperties.ConstantUsersDuration) // 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 userSeed:Int = initIntSetting(ConfigProperties.UserSeed)
+ val appUser = initStrSetting(ConfigProperties.AppUser)
+ val appUserPassword = initStrSetting(ConfigProperties.AppUserPassword)
val appUserBase64 = Base64.getEncoder.encodeToString((appUser + ":" + appUserPassword).getBytes(StandardCharsets.UTF_8))
- var numEntities:Int = Integer.getInteger(ConfigProperties.NumEntities, 5000).toInt
- val totalNumEntities:Int = numEntities
- val numDevices:Int = Integer.getInteger(ConfigProperties.NumDevices, 4000).toInt
+ val totalNumEntities:Int = initIntSetting(ConfigProperties.NumEntities)
+ val numDevices:Int = initIntSetting(ConfigProperties.NumDevices)
- val collectionType = System.getProperty(ConfigProperties.CollectionType, "customentities")
- val baseCollectionUrl = baseAppUrl + "/" + collectionType
+ val collection = initStrSetting(ConfigProperties.Collection)
+ val baseCollectionUrl = baseAppUrl + "/" + collection
- 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
+ val rampTime:Int = initIntSetting(ConfigProperties.RampTime) // in seconds
+ val throttle:Int = initIntSetting(ConfigProperties.Throttle) // in seconds
+ val rpsTarget:Int = initIntSetting(ConfigProperties.RpsTarget) // requests per second target
+ val rpsRampTime:Int = initIntSetting(ConfigProperties.RpsRampTime) // in seconds
+ val holdDuration:Int = initIntSetting(ConfigProperties.HoldDuration) // in seconds
// Geolocation settings
val centerLatitude:Double = 37.442348 // latitude of center point
@@ -73,78 +107,119 @@ object Settings {
val geoSearchRadius:Int = 8000 // search area in meters
// Push Notification settings
- val pushNotifier = System.getProperty(ConfigProperties.PushNotifier, "loadNotifier")
- val pushProvider = System.getProperty(ConfigProperties.PushProvider, "noop")
+ val pushNotifier = initStrSetting(ConfigProperties.PushNotifier)
+ val pushProvider = initStrSetting(ConfigProperties.PushProvider)
// Large Entity Collection settings
- val entityPrefix = System.getProperty(ConfigProperties.EntityPrefix, "entity")
- val entityType = System.getProperty(ConfigProperties.EntityType, EntityType.Basic) // basic/trivial/?
- var entitySeed = Integer.getInteger(ConfigProperties.EntitySeed, 1).toInt
- val overallEntitySeed = entitySeed
- 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
+ val entityPrefix = initStrSetting(ConfigProperties.EntityPrefix)
+ val entityType = initStrSetting(ConfigProperties.EntityType) // basic/trivial/?
+ val overallEntitySeed = initIntSetting(ConfigProperties.EntitySeed)
+ val searchLimit:Int = initIntSetting(ConfigProperties.SearchLimit)
+ val searchQuery = initStrSetting(ConfigProperties.SearchQuery)
+ val endConditionType = initStrSetting(ConfigProperties.EndConditionType)
+ val endMinutes:Int = initIntSetting(ConfigProperties.EndMinutes)
+ val endRequestCount:Int = initIntSetting(ConfigProperties.EndRequestCount)
// Org creation fields
- val orgCreationUsername = System.getProperty(ConfigProperties.OrgCreationUsername, org.concat("_admin"))
- val orgCreationEmail = System.getProperty(ConfigProperties.OrgCreationEmail, orgCreationUsername.concat("@usergrid.com"))
- val orgCreationName = System.getProperty(ConfigProperties.OrgCreationName, orgCreationUsername)
- val orgCreationPassword = System.getProperty(ConfigProperties.OrgCreationPassword, "test")
+ private val cfgOrgCreationUsername = initStrSetting(ConfigProperties.OrgCreationUsername)
+ private val cfgOrgCreationEmail = initStrSetting(ConfigProperties.OrgCreationEmail)
+ private val cfgOrgCreationName = initStrSetting(ConfigProperties.OrgCreationName)
+ val orgCreationUsername = if (cfgOrgCreationUsername == "") org.concat("_admin") else cfgOrgCreationUsername
+ val orgCreationEmail = if (cfgOrgCreationEmail == "") orgCreationUsername.concat("@usergrid.com") else cfgOrgCreationEmail
+ val orgCreationName = if (cfgOrgCreationName == "") orgCreationUsername else cfgOrgCreationName
+ val orgCreationPassword = initStrSetting(ConfigProperties.OrgCreationPassword)
// Entity update
- val updateProperty = System.getProperty(ConfigProperties.UpdateProperty, "updateProp")
- val updateValue = System.getProperty(ConfigProperties.UpdateValue, new Date().toString)
+ val updateProperty = initStrSetting(ConfigProperties.UpdateProperty)
+ val updateValue = initStrSetting(ConfigProperties.UpdateValue)
val updateBody = Utils.toJSONStr(Map(updateProperty -> updateValue))
// Entity workers
- val entityWorkerCount = Integer.getInteger(ConfigProperties.EntityWorkerCount,1)
- val entityWorkerNum = Integer.getInteger(ConfigProperties.EntityWorkerNum, 1)
-
- if (entityWorkerCount > 1 && entityWorkerNum >= 1 && entityWorkerNum <= entityWorkerCount) {
- // split entities across multiple workers
- val entitiesPerWorkerFloor = totalNumEntities / entityWorkerCount
- val leftOver = totalNumEntities % entityWorkerCount
- val zeroBasedWorkerNum = entityWorkerNum - 1
- val takeExtraEntity = if (entityWorkerNum <= leftOver) 1 else 0
- entitySeed = overallEntitySeed + zeroBasedWorkerNum * entitiesPerWorkerFloor + (if (takeExtraEntity == 1) zeroBasedWorkerNum else leftOver)
- numEntities = entitiesPerWorkerFloor + takeExtraEntity
+ private val cfgEntityWorkerCount:Int = initIntSetting(ConfigProperties.EntityWorkerCount)
+ private val cfgEntityWorkerNum:Int = initIntSetting(ConfigProperties.EntityWorkerNum)
+ val useWorkers:Boolean = cfgEntityWorkerCount > 1 && cfgEntityWorkerNum >= 1 && cfgEntityWorkerNum <= cfgEntityWorkerCount
+ val entityWorkerCount:Int = if (useWorkers) cfgEntityWorkerCount else 1
+ val entityWorkerNum:Int = if (useWorkers) cfgEntityWorkerNum else 1
+
+ // if only one worker system, these numbers will still be fine
+ private val entitiesPerWorkerFloor:Int = totalNumEntities / entityWorkerCount
+ private val leftOver:Int = totalNumEntities % entityWorkerCount // will be 0 if only one worker
+ private val extraEntity:Int = if (entityWorkerNum <= leftOver) 1 else 0
+ private val zeroBasedWorkerNum:Int = entityWorkerNum - 1
+ val entitySeed:Int = overallEntitySeed + zeroBasedWorkerNum * entitiesPerWorkerFloor + (if (extraEntity == 1) zeroBasedWorkerNum else leftOver)
+ val numEntities:Int = entitiesPerWorkerFloor + extraEntity
+
+ // UUID log file, have to go through this because creating a csv feeder with an invalid csv file fails at maven compile time
+ private val dummyCsv = ConfigProperties.getDefault(ConfigProperties.UuidFilename).toString
+ private val uuidFilename = initStrSetting(ConfigProperties.UuidFilename)
+ val captureUuids = uuidFilename != dummyCsv && scenarioType == ScenarioType.LoadEntities
+ val feedUuids = uuidFilename != dummyCsv && scenarioType == ScenarioType.UuidRandomInfinite
+ val captureUuidFilename = if (captureUuids) uuidFilename else dummyCsv
+ val feedUuidFilename = if (feedUuids) uuidFilename else dummyCsv
+ val purgeUsers:Int = initIntSetting(ConfigProperties.PurgeUsers)
+
+ private var uuidMap: Map[String, String] = Map()
+ def addUuid(name: String, uuid: String): Unit = {
+ if (captureUuids) uuidMap += (name -> uuid)
+ // println(s"UUID: ${name},${uuid}")
+ }
+
+ def writeUuidsToFile(): Unit = {
+ if (captureUuids) {
+ val writer = {
+ val fos = new FileOutputStream(captureUuidFilename)
+ new PrintWriter(fos, false)
+ }
+ writer.println("name,uuid")
+ uuidMap.keys.foreach { name =>
+ writer.println(s"${Settings.entityPrefix}${name},${uuidMap(name)}")
+ }
+ writer.flush()
+ writer.close()
+ }
}
- def getUserFeeder():Array[Map[String, String]]= {
+ def getUserFeeder:Array[Map[String, String]]= {
FeederGenerator.generateUserWithGeolocationFeeder(totalUsers, userLocationRadius, centerLatitude, centerLongitude)
}
- def getInfiniteUserFeeder():Iterator[Map[String, String]]= {
+ def getInfiniteUserFeeder:Iterator[Map[String, String]]= {
FeederGenerator.generateUserWithGeolocationFeederInfinite(userSeed, userLocationRadius, centerLatitude, centerLongitude)
}
- var testStartTime = System.currentTimeMillis()
+ private var testStartTime: Long = System.currentTimeMillis()
+
+ def getTestStartTime: Long = {
+ testStartTime
+ }
def setTestStartTime(): Unit = {
testStartTime = System.currentTimeMillis()
}
+ def continueMinutesTest: Boolean = {
+ (System.currentTimeMillis() - testStartTime) < (endMinutes.toLong*60L*1000L)
+ }
+
def printSettingsSummary(): Unit = {
- val authTypeStr = authType + (if (authType == AuthType.Token) s"(${tokenType})" else "")
- val endConditionStr = if (endConditionType == EndConditionType.MinutesElapsed) s"${endMinutes} minutes elapsed" else s"${endRequestCount} requests"
+ val authTypeStr = authType + (if (authType == AuthType.Token) s"($tokenType)" else "")
+ val endConditionStr = if (endConditionType == EndConditionType.MinutesElapsed) s"$endMinutes minutes elapsed" else s"$endRequestCount requests"
println("-----------------------------------------------------------------------------")
println("SIMULATION SETTINGS")
println("-----------------------------------------------------------------------------")
println()
- println(s"Org:${org} App:${app} Collection:${collectionType}")
- println(s"CreateOrg:${createOrg} CreateApp:${createApp} LoadEntities:${loadEntities}")
- println(s"ScenarioType:${scenarioType} AuthType:${authTypeStr}")
+ println(s"Org:$org App:$app Collection:$collection")
+ println(s"CreateOrg:$createOrg CreateApp:$createApp LoadEntities:$loadEntities")
+ println(s"ScenarioType:$scenarioType AuthType:$authTypeStr")
println()
- println(s"Entity Type:${entityType} Prefix:${entityPrefix}")
+ println(s"Entity Type:$entityType Prefix:$entityPrefix")
println()
- println(s"Overall: NumEntities:${totalNumEntities} Seed:${overallEntitySeed} Workers:${entityWorkerCount}")
- println(s"Worker: NumEntities:${numEntities} Seed:${entitySeed} WorkerNum:${entityWorkerNum}")
+ println(s"Overall: NumEntities:$totalNumEntities Seed:$overallEntitySeed Workers:$entityWorkerCount")
+ println(s"Worker: NumEntities:$numEntities Seed:$entitySeed WorkerNum:$entityWorkerNum")
println()
- println(s"Ramp: Users:${rampUsers} Time:${rampTime}")
- println(s"Constant: UsersPerSec:${constantUsersPerSec} Time:${constantUsersDuration}")
- println(s"End Condition:${endConditionStr}")
+ println(s"Ramp: Users:$rampUsers Time:$rampTime")
+ println(s"Constant: UsersPerSec:$constantUsersPerSec Time:$constantUsersDuration")
+ println(s"End Condition:$endConditionStr")
println()
println("-----------------------------------------------------------------------------")
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/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
index 8151cb1..da5189e 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConfigurableSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/ConfigurableSimulation.scala
@@ -29,7 +29,7 @@ import org.apache.usergrid.settings.Settings
* Configuration items:
* skipSetup, createOrg, org, createApp, app, adminUser, adminPassword, baseUrl,
* numEntities, entityType, entityPrefix, entitySeed, rampUsers, rampTime,
- * constantUsersPerSec, constantUsersDuration, collectionType, scenarioType
+ * constantUsersPerSec, constantUsersDuration, collection, scenarioType
*
* getAllByCursor scenario: searchQuery, searchLimit
*/
@@ -42,10 +42,11 @@ class ConfigurableSimulation extends Simulation {
case ScenarioType.UpdateEntities => EntityCollectionScenarios.updateEntities
case ScenarioType.GetAllByCursor => EntityCollectionScenarios.getEntityPagesToEnd
case ScenarioType.NameRandomInfinite => EntityCollectionScenarios.getRandomEntitiesByName
+ case ScenarioType.UuidRandomInfinite => EntityCollectionScenarios.getRandomEntitiesByUuid
}
}
- before(
+ before{
if (!Settings.skipSetup) {
println("Begin setup")
if (Settings.createOrg) Setup.setupOrg()
@@ -54,7 +55,8 @@ class ConfigurableSimulation extends Simulation {
} else {
println("Skipping setup")
}
- )
+ if (Settings.sandboxCollection) Setup.sandboxCollection()
+ }
Settings.setTestStartTime()
if (ScenarioType.isValid(Settings.scenarioType)) {
@@ -70,9 +72,10 @@ class ConfigurableSimulation extends Simulation {
println(s"scenarioType ${Settings.scenarioType} not found.")
}
- after(
+ after {
+ if (Settings.captureUuids) Settings.writeUuidsToFile()
Settings.printSettingsSummary()
- )
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PostCustomEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PostCustomEntitySimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PostCustomEntitySimulation.scala
index 9369489..2db4160 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PostCustomEntitySimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PostCustomEntitySimulation.scala
@@ -30,7 +30,7 @@ import org.apache.usergrid.settings.Settings
* PostCustomEntitySimulation - creates lots of custom entities
*
* Run this way:
- * mvn gatling:execute -DrampTime=10 -DmaxPossibleUsers=10 -Dduration=120 -Dorg=yourorgname -Dapp=sandbox -Dbaseurl=https://api.usergrid.com -DadminUser=yourusername -DadminPassword='yourpassword' -Dgatling.simulationClass=org.apache.usergrid.simulations.deprecated.PostCustomEntitySimulation -DcollectionType=yourcollection
+ * 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.deprecated.PostCustomEntitySimulation -Dcollection=yourcollection
*
*
*/
@@ -46,8 +46,8 @@ class PostCustomEntitySimulation extends Simulation {
}
val numEntities:Int = Settings.numEntities
- val collectionType = Settings.collectionType
- println("collection type = " + collectionType)
+ val collection = Settings.collection
+ println("collection type = " + collection)
val rampTime:Int = Settings.rampTime
val throttle:Int = Settings.throttle
val feeder = FeederGenerator.generateCustomEntityInfinite(0)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PutCustomEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PutCustomEntitySimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PutCustomEntitySimulation.scala
index bffed0f..57e4faf 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PutCustomEntitySimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/deprecated/PutCustomEntitySimulation.scala
@@ -29,7 +29,7 @@ import org.apache.usergrid.settings.Settings
* PostCustomEntitySimulation - creates lots of custom entities
*
* Run this way:
- * mvn gatling:execute -DrampTime=10 -DmaxPossibleUsers=10 -Dduration=120 -Dorg=yourorgname -Dapp=sandbox -Dbaseurl=https://api.usergrid.com -DadminUser=yourusername -DadminPassword='yourpassword' -Dgatling.simulationClass=org.apache.usergrid.simulations.deprecated.PostCustomEntitySimulation -DcollectionType=yourcollection
+ * 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.deprecated.PostCustomEntitySimulation -Dcollection=yourcollection
*
*
*/
@@ -45,8 +45,8 @@ class PutCustomEntitySimulation extends Simulation {
}
val numEntities:Int = Settings.numEntities
- val collectionType = Settings.collectionType
- println("collection type = " + collectionType)
+ val collection = Settings.collection
+ println("collection type = " + collection)
val rampTime:Int = Settings.rampTime
val throttle:Int = Settings.throttle
val feeder = FeederGenerator.generateCustomEntityPutInfinite(0)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/src/test/resources/dummy.csv
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/dummy.csv b/stack/loadtests/src/test/resources/dummy.csv
new file mode 100644
index 0000000..187f36b
--- /dev/null
+++ b/stack/loadtests/src/test/resources/dummy.csv
@@ -0,0 +1 @@
+name,uuid
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/src/test/resources/logback-test.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/logback-test.xml b/stack/loadtests/src/test/resources/logback-test.xml
index 6a188ab..5ad4ea3 100644
--- a/stack/loadtests/src/test/resources/logback-test.xml
+++ b/stack/loadtests/src/test/resources/logback-test.xml
@@ -26,11 +26,11 @@
</appender>
<!-- Uncomment for logging ALL HTTP request and responses -->
- <!-- <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="TRACE" /> -->
+ <!-- <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="TRACE" /> -->
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
- <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="DEBUG" />
+ <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="DEBUG" />
-<logger name="io.gatling.http" level="TRACE" />
+<!-- <logger name="io.gatling.http" level="TRACE" /> -->
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
<root level="WARN">
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/af446bee/stack/loadtests/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/test/resources/logback.xml b/stack/loadtests/src/test/resources/logback.xml
index 6ba218c..232d333 100644
--- a/stack/loadtests/src/test/resources/logback.xml
+++ b/stack/loadtests/src/test/resources/logback.xml
@@ -27,9 +27,9 @@
</appender>
<!-- Uncomment for logging ALL HTTP request and responses -->
- <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="TRACE" />
+ <!-- <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="TRACE" /> -->
<!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
- <!--<logger name="io.gatling.http.ahc.AsyncHandlerActor" level="DEBUG" />-->
+ <logger name="io.gatling.http.ahc.AsyncHandlerActor" level="DEBUG" />
<root level="WARN">
<appender-ref ref="CONSOLE" />