usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [02/33] usergrid git commit: USERGRID-1044: add option to delete entity after successful audit
Date Tue, 20 Oct 2015 21:07:03 GMT
USERGRID-1044: add option to delete entity after successful audit


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

Branch: refs/heads/usergrid-1007-shiro-cache
Commit: 9b2508f7d4d47af9bfd28ba6953072e0aa1eff90
Parents: a9927a3b
Author: Mike Dunker <mdunker@apigee.com>
Authored: Thu Oct 8 13:19:28 2015 -0700
Committer: Mike Dunker <mdunker@apigee.com>
Committed: Thu Oct 8 13:19:28 2015 -0700

----------------------------------------------------------------------
 .../runAuditVerifyCollectionEntities.sh         |  9 +++++---
 .../usergrid/enums/ConfigProperties.scala       |  4 +++-
 .../usergrid/scenarios/AuditScenarios.scala     | 23 ++++++++++++++++++++
 .../org/apache/usergrid/settings/Settings.scala | 17 +++++++++++++++
 4 files changed, 49 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b2508f7/stack/loadtests/runAuditVerifyCollectionEntities.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/runAuditVerifyCollectionEntities.sh b/stack/loadtests/runAuditVerifyCollectionEntities.sh
index 6d963f3..2e2d76d 100755
--- a/stack/loadtests/runAuditVerifyCollectionEntities.sh
+++ b/stack/loadtests/runAuditVerifyCollectionEntities.sh
@@ -27,17 +27,19 @@ if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
 #TOKEN_TYPE=
 #RETRY_COUNT=
 
+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]"
+[ "$#" -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)]]"
 
 RAMP_USERS="$1"
 RAMP_TIME="$2"
 AUDIT_UUID_FILENAME="$3"
 FAILED_UUID_FILENAME="$4"
-[ "$#" -ge 5 ] && LATER_THAN_TIMESTAMP="$5"
+[ "$#" -ge 5 ] && DELETE_AFTER_SUCCESSFUL_AUDIT="$5"
 
-shift 4
+shift $#
 
 SCENARIO_TYPE=auditVerifyCollectionEntities
 
@@ -60,5 +62,6 @@ mvn gatling:execute \
 -DauditUuidFilename=${AUDIT_UUID_FILENAME} \
 -DfailedUuidFilename=${FAILED_UUID_FILENAME} \
 -DprintFailedRequests=${PRINT_FAILED_REQUESTS} \
+-DdeleteAfterSuccessfulAudit=${DELETE_AFTER_SUCCESSFUL_AUDIT} \
 -Dgatling.simulationClass=org.apache.usergrid.simulations.AuditSimulation
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b2508f7/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 ba09979..975944a 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
@@ -85,6 +85,7 @@ object ConfigProperties {
   val FlushCsv = "flushCsv"
   val InterleavedWorkerFeed = "interleavedWorkerFeed"
   val NewCsvOnFlush = "newCsvOnFlush"
+  val DeleteAfterSuccessfulAudit = "deleteAfterSuccessfulAudit"
 
   val Values = Seq(Org,App,AdminUser,AdminPassword,BaseUrl,AuthType,TokenType,SkipSetup,CreateOrg,CreateApp,LoadEntities,
     ScenarioType,RampUsers,ConstantUsersPerSec,ConstantUsersDuration,UserSeed,AppUser,AppUserPassword,NumEntities,
@@ -94,7 +95,7 @@ object ConfigProperties {
     UuidFilename,AuditUuidFilename,FailedUuidFilename,SandboxCollection,PurgeUsers,RetryCount,LaterThanTimestamp,
     EntityProgressCount,InjectionList,PrintFailedRequests,GetViaQuery,MultiPropertyPrefix,MultiPropertyCount,
     MultiPropertySizeInK,EntityNumberProperty,QueryParams,CsvFeedPattern,UnlimitedFeed,FlushCsv,InterleavedWorkerFeed,
-    NewCsvOnFlush)
+    NewCsvOnFlush,DeleteAfterSuccessfulAudit)
 
   def isValid(str: String): Boolean = {
     Values.contains(str)
@@ -167,6 +168,7 @@ object ConfigProperties {
         case FlushCsv => 0L
         case InterleavedWorkerFeed => false
         case NewCsvOnFlush => false
+        case DeleteAfterSuccessfulAudit => false
       }
     } else {
       null

http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b2508f7/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 3a7121b..836a1fb 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
@@ -33,6 +33,7 @@ object AuditScenarios {
   //The value for the cursor
   val SessionVarCursor: String = "cursor"
   val SessionVarUuid: String = "entityUuid"
+  val SessionVarDeletedUuid: String = "deletedUuid"
   val SessionVarCollectionName: String = "collectionName"
   val SessionVarCollectionEntities: String = "collectionEntities"
 
@@ -112,6 +113,23 @@ object AuditScenarios {
       session
     }
 
+  val deleteAuditedEntity = exec(
+    http("DELETE audited entity")
+      .delete("/${collectionName}/${uuid}")
+      .headers(Headers.authToken)
+      .check(extractCreateUuid(SessionVarDeletedUuid)))
+      .exec(session => {
+        val uuid = session(SessionVarDeletedUuid).as[String]
+
+        if (uuid != null && uuid != "") {
+          // successful
+          Settings.incAuditEntryDeleteSuccess()
+        } else {
+          Settings.incAuditEntryDeleteFailure()
+        }
+
+        session
+      })
 
   val getCollectionEntity = exec(
     http("GET collection entity")
@@ -140,6 +158,11 @@ object AuditScenarios {
 
         session
       })
+      .doIf(session => Settings.deleteAfterSuccessfulAudit && session("count").as[String].toInt
== 1) {
+        // tryMax(Settings.retryCount) {
+          exec(deleteAuditedEntity)
+        // }
+      }
 
   val verifyCollections = scenario("Verify collections")
     .exec(injectTokenIntoSession())

http://git-wip-us.apache.org/repos/asf/usergrid/blob/9b2508f7/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 27c1d33..eeeac1f 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
@@ -186,6 +186,7 @@ object Settings {
   // unlimited feed forces interleaved worker feed
   val interleavedWorkerFeed:Boolean = if (unlimitedFeed) true else initBoolSetting(ConfigProperties.InterleavedWorkerFeed)
   val newCsvOnFlush:Boolean = initBoolSetting(ConfigProperties.NewCsvOnFlush)
+  val deleteAfterSuccessfulAudit:Boolean = initBoolSetting(ConfigProperties.DeleteAfterSuccessfulAudit)
 
   val multiPropertyPrefix = initStrSetting(ConfigProperties.MultiPropertyPrefix)
   val multiPropertyCount:Int = initIntSetting(ConfigProperties.MultiPropertyCount)
@@ -429,6 +430,8 @@ object Settings {
   private val countAuditSuccess = new AtomicInteger(0)
   private val countAuditNotFound = new AtomicInteger(0)
   private val countAuditBadResponse = new AtomicInteger(0)
+  private val countAuditEntryDeleteSuccess = new AtomicInteger(0)
+  private val countAuditEntryDeleteFailure = new AtomicInteger(0)
 
   def incAuditSuccess(): Unit = {
     countAuditSuccess.incrementAndGet()
@@ -442,11 +445,21 @@ object Settings {
     countAuditBadResponse.incrementAndGet()
   }
 
+  def incAuditEntryDeleteSuccess(): Unit = {
+    countAuditEntryDeleteSuccess.incrementAndGet()
+  }
+
+  def incAuditEntryDeleteFailure(): Unit = {
+    countAuditEntryDeleteFailure.incrementAndGet()
+  }
+
   def printAuditResults(): Unit = {
     if (scenarioType == ScenarioType.AuditVerifyCollectionEntities) {
       val countSuccess = countAuditSuccess.get
       val countNotFound = countAuditNotFound.get
       val countBadResponse = countAuditBadResponse.get
+      val countDeleteSuccess = countAuditEntryDeleteSuccess.get
+      val countDeleteFailure = countAuditEntryDeleteFailure.get
       val countTotal = countSuccess + countNotFound + countBadResponse
 
       val seconds = ((testEndTime - testStartTime) / 1000).toInt
@@ -463,6 +476,10 @@ object Settings {
       println(s"Successful:          $countSuccess")
       println(s"Not Found:           $countNotFound")
       println(s"Bad Response:        $countBadResponse")
+      if (deleteAfterSuccessfulAudit) {
+        println(s"Delete Successes:    $countDeleteSuccess")
+        println(s"Delete Failures:     $countDeleteFailure")
+      }
       println(s"Total:               $countTotal")
       println()
       println(s"Start Timestamp(ms): $testStartTime")


Mime
View raw message