You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by as...@apache.org on 2015/11/09 22:36:59 UTC

[08/50] [abbrv] incubator-geode git commit: GEODE-512: fix unit test suspect string reporter

GEODE-512: fix unit test suspect string reporter

A couple of problems that have been fixed:
1. If a stack has a "caused by" it will now be included
in the suspect string report.
2. Warning messages were only being partly ignored.
Now they are completely ignored. At some point in the
future we should consider treating a warning message
like error and severe messages.
3. A suspect message can now be up to 128 lines. It used
to be limited to 50 lines.


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

Branch: refs/heads/feature/GEODE-11
Commit: fc4bbfc13e3de49d6d217c02dd93662d2d3e01af
Parents: 030853b
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Thu Oct 29 16:16:15 2015 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Thu Oct 29 16:19:09 2015 -0700

----------------------------------------------------------------------
 .../java/batterytest/greplogs/LogConsumer.java  | 45 +++++++++-----------
 1 file changed, 19 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/fc4bbfc1/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java b/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
index 4909536..2976802 100644
--- a/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
+++ b/gemfire-core/src/test/java/batterytest/greplogs/LogConsumer.java
@@ -41,7 +41,10 @@ public class LogConsumer {
   private static final Pattern ExpectedExceptionPattern = Pattern.compile("<ExpectedException action=(add|remove)>(.*)</ExpectedException>");
   private static final Pattern logPattern = Pattern.compile("^\\[(?:fatal|error|warn|info|debug|trace|severe|warning|fine|finer|finest)");
   private static final Pattern blankPattern = Pattern.compile("^\\s*$");
-  private static final Pattern infoOrBelowPattern = Pattern.compile("^\\[(?:info|debug|trace|fine|finer|finest)");
+  /**
+   * Any messages at these levels will be skipped
+   */
+  private static final Pattern skipLevelPattern = Pattern.compile("^\\[(?:warn|warning|info|debug|trace|fine|finer|finest)");
   private static final Pattern fatalOrErrorPattern = Pattern.compile("^\\[(?:fatal|error|severe)");
   private static final Pattern causedByPattern = Pattern.compile("Caused by");
   private static final Pattern shortErrPattern = Pattern.compile("^\\[[^\\]]+\\](.*)$", Pattern.MULTILINE | Pattern.DOTALL);
@@ -55,7 +58,7 @@ public class LogConsumer {
   private static final Pattern misformatedI18nMessagePattern = Pattern.compile("[^\\d]\\{\\d+\\}");
   private static final Pattern rvvBitSetMessagePattern = Pattern.compile("RegionVersionVector.+bsv\\d+.+bs=\\{\\d+\\}");
   /** Limit long errors to this many lines */
-  private static int ERROR_BUFFER_LIMIT = 50;
+  private static int ERROR_BUFFER_LIMIT = 128;
   
   
   
@@ -94,7 +97,7 @@ public class LogConsumer {
           return null;
         }
       }
-      if (infoOrBelowPattern.matcher(line).find()){
+      if (skipLevelPattern.matcher(line).find()){
         infoMsgFlag = true;
         return null;
       }
@@ -121,20 +124,14 @@ public class LogConsumer {
           }
         } else {
           if (causedByPattern.matcher(line).find()) {
-            tmpErrFlag = false;
-            tmpErrLines = 0;
-            saveFlag = false;
-            StringBuilder buffer = new StringBuilder();
-            buffer.append("-----------------------------------------------------------------------\n");
-            buffer.append("Found suspect string in ")
-                   .append(fileName)
-                   .append(" at line ")
-                   .append(savelinenum).append("\n\n")
-                   .append(all.toString());
-            return buffer;
+            // This code used to stop appending if a causedBy was seen.
+            // But we want the causedBy stack trace to also be included
+            // in the suspect StringBuilder.
+            // The main thing is we do not want to call checkExpectedStrs
+            // with this "caused by" line.
           } else if (checkExpectedStrs(line, expectedExceptions)) {
             // reset the counters and throw it all away if it matches 
-            // one of the registered ignorable strings
+            // one of the registered expected strings
             tmpErrFlag = false;
             tmpErrLines = 0;
             saveFlag = false; 
@@ -199,7 +196,7 @@ public class LogConsumer {
       } else if (exceptionPattern.matcher(line).find()
                  || javaLangErrorPattern.matcher(line).find()
                  || (misformatedI18nMessagePattern.matcher(line).find()
-                     && !(infoOrBelowPattern.matcher(line).find()
+                     && !(skipLevelPattern.matcher(line).find()
                          && rvvBitSetMessagePattern.matcher(line).find())) ) {
         if(! checkExpectedStrs(line, expectedExceptions)) {
           // it's the Exception colon that we want to find
@@ -210,7 +207,7 @@ public class LogConsumer {
           Matcher m2 = exceptionPattern2.matcher(line);
           Matcher m3 = exceptionPattern3.matcher(line);
           Matcher m4 = exceptionPattern4.matcher(line);
-          String shortName = "";
+          String shortName = null;
            
           if(m2.find()) {
             shortName = m2.group(1);
@@ -219,6 +216,7 @@ public class LogConsumer {
           } else if (m4.find()) {
             shortName = m4.group(1);
           }
+          if (shortName != null) {
           Integer i = (Integer) individalErrorCount.get(shortName);
           Integer occurances = 
             new Integer((i == null) ? 1 : i.intValue() + 1);
@@ -227,6 +225,9 @@ public class LogConsumer {
                             line + "\n", 
                             lineNumber,
                             fileName);
+          } else {
+            return enforceErrorLimit(1, line + "\n", lineNumber, fileName);
+          }
         }
       }
     }
@@ -242,15 +243,7 @@ public class LogConsumer {
       // we're still trying to save lines
       
       saveFlag = false;
-      StringBuilder buffer = new StringBuilder();
-      buffer.append("\n-----------------------------------------------------------------------\n")
-            .append("Found suspect string in ")
-            .append(fileName)
-            .append(" at line ")
-            .append(savelinenum)
-            .append("\n\n")
-            .append(all);
-      return buffer;
+      return enforceErrorLimit(1, all.toString(), savelinenum, fileName);
     }
     return null;
   }