usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdun...@apache.org
Subject [2/2] usergrid git commit: USERGRID-1044: save previous status and error in audit failure CSV
Date Tue, 27 Oct 2015 19:56:26 GMT
USERGRID-1044: save previous status and error in audit failure CSV


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

Branch: refs/heads/USERGRID-1044
Commit: be0033eac3f715f63ec716a43ee4d28bffed33dc
Parents: 9158772
Author: Mike Dunker <mdunker@apigee.com>
Authored: Tue Oct 27 12:56:05 2015 -0700
Committer: Mike Dunker <mdunker@apigee.com>
Committed: Tue Oct 27 12:56:05 2015 -0700

----------------------------------------------------------------------
 .../usergrid/scenarios/AuditScenarios.scala       | 18 +++++++++++-------
 .../org/apache/usergrid/settings/Settings.scala   | 12 +++++++-----
 2 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/be0033ea/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 7a93eb6..86c0b73 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
@@ -32,7 +32,7 @@ object AuditScenarios {
 
   //The value for the cursor
   val SessionVarCursor: String = "cursor"
-  val SessionVarStatus: String = "status"
+  val SessionVarStatus: String = "newStatus"
   val SessionVarEntityUuid: String = "entityUuid"
   val SessionVarEntityName: String = "entityName"
   val SessionVarDeletedUuid: String = "deletedUuid"
@@ -157,6 +157,8 @@ object AuditScenarios {
         val modified = session("modified").as[String].toLong
         val uuid = session("uuid").as[String]
         val reqName = session("name").as[String]
+        val prevStatus = session("status").as[Int]
+        val prevError = session("error").as[String]
         if (status == 200 || status == 404) {
           val collectionEntities = session(SessionVarCollectionEntities).as[Seq[Any]]
           val entityUuid = session(SessionVarEntityUuid).as[String]
@@ -164,12 +166,12 @@ object AuditScenarios {
 
           val count = collectionEntities.length
           if (count < 1) {
-            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"NotFoundAtAll")
+            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"NotFoundAtAll",
prevStatus, prevError)
             Settings.incAuditNotFoundAtAll()
             println(s"NOT FOUND AT ALL: $collectionName.$reqName ($uuid)")
           } else if (count > 1) {
             // invalid
-            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"QueryInvalidCount$count")
+            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"QueryInvalidCount$count",
prevStatus, prevError)
             Settings.incAuditBadResponse()
             println(s"INVALID RESPONSE (count=$count): $collectionName.$reqName ($uuid)")
           } else {
@@ -197,13 +199,13 @@ object AuditScenarios {
               println(s"PAYLOAD NAME MISMATCH (DIRECT): requestedName=$reqName returnedName=$entityName")
             }
 
-            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, errorString)
+            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, errorString,
prevStatus, prevError)
             Settings.incAuditNotFoundViaQuery()
             println(s"NOT FOUND VIA QUERY: $collectionName.$reqName ($uuid)")
           }
           session
         } else if (saveFailures) {
-          Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, "Failure")
+          Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, "Failure",
prevStatus, prevError)
           session
         } else {
           session.markAsFailed
@@ -225,6 +227,8 @@ object AuditScenarios {
         val uuid = session("uuid").as[String]
         val reqName = session("name").as[String]
         val modified = session("modified").as[String].toLong
+        val prevStatus = session("status").as[Int]
+        val prevError = session("error").as[String]
         val collectionName = session(SessionVarCollectionName).as[String]
         val entityUuid = session(SessionVarEntityUuid).as[String]
         val entityName = session(SessionVarEntityName).as[String]
@@ -232,7 +236,7 @@ object AuditScenarios {
         if (count < 1) {
           // will check to see whether accessible directly
         } else if (count > 1) {
-          Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"QueryInvalidCount$count")
+          Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, s"QueryInvalidCount$count",
prevStatus, prevError)
           Settings.incAuditBadResponse()
           println(s"INVALID RESPONSE (count=$count): $collectionName.$reqName ($uuid)")
         } else {
@@ -264,7 +268,7 @@ object AuditScenarios {
 
           // log even if technically successful -- we need to capture incorrect response
           if (errorString != errorPrefix) {
-            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, errorString)
+            Settings.addAuditUuid(uuid, collectionName, reqName, modified, status, errorString,
prevStatus, prevError)
           }
           Settings.incAuditSuccess()
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/be0033ea/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 1db0a55..e0a0ec9 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
@@ -291,9 +291,10 @@ object Settings {
   val purgeUsers:Int = initIntSetting(ConfigProperties.PurgeUsers)
 
   val uuidsHeader = "collection,name,uuid,modified,status"
-  val uuidsFailHeader = "collection,name,uuid,modified,status,error"
+  val uuidsFailHeader = "collection,name,uuid,modified,status,error,prevStatus,prevError"
   case class AuditList(var collection: String, var entityName: String, var uuid: String,
var modified: Long, var status: Int)
-  case class AuditFailList(var collection: String, var entityName: String, var uuid: String,
var modified: Long, var status: Int, var error: String)
+  case class AuditFailList(var collection: String, var entityName: String, var uuid: String,
var modified: Long,
+                           var status: Int, var error: String, var prevStatus: Int, var prevError:
String)
 
   //private var uuidMap: Map[Int, String] = Map()
   private var uuidList: mutable.MutableList[AuditList] = mutable.MutableList[AuditList]()
@@ -381,10 +382,11 @@ object Settings {
   private var auditEntityCounter: Long = 0L
   private var lastAuditEntityCountPrinted: Long = 0L
   private var auditUuidList: mutable.MutableList[AuditFailList] = mutable.MutableList[AuditFailList]()
-  def addAuditUuid(uuid: String, collection: String, entityName: String, modified: Long,
status: Int, error: String): Unit = {
+  def addAuditUuid(uuid: String, collection: String, entityName: String, modified: Long,
status: Int, error: String,
+                    prevStatus: Int, prevError: String): Unit = {
     if (captureAuditUuids) {
       auditUuidList.synchronized {
-        auditUuidList += AuditFailList(collection, entityName, uuid, modified, status, error)
+        auditUuidList += AuditFailList(collection, entityName, uuid, modified, status, error,
prevStatus, prevError)
         auditEntityCounter += 1L
         if (logEntityProgress && (auditEntityCounter >= lastAuditEntityCountPrinted
+ entityProgressCount)) {
           println(s"Entity: $auditEntityCounter")
@@ -404,7 +406,7 @@ object Settings {
       writer.println(uuidsFailHeader)
       val uuidList: List[AuditFailList] = auditUuidList.toList.sortBy(e => (e.collection,
e.entityName, e.modified, e.status))
       uuidList.foreach { e =>
-        writer.println(s"${e.collection},${e.entityName},${e.uuid},${e.modified},${e.status},${e.error}")
+        writer.println(s"${e.collection},${e.entityName},${e.uuid},${e.modified},${e.status},${e.error},${e.prevStatus},${e.prevError}")
       }
       writer.flush()
       writer.close()


Mime
View raw message