usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdun...@apache.org
Subject usergrid git commit: USERGRID-1044: if query audit fails, try direct access
Date Thu, 15 Oct 2015 16:34:32 GMT
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-1044 b62ad30cb -> 2757e905d


USERGRID-1044: if query audit fails, try direct access


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

Branch: refs/heads/USERGRID-1044
Commit: 2757e905d9a2cf38adf426df6604dd78e8a512ac
Parents: b62ad30
Author: Mike Dunker <mdunker@apigee.com>
Authored: Thu Oct 15 09:34:14 2015 -0700
Committer: Mike Dunker <mdunker@apigee.com>
Committed: Thu Oct 15 09:34:14 2015 -0700

----------------------------------------------------------------------
 .../usergrid/scenarios/AuditScenarios.scala     | 40 ++++++++++++++++++--
 .../org/apache/usergrid/settings/Settings.scala | 19 +++++++---
 2 files changed, 50 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/2757e905/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 aaabf99..905c652 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
@@ -131,6 +131,38 @@ object AuditScenarios {
         session
       })
 
+  val getCollectionEntityDirect = exec(
+    http("GET collection entity direct")
+      .get("/${collectionName}/${uuid}")
+      .headers(Headers.authToken)
+      .headers(Headers.auditRegionHeaders)
+      .check(status.is(200),jsonPath("$.count").optional.saveAs("count"),extractAuditEntities(SessionVarCollectionEntities)))
+      .exec(session => {
+        val count = session("count").as[String].toInt
+        val uuid = session("uuid").as[String]
+        val entityName = session("name").as[String]
+        val modified = session("modified").as[String].toLong
+        val collectionName = session(SessionVarCollectionName).as[String]
+
+        if (count < 1) {
+          Settings.addAuditUuid(uuid, collectionName, entityName, modified)
+          Settings.incAuditNotFoundAtAll()
+          println(s"NOT FOUND AT ALL: $collectionName.$entityName ($uuid)")
+        } else if (count == 1) {
+          // found via direct access but not query
+          Settings.addAuditUuid(uuid, collectionName, entityName, modified)
+          Settings.incAuditNotFoundViaQuery()
+          println(s"NOT FOUND VIA QUERY: $collectionName.$entityName ($uuid)")
+        } else {
+          // count > 1 -> invalid
+          Settings.addAuditUuid(uuid, collectionName, entityName, modified)
+          Settings.incAuditBadResponse()
+          println(s"INVALID RESPONSE (count=$count): $collectionName.$entityName ($uuid)")
+        }
+
+        session
+      })
+
   val getCollectionEntity = exec(
     http("GET collection entity")
       .get("/${collectionName}?ql=uuid=${uuid}")
@@ -145,20 +177,22 @@ object AuditScenarios {
         val collectionName = session(SessionVarCollectionName).as[String]
 
         if (count < 1) {
-          Settings.addAuditUuid(uuid, collectionName, entityName, modified)
-          Settings.incAuditNotFound()
-          println(s"NOT FOUND: $collectionName.$entityName ($uuid)")
+          // will check to see whether accessible directly
         } else if (count > 1) {
           Settings.addAuditUuid(uuid, collectionName, entityName, modified)
           Settings.incAuditBadResponse()
           println(s"INVALID RESPONSE (count=$count): $collectionName.$entityName ($uuid)")
         } else {
+          // count == 1 -> success
           // println(s"FOUND: $collectionName.$entityName ($uuid)")
           Settings.incAuditSuccess()
         }
 
         session
       })
+      .doIf(session => session("count").as[String].toInt < 1) {
+        exec(getCollectionEntityDirect)
+      }
       .doIf(session => Settings.deleteAfterSuccessfulAudit && session("count").as[String].toInt
== 1) {
         // tryMax(Settings.retryCount) {
           exec(deleteAuditedEntity)

http://git-wip-us.apache.org/repos/asf/usergrid/blob/2757e905/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 979fb3f..374440d 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
@@ -429,7 +429,8 @@ object Settings {
   }
 
   private val countAuditSuccess = new AtomicInteger(0)
-  private val countAuditNotFound = new AtomicInteger(0)
+  private val countAuditNotFoundViaQuery = new AtomicInteger(0)
+  private val countAuditNotFoundAtAll = new AtomicInteger(0)
   private val countAuditBadResponse = new AtomicInteger(0)
   private val countAuditEntryDeleteSuccess = new AtomicInteger(0)
   private val countAuditEntryDeleteFailure = new AtomicInteger(0)
@@ -438,8 +439,12 @@ object Settings {
     countAuditSuccess.incrementAndGet()
   }
 
-  def incAuditNotFound(): Unit = {
-    countAuditNotFound.incrementAndGet()
+  def incAuditNotFoundViaQuery(): Unit = {
+    countAuditNotFoundViaQuery.incrementAndGet()
+  }
+
+  def incAuditNotFoundAtAll(): Unit = {
+    countAuditNotFoundAtAll.incrementAndGet()
   }
 
   def incAuditBadResponse(): Unit = {
@@ -457,11 +462,12 @@ object Settings {
   def printAuditResults(): Unit = {
     if (scenarioType == ScenarioType.AuditVerifyCollectionEntities) {
       val countSuccess = countAuditSuccess.get
-      val countNotFound = countAuditNotFound.get
+      val countNotFoundViaQuery = countAuditNotFoundViaQuery.get
+      val countNotFoundAtAll = countAuditNotFoundAtAll.get
       val countBadResponse = countAuditBadResponse.get
       val countDeleteSuccess = countAuditEntryDeleteSuccess.get
       val countDeleteFailure = countAuditEntryDeleteFailure.get
-      val countTotal = countSuccess + countNotFound + countBadResponse
+      val countTotal = countSuccess + countNotFoundViaQuery + countBadResponse
 
       val seconds = ((testEndTime - testStartTime) / 1000).toInt
       val s:Int = seconds % 60
@@ -475,7 +481,8 @@ object Settings {
       println("-----------------------------------------------------------------------------")
       println()
       println(s"Successful:          $countSuccess")
-      println(s"Not Found:           $countNotFound")
+      println(s"Not Found via query: $countNotFoundViaQuery (found via direct access)")
+      println(s"Not Found at all:    $countNotFoundAtAll")
       println(s"Bad Response:        $countBadResponse")
       if (deleteAfterSuccessfulAudit) {
         println(s"Delete Successes:    $countDeleteSuccess")


Mime
View raw message