USERGRID-1044: add audit delete test (delete only, no verify)
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/247f7960 Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/247f7960 Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/247f7960 Branch: refs/heads/master Commit: 247f79603d1775273a56274ce7810f1b8f1f5d29 Parents: 0fc1804 Author: Mike Dunker <mdun...@apigee.com> Authored: Mon Nov 2 07:34:42 2015 -0800 Committer: Mike Dunker <mdun...@apigee.com> Committed: Mon Nov 2 07:34:42 2015 -0800 ---------------------------------------------------------------------- stack/loadtests/runAuditDeleteEntities.sh | 65 ++++++++++++++++++++ .../runAuditVerifyCollectionEntities.sh | 2 +- .../apache/usergrid/enums/ScenarioType.scala | 3 +- .../usergrid/scenarios/AuditScenarios.scala | 49 ++++++++++++++- .../usergrid/simulations/AuditSimulation.scala | 4 +- 5 files changed, 118 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/247f7960/stack/loadtests/runAuditDeleteEntities.sh ---------------------------------------------------------------------- diff --git a/stack/loadtests/runAuditDeleteEntities.sh b/stack/loadtests/runAuditDeleteEntities.sh new file mode 100755 index 0000000..ff92940 --- /dev/null +++ b/stack/loadtests/runAuditDeleteEntities.sh @@ -0,0 +1,65 @@ +#!/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= +#ORG= +#APP= +#AUTH_TYPE= +#TOKEN_TYPE= +#RETRY_COUNT= + +die() { echo "$@" 1>&2 ; exit 1; } + +[ "$#" -ge 3 ] || die "At least 3 arguments required, $# provided. Example is $0 RAMP_USERS RAMP_TIME(seconds) AUDIT_UUID_FILENAME [FAILED_UUID_FILENAME [USERGRID_REGION]]" + +RAMP_USERS="$1" +RAMP_TIME="$2" +AUDIT_UUID_FILENAME="$3" +FAILED_UUID_FILENAME="$4" +[ "$#" -ge 5 ] && USERGRID_REGION="$5" + +shift $# + +SCENARIO_TYPE=auditDeleteEntities + +#Compile everything +mvn compile + +#Execute the test +mvn gatling:execute \ +-DbaseUrl=${URL} \ +-DadminUser=${ADMIN_USER} \ +-DadminPassword=${ADMIN_PASSWORD} \ +-Dorg=${ORG} \ +-Dapp=${APP} \ +-DauthType=${AUTH_TYPE} \ +-DtokenType=${TOKEN_TYPE} \ +-DretryCount=${RETRY_COUNT} \ +-DscenarioType=${SCENARIO_TYPE} \ +-DrampUsers=${RAMP_USERS} \ +-DrampTime=${RAMP_TIME} \ +-DauditUuidFilename=${AUDIT_UUID_FILENAME} \ +-DfailedUuidFilename=${FAILED_UUID_FILENAME} \ +-DprintFailedRequests=${PRINT_FAILED_REQUESTS} \ +-DusergridRegion=${USERGRID_REGION} \ +-Dgatling.simulationClass=org.apache.usergrid.simulations.AuditSimulation + http://git-wip-us.apache.org/repos/asf/usergrid/blob/247f7960/stack/loadtests/runAuditVerifyCollectionEntities.sh ---------------------------------------------------------------------- diff --git a/stack/loadtests/runAuditVerifyCollectionEntities.sh b/stack/loadtests/runAuditVerifyCollectionEntities.sh index 695c9ee..be50189 100755 --- a/stack/loadtests/runAuditVerifyCollectionEntities.sh +++ b/stack/loadtests/runAuditVerifyCollectionEntities.sh @@ -31,7 +31,7 @@ DELETE_AFTER_SUCCESSFUL_AUDIT=false die() { echo "$@" 1>&2 ; exit 1; } -[ "$#" -ge 3 ] || die "At least 3 arguments required, $# provided. Example is $0 RAMP_USERS RAMP_TIME(seconds) AUDIT_UUID_FILENAME [FAILED_UUID_FILENAME [DELETE_AFTER_SUCCESSFUL_AUDIT(true/false)[USERGRID_REGION]]]" +[ "$#" -ge 3 ] || die "At least 3 arguments required, $# provided. Example is $0 RAMP_USERS RAMP_TIME(seconds) AUDIT_UUID_FILENAME [FAILED_UUID_FILENAME [DELETE_AFTER_SUCCESSFUL_AUDIT(true/false) [USERGRID_REGION]]]" RAMP_USERS="$1" RAMP_TIME="$2" http://git-wip-us.apache.org/repos/asf/usergrid/blob/247f7960/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 c86dc33..1cc1fa2 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 @@ -26,10 +26,11 @@ object ScenarioType { val GetByNameSequential = "getByNameSequential" val AuditGetCollectionEntities = "auditGetCollectionEntities" val AuditVerifyCollectionEntities = "auditVerifyCollectionEntities" + val AuditDeleteEntities = "auditDeleteEntities" val DoNothing = "doNothing" val Values = Seq(GetAllByCursor,NameRandomInfinite,LoadEntities,DeleteEntities,UpdateEntities,UuidRandomInfinite, - GetByNameSequential,AuditGetCollectionEntities,AuditVerifyCollectionEntities,DoNothing) + GetByNameSequential,AuditGetCollectionEntities,AuditVerifyCollectionEntities,AuditDeleteEntities,DoNothing) def isValid(str: String): Boolean = { Values.contains(str) http://git-wip-us.apache.org/repos/asf/usergrid/blob/247f7960/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/AuditScenarios.scala ---------------------------------------------------------------------- diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/AuditScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/AuditScenarios.scala index cc59e0a..9ca479a 100644 --- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/AuditScenarios.scala +++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/AuditScenarios.scala @@ -147,7 +147,6 @@ object AuditScenarios { .get("/${collectionName}/${accessField}") .headers(Headers.authToken) .headers(Headers.usergridRegionHeaders) - .check() .check(status.in(Seq(200,404)),status.saveAs(SessionVarStatus),extractAuditEntities(SessionVarCollectionEntities), extractEntityUuid(SessionVarEntityUuid),extractEntityName(SessionVarEntityName))) .exec(session => { @@ -282,7 +281,7 @@ object AuditScenarios { // } } - val verifyCollections = scenario("Verify collections") + val verifyAuditedEntities = scenario("Verify audited entities") .exec(injectTokenIntoSession()) .exec(injectAuthType()) .asLongAs(session => session("validEntity").asOption[String].map(validEntity => validEntity != "no").getOrElse[Boolean](true)) { @@ -294,4 +293,50 @@ object AuditScenarios { } } + val deleteEntity = exec( + http("DELETE entity") + .delete("/${collectionName}/${accessField}") + .headers(Headers.authToken) + .headers(Headers.usergridRegionHeaders) + .check(status.saveAs(SessionVarStatus))) + .exec(session => { + val saveFailures = Settings.saveInvalidResponse + val status = session(SessionVarStatus).as[Int] + val collectionName = session(SessionVarCollectionName).as[String] + val modified = session("modified").as[String].toLong + val uuid = session("uuid").as[String] + val reqName = session("name").as[String] + val lastStatus = session("lastStatus").as[String] + if (status == 200) { + // success + Settings.incAuditSuccess() + session + } else if (status == 401 || status == 404) { + // didn't exist (currently returns 401, but 404 would be more appropriate) + Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"NotFound", lastStatus) + Settings.incAuditEntryDeleteFailure() + session + } else if (saveFailures) { + // a different error + Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"Error", lastStatus) + Settings.incAuditEntryDeleteFailure() + println(s"DELETE ERROR (status=$status): $collectionName.$reqName ($uuid)") + session.markAsFailed + } else { + session.markAsFailed + } + + }) + + val deleteAuditedEntities = scenario("Delete audited entities") + .exec(injectTokenIntoSession()) + .exec(injectAuthType()) + .asLongAs(session => session("validEntity").asOption[String].map(validEntity => validEntity != "no").getOrElse[Boolean](true)) { + feed(FeederGenerator.collectionCsvFeeder) + .doIf(session => session("validEntity").as[String] == "yes") { + tryMax(if (Settings.saveInvalidResponse) 1 else 1+Settings.retryCount) { + exec(deleteEntity) + } + } + } } http://git-wip-us.apache.org/repos/asf/usergrid/blob/247f7960/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AuditSimulation.scala ---------------------------------------------------------------------- diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AuditSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AuditSimulation.scala index bdec3dd..ac900fd 100755 --- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AuditSimulation.scala +++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/AuditSimulation.scala @@ -33,7 +33,8 @@ class AuditSimulation extends Simulation { def getScenario(scenarioType: String): ScenarioBuilder = { scenarioType match { case ScenarioType.AuditGetCollectionEntities => AuditScenarios.getAllCollections - case ScenarioType.AuditVerifyCollectionEntities => AuditScenarios.verifyCollections + case ScenarioType.AuditVerifyCollectionEntities => AuditScenarios.verifyAuditedEntities + case ScenarioType.AuditDeleteEntities => AuditScenarios.deleteAuditedEntities } } @@ -66,6 +67,7 @@ class AuditSimulation extends Simulation { val uuidDesc = Settings.scenarioType match { case ScenarioType.AuditGetCollectionEntities => "found" case ScenarioType.AuditVerifyCollectionEntities => "failed" + case ScenarioType.AuditDeleteEntities => "failed" } Settings.writeAuditUuidsToFile(uuidDesc) }