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:31:01 UTC

[17/21] incubator-usergrid git commit: USERGRID-871: fix cursor query test

USERGRID-871: fix cursor query test


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

Branch: refs/heads/two-dot-o-dev
Commit: 3976ff98f12b38c223a2d618824da83161c1d055
Parents: 15c1c59
Author: Mike Dunker <md...@apigee.com>
Authored: Fri Jul 31 10:41:20 2015 -0700
Committer: Mike Dunker <md...@apigee.com>
Committed: Fri Jul 31 10:41:20 2015 -0700

----------------------------------------------------------------------
 stack/loadtests/runCollectionQueryTest.sh       |  10 +-
 stack/loadtests/runLoadSortableEntities.sh      | 107 +++++++++++++++++++
 .../datagenerators/EntityDataGenerator.scala    |  33 +++---
 .../org/apache/usergrid/enums/EntityType.scala  |   3 +-
 .../apache/usergrid/helpers/Extractors.scala    |   2 +-
 .../src/test/resources/logback-test.xml         |   5 +-
 6 files changed, 138 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3976ff98/stack/loadtests/runCollectionQueryTest.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runCollectionQueryTest.sh b/stack/loadtests/runCollectionQueryTest.sh
index 9882cf2..85910e6 100755
--- a/stack/loadtests/runCollectionQueryTest.sh
+++ b/stack/loadtests/runCollectionQueryTest.sh
@@ -41,14 +41,14 @@ ORG=gatling
 CREATE_APP=false
 #APP=$(date +%s)
 APP=millionentities
-COLLECTION=basicentities
+COLLECTION=sortableentities
 SCENARIO_TYPE=getAllByCursor
 LOAD_ENTITIES=false
 NUM_ENTITIES=10000
 SKIP_SETUP=false
-SEARCH_QUERY=order%20by%20specials%20desc
-ENTITY_TYPE=basic
-ENTITY_PREFIX=basic
+SEARCH_QUERY=order%20by%20sortField%20desc
+ENTITY_TYPE=trivialSortable
+ENTITY_PREFIX=sortable
 ENTITY_SEED=1
 AUTH_TYPE=token
 TOKEN_TYPE=management
@@ -72,6 +72,8 @@ mvn gatling:execute -Dorg=usergrid \
 -DentityType=${ENTITY_TYPE} \
 -DentityPrefix=${ENTITY_PREFIX} \
 -DentitySeed=${ENTITY_SEED} \
+-DsearchQuery=${SEARCH_QUERY} \
+-DsearchLimit=${SEARCH_LIMIT} \
 -DrampUsers=${RAMP_USERS}  \
 -DrampTime=${RAMP_TIME}  \
 -DconstantUsersPerSec=${CONSTANT_USERS_PER_SEC}    \

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3976ff98/stack/loadtests/runLoadSortableEntities.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runLoadSortableEntities.sh b/stack/loadtests/runLoadSortableEntities.sh
new file mode 100755
index 0000000..5289b6a
--- /dev/null
+++ b/stack/loadtests/runLoadSortableEntities.sh
@@ -0,0 +1,107 @@
+#!/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 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"
+RAMP_TIME="$3"
+CONSTANT_USERS_PER_SEC="$4"
+CONSTANT_USERS_DURATION="$5"
+NUM_ENTITIES="$6"
+ENTITY_WORKER_NUM="$7"
+ENTITY_WORKER_COUNT="$8"
+UUID_FILENAME="$9"
+
+shift 9
+
+#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=sortableentities
+SANDBOX_COLLECTION=true
+SCENARIO_TYPE=loadEntities
+# don't load entities as part of setup
+LOAD_ENTITIES=false
+
+SKIP_SETUP=false
+#SEARCH_QUERY=order%20by%20specials%20desc
+#SEARCH_LIMIT=1000
+ENTITY_TYPE=trivialSortable
+ENTITY_PREFIX=sortable
+ENTITY_SEED=1
+AUTH_TYPE=token
+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} \
+-DentityWorkerCount=${ENTITY_WORKER_COUNT} \
+-DentityWorkerNum=${ENTITY_WORKER_NUM} \
+-DuuidFilename=${UUID_FILENAME} \
+-DsandboxCollection=${SANDBOX_COLLECTION} \
+-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/3976ff98/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 cd359b7..5b5c612 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
@@ -87,16 +87,24 @@ object EntityDataGenerator {
 
    /* --------------------------- */
 
-   def generateTrivialEntity(name: String = null): String = {
+  def generateTrivialEntity(name: String = null): String = {
 
-     val nameKey = if (name != null) "name" else "noname"
-     val nameVal = if (name != null) name else Utils.generateRandomInt(1,10000000).toString
+    val nameKey = if (name != null) "name" else "noname"
+    val nameVal = if (name != null) name else Utils.generateRandomInt(1,10000000).toString
 
-     val entity: Map[String, String] = Map(
-       nameKey -> nameVal
-     )
+    val entity: Map[String, String] = Map(
+      nameKey -> nameVal
+    )
 
-     new JSONObject(entity).toString()
+    new JSONObject(entity).toString()
+  }
+
+   def generateTrivialSortableEntity(name: String = null): String = {
+
+     if (name != null)
+       new JSONObject(Map("name" -> name, "sortField" -> Utils.generateRandomInt(1,10000000))).toString()
+     else
+       new JSONObject(Map("sortField" -> Utils.generateRandomInt(1,10000000))).toString()
    }
 
    def generateBasicEntity(name: String = null): String = {
@@ -127,13 +135,12 @@ object EntityDataGenerator {
    }
 
    def generateEntity(entityType: String = EntityType.Basic, entityName: String = null): String = {
-     val entity: String =
-       if (entityType == EntityType.Trivial)
-         generateTrivialEntity(entityName)
-       else // default is basic
-         generateBasicEntity(entityName)
 
-     entity
+     entityType match {
+       case EntityType.Trivial => generateTrivialEntity(entityName)
+       case EntityType.TrivialSortable => generateTrivialSortableEntity(entityName)
+       case EntityType.Basic => generateBasicEntity(entityName)
+     }
    }
 
    def generateUserEntity(userId: String = "user" + System.currentTimeMillis().toString): String = {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3976ff98/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
index dfb378c..214d48c 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EntityType.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/enums/EntityType.scala
@@ -2,9 +2,10 @@ package org.apache.usergrid.enums
 
 object EntityType {
   val Trivial = "trivial"
+  val TrivialSortable = "trivialSortable"
   val Basic = "basic"
 
-  val Values = Seq(Trivial,Basic)
+  val Values = Seq(Trivial,TrivialSortable,Basic)
 
   def isValid(str: String): Boolean = {
     Values.contains(str)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3976ff98/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 120d790..e970fbd 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
@@ -34,7 +34,7 @@ object Extractors {
    * Will extract the cursor from the response.  If the cursor is not present, an empty string will be set
    */
   def maybeExtractCursor(saveAsName: String) = {
-    jsonPath("$..cursor").transformOption(extract => {
+    jsonPath("$.cursor").transformOption(extract => {
       //it may or may not be present.  If it is, save it, otherwise save it as an empty string
       extract.orElse(Some(""))
     }).saveAs(saveAsName)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3976ff98/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 646582b..35a4688 100644
--- a/stack/loadtests/src/test/resources/logback-test.xml
+++ b/stack/loadtests/src/test/resources/logback-test.xml
@@ -28,10 +28,9 @@
 	<!-- Uncomment for logging ALL HTTP request and responses -->
 	 	<!-- <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" /> -->
-        <!-- Uncomment for logging ONLY FAILED HTTP request and responses -->
+    <!-- <logger name="io.gatling.http" level="TRACE" /> -->
 
 	<root level="WARN">
 		<appender-ref ref="CONSOLE" />