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:00 UTC

[16/21] incubator-usergrid git commit: USERGRID-871: add get by name sequential scenario, plus fix Base64

USERGRID-871: add get by name sequential scenario, plus fix Base64


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

Branch: refs/heads/two-dot-o-dev
Commit: 15c1c59cef3092477e734de54a1d49db7e7df2fe
Parents: 0a0ef1b
Author: Mike Dunker <md...@apigee.com>
Authored: Thu Jul 30 17:08:43 2015 -0700
Committer: Mike Dunker <md...@apigee.com>
Committed: Thu Jul 30 17:08:43 2015 -0700

----------------------------------------------------------------------
 .../loadtests/runGetEntitiesByNameSequential.sh | 106 +++++++++++++++++++
 .../datagenerators/FeederGenerator.scala        |   2 +-
 .../apache/usergrid/enums/ScenarioType.scala    |   4 +-
 .../scenarios/EntityCollectionScenarios.scala   |  52 ++++++++-
 .../usergrid/scenarios/EntityScenarios.scala    |   4 +-
 .../org/apache/usergrid/settings/Headers.scala  |   4 +-
 .../org/apache/usergrid/settings/Settings.scala |  11 +-
 .../simulations/ConfigurableSimulation.scala    |   1 +
 .../src/test/resources/logback-test.xml         |   1 -
 9 files changed, 170 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/stack/loadtests/runGetEntitiesByNameSequential.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runGetEntitiesByNameSequential.sh b/stack/loadtests/runGetEntitiesByNameSequential.sh
new file mode 100755
index 0000000..d97edc2
--- /dev/null
+++ b/stack/loadtests/runGetEntitiesByNameSequential.sh
@@ -0,0 +1,106 @@
+#!/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=trivialentities
+SANDBOX_COLLECTION=false
+SCENARIO_TYPE=getByNameSequential
+LOAD_ENTITIES=false
+
+SKIP_SETUP=false
+#SEARCH_QUERY=order%20by%20specials%20desc
+#SEARCH_LIMIT=1000
+ENTITY_TYPE=trivial
+ENTITY_PREFIX=trivial
+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/15c1c59c/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 f218b5b..09030f5 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
@@ -227,7 +227,7 @@ object FeederGenerator {
 
      // println(entityName)
 
-     Map("entityName" -> entityName, "entity" -> entity, "entityUrl" -> entityUrl, "validEntity" -> validEntity, "entityNum" -> (i+1).toString)
+     Map("entityName" -> entityName, "entity" -> entity, "entityUrl" -> entityUrl, "validEntity" -> validEntity, "entityNum" -> (i+1).toString, "seededEntityNum" -> seededVal.toString)
    }
  }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/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 db9a3af..760c837 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
@@ -7,8 +7,10 @@ object ScenarioType {
   val DeleteEntities = "deleteEntities"
   val UpdateEntities = "updateEntities"
   val UuidRandomInfinite = "uuidRandomInfinite"
+  val GetByNameSequential = "getByNameSequential"
 
-  val Values = Seq(GetAllByCursor,NameRandomInfinite,LoadEntities,DeleteEntities,UpdateEntities,UuidRandomInfinite)
+  val Values = Seq(GetAllByCursor,NameRandomInfinite,LoadEntities,DeleteEntities,UpdateEntities,UuidRandomInfinite,
+    GetByNameSequential)
 
   def isValid(str: String): Boolean = {
     Values.contains(str)

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/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 b661d9c..5f679ec 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
@@ -196,7 +196,7 @@ object EntityCollectionScenarios {
         // 200 for success, 400 if already exists
         .check(status.in(Seq(200)), extractCreateUuid(SessionVarUuid)))
         .exec(session => {
-          Settings.addUuid(session("entityNum").as[String].toInt, session(SessionVarUuid).as[String])
+          Settings.addUuid(session("seededEntityNum").as[String].toInt, session(SessionVarUuid).as[String])
           session
         })
     }
@@ -268,4 +268,54 @@ object EntityCollectionScenarios {
           exec(updateEntity)
         }
     }
+
+  /*
+   * Get by name sequential
+   */
+  val getEntityByNameSequentialAnonymous = exec(
+    doIf("${validEntity}", "yes") {
+      exec(http("GET entity by name sequential (anonymous)")
+        .get("/" + Settings.collection + "/${entityName}")
+        .headers(Headers.authAnonymous)
+        .check(status.is(200), extractCreateUuid(SessionVarUuid)))
+        .exec(session => {
+          Settings.addUuid(session("seededEntityNum").as[String].toInt, session(SessionVarUuid).as[String])
+          session
+        })
+    }
+  )
+
+  val getEntityByNameSequentialWithToken = exec(
+    doIf("${validEntity}", "yes") {
+      exec(http("GET entity by name sequential (anonymous)")
+        .get("/" + Settings.collection + "/${entityName}")
+        .headers(Headers.authToken)
+        .check(status.is(200), extractCreateUuid(SessionVarUuid)))
+        .exec(session => {
+        Settings.addUuid(session("seededEntityNum").as[String].toInt, session(SessionVarUuid).as[String])
+        session
+      })
+    }
+  )
+
+  val getEntitiesByNameSequential = scenario("Get entities by name sequentially")
+    .exec(injectTokenIntoSession())
+    .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{
+          session => if (session("validEntity").as[String] == "yes") { println("Loading entity #" + session("entityNum").as[String]) }
+          session
+        }*/
+        .doIf(session => session("validEntity").as[String] == "yes") {
+          tryMax(5) {
+            doIfOrElse(_ => Settings.authType == AuthType.Anonymous) {
+              exec(getEntityByNameSequentialAnonymous)
+            } {
+              exec(getEntityByNameSequentialWithToken)
+            }
+          }
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/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 65d0111..df1657b 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
@@ -18,9 +18,7 @@ package org.apache.usergrid.scenarios
 
 import io.gatling.core.Predef._
 import io.gatling.http.Predef._
-import org.apache.usergrid.datagenerators.{EntityDataGenerator, FeederGenerator}
-import org.apache.usergrid.helpers.{Extractors,Utils}
-import org.apache.usergrid.settings.{Headers, Settings}
+import org.apache.usergrid.settings.Headers
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
index 04c4d3b..d158f0c 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- package org.apache.usergrid.settings
+package org.apache.usergrid.settings
 
- import org.apache.usergrid.enums.AuthType
+import org.apache.usergrid.enums.AuthType
 
  /**
  *

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/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 387fd24..e4be5c8 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
@@ -17,10 +17,7 @@
 package org.apache.usergrid.settings
 
 import java.io.{PrintWriter, FileOutputStream}
-import java.nio.charset.StandardCharsets
-import java.util.{Date, Base64}
-
-
+import javax.xml.bind.DatatypeConverter
 import io.gatling.http.Predef._
 import io.gatling.http.config.HttpProtocolBuilder
 import org.apache.usergrid.datagenerators.FeederGenerator
@@ -86,7 +83,9 @@ object Settings {
   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))
+
+  // val appUserBase64 = Base64.getEncoder.encodeToString((appUser + ":" + appUserPassword).getBytes(StandardCharsets.UTF_8))
+  val appUserBase64: String = DatatypeConverter.printBase64Binary((appUser + ":" + appUserPassword).getBytes("UTF-8"))
 
   val totalNumEntities:Int = initIntSetting(ConfigProperties.NumEntities)
   val numDevices:Int = initIntSetting(ConfigProperties.NumDevices)
@@ -152,7 +151,7 @@ object Settings {
   // 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 captureUuids = uuidFilename != dummyCsv && (scenarioType == ScenarioType.LoadEntities || scenarioType == ScenarioType.GetByNameSequential)
   val feedUuids = uuidFilename != dummyCsv && scenarioType == ScenarioType.UuidRandomInfinite
   val captureUuidFilename = if (captureUuids) uuidFilename else dummyCsv
   val feedUuidFilename = if (feedUuids) uuidFilename else dummyCsv

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/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 da5189e..b923c46 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
@@ -43,6 +43,7 @@ class ConfigurableSimulation extends Simulation {
       case ScenarioType.GetAllByCursor => EntityCollectionScenarios.getEntityPagesToEnd
       case ScenarioType.NameRandomInfinite => EntityCollectionScenarios.getRandomEntitiesByName
       case ScenarioType.UuidRandomInfinite => EntityCollectionScenarios.getRandomEntitiesByUuid
+      case ScenarioType.GetByNameSequential => EntityCollectionScenarios.getEntitiesByNameSequential
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/15c1c59c/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 dd39a3e..646582b 100644
--- a/stack/loadtests/src/test/resources/logback-test.xml
+++ b/stack/loadtests/src/test/resources/logback-test.xml
@@ -27,7 +27,6 @@
 
 	<!-- 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" /> -->