Added a nested entity to gatling tests
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/44bcbc47 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/44bcbc47 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/44bcbc47 Branch: refs/heads/master Commit: 44bcbc47e82e93a957f815e1ceeb866f63953bf8 Parents: 74de4bc Author: George Reyes <[email protected]> Authored: Mon Apr 11 12:41:30 2016 -0700 Committer: George Reyes <[email protected]> Committed: Mon Apr 11 12:41:30 2016 -0700 ---------------------------------------------------------------------- tests/performance/runLoadNestedEntities.sh | 98 ++++++++++++++++++++ .../datagenerators/EntityDataGenerator.scala | 40 ++++++++ .../org/apache/usergrid/enums/EntityType.scala | 3 +- 3 files changed, 140 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/44bcbc47/tests/performance/runLoadNestedEntities.sh ---------------------------------------------------------------------- diff --git a/tests/performance/runLoadNestedEntities.sh b/tests/performance/runLoadNestedEntities.sh new file mode 100755 index 0000000..02fa71e --- /dev/null +++ b/tests/performance/runLoadNestedEntities.sh @@ -0,0 +1,98 @@ +#!/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. + + +DIR="${BASH_SOURCE%/*}" +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi +. "$DIR/testConfig.sh" + +# from testConfig.sh +#URL= +#ADMIN_USER= +#ADMIN_PASSWORD= +#ENTITY_WORKER_NUM= #may be overridden on command line +#ENTITY_WORKER_COUNT= #may be overridden on command line +#ORG= +#APP= +#AUTH_TYPE= +#TOKEN_TYPE= +#CREATE_ORG= +#CREATE_APP= +#SANDBOX_COLLECTION= +#NUM_ENTITIES= #may be overridden on command line +#SKIP_SETUP= +#COLLECTION= +#ENTITY_SEED= #may be overridden on command line +#RETRY_COUNT= +#ENTITY_PROGRESS_COUNT= +#CONSTANT_USERS_PER_SEC= +#CONSTANT_USERS_DURATION= + + +die() { echo "$@" 1>&2 ; exit 1; } + +[ "$#" -ge 2 ] || die "At least 2 arguments required, $# provided. Example is $0 RAMP_USERS RAMP_TIME(seconds) [UUID_FILENAME [NUM_ENTITIES [ENTITY_SEED [ENTITY_WORKER_NUM [ENTITY_WORKER_COUNT]]]]]" + +RAMP_USERS="$1" +RAMP_TIME="$2" +[ "$#" -ge 3 ] && UUID_FILENAME="$3" +[ "$#" -ge 4 ] && NUM_ENTITIES="$4" +[ "$#" -ge 5 ] && ENTITY_SEED="$5" +[ "$#" -ge 6 ] && ENTITY_WORKER_NUM="$6" +[ "$#" -ge 7 ] && ENTITY_WORKER_COUNT="$7" + +shift $# + +SCENARIO_TYPE=loadEntities +ENTITY_TYPE=nested +ENTITY_PREFIX=nestedval + +# don't load entities as part of setup (loading entities is the point of the test) +LOAD_ENTITIES=false + +#Compile everything +mvn compile + +#Execute the test +mvn gatling:execute \ +-DbaseUrl=${URL} \ +-DadminUser=${ADMIN_USER} \ +-DadminPassword=${ADMIN_PASSWORD} \ +-DentityWorkerNum=${ENTITY_WORKER_NUM} \ +-DentityWorkerCount=${ENTITY_WORKER_COUNT} \ +-Dorg=${ORG} \ +-Dapp=${APP} \ +-DauthType=${AUTH_TYPE} \ +-DtokenType=${TOKEN_TYPE} \ +-DcreateOrg=${CREATE_ORG} \ +-DcreateApp=${CREATE_APP} \ +-DsandboxCollection=${SANDBOX_COLLECTION} \ +-DnumEntities=${NUM_ENTITIES} \ +-DskipSetup=${SKIP_SETUP} \ +-Dcollection=${COLLECTION} \ +-DentitySeed=${ENTITY_SEED} \ +-DretryCount=${RETRY_COUNT} \ +-DentityProgressCount=${ENTITY_PROGRESS_COUNT} \ +-DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC} \ +-DconstantUsersDuration=${CONSTANT_USERS_DURATION} \ +-DscenarioType=${SCENARIO_TYPE} \ +-DentityType=${ENTITY_TYPE} \ +-DentityPrefix=${ENTITY_PREFIX} \ +-DloadEntities=${LOAD_ENTITIES} \ +-DrampUsers=${RAMP_USERS} \ +-DrampTime=${RAMP_TIME} \ +-DuuidFilename=${UUID_FILENAME} \ +-DprintFailedRequests=${PRINT_FAILED_REQUESTS} \ +-Dgatling.simulationClass=org.apache.usergrid.simulations.ConfigurableSimulation + http://git-wip-us.apache.org/repos/asf/usergrid/blob/44bcbc47/tests/performance/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala ---------------------------------------------------------------------- diff --git a/tests/performance/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala b/tests/performance/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala index 326a319..b0d4f46 100755 --- a/tests/performance/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala +++ b/tests/performance/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala @@ -108,6 +108,45 @@ object EntityDataGenerator { new JSONObject(Map("sortField" -> Utils.generateRandomInt(1,10000000))).toString() } + def generateNestedEntity(name: String = null): String = { + + new JSONObject(Map("magicData"-> + new JSONObject( + Map( + "level1" -> "level1", + "level2" -> "level2", + "level3" -> "level3", + "level4" -> + new JSONObject( + Map( + "level5" -> "level5", + "level6" -> "level6", + "level7" -> "level7", + "level8" -> + new JSONObject( + Map( + "level9" -> "level9", + "level10" -> "level10", + "level11" -> "level11", + "level12" -> + new JSONObject( + Map( + "level13" -> "level13", + "level14" -> "level14", + "level15" -> "level15", + "level16" -> "level16" + ) + ) + ) + ) + ) + ) + ) + ) + ) + ).toString() + } + val pirate1KString = "Yarrrrrrrrrrrrrrrr! Blimey! Avast ye scurvy dog! Dead men tell no tales. Hang him from the yardarm! Heave ho! Run a shot across the bow. Yo-ho-ho and a bottle of rum. Heave ho ye scallywag, or ye shall walk the plank! Weigh anchor and hoist the mizzen! Thar she blows! Shiver me timbers! Splice the mainbrace! Keelhaul the hornswaggler! Raise the Jolly Roger! Feed him to the fish! You fight like a dairy farmer. How appropriate, you fight like a cow. Batten down the hatches! Blow the man down! Swab the deck! Ahoy, matey! I'll crush ye barnacles! Fetch me grog! Gangway! Arrr, he's gone to Davy Jones's Locker. He be three sheets to the wind. Yo-ho me hearties! Prepare to be boarded! All your pieces of eight, else ye meet me cat o'nine tails! Bring 'er alongside! The rougher the seas, the smoother we sail! It's more fun to be a pirate than to join the navy. The beatings will continue until morale improves! Fifteen men on the dead man's chest! I be the captain of th is ship -- swab the decks! " def generateLargeMultiFieldEntity(name: String = null, entityNum: Int = 0): String = { @@ -157,6 +196,7 @@ object EntityDataGenerator { case EntityType.TrivialSortable => generateTrivialSortableEntity(entityName) case EntityType.Basic => generateBasicEntity(entityName) case EntityType.LargeMultiField => generateLargeMultiFieldEntity(entityName, entityNum) + case EntityType.Nested => generateNestedEntity(null) } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/44bcbc47/tests/performance/src/main/scala/org/apache/usergrid/enums/EntityType.scala ---------------------------------------------------------------------- diff --git a/tests/performance/src/main/scala/org/apache/usergrid/enums/EntityType.scala b/tests/performance/src/main/scala/org/apache/usergrid/enums/EntityType.scala index 277cd04..c1e8ce8 100644 --- a/tests/performance/src/main/scala/org/apache/usergrid/enums/EntityType.scala +++ b/tests/performance/src/main/scala/org/apache/usergrid/enums/EntityType.scala @@ -20,9 +20,10 @@ object EntityType { val Trivial = "trivial" val TrivialSortable = "trivialSortable" val Basic = "basic" + val Nested = "nested" val LargeMultiField = "largeMultiField" - val Values = Seq(Trivial,TrivialSortable,Basic,LargeMultiField) + val Values = Seq(Trivial,TrivialSortable,Basic,LargeMultiField,Nested) def isValid(str: String): Boolean = { Values.contains(str)
