You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2014/12/29 16:12:51 UTC

svn commit: r1648357 - /hive/branches/HIVE-8065/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java

Author: brock
Date: Mon Dec 29 15:12:50 2014
New Revision: 1648357

URL: http://svn.apache.org/r1648357
Log:
HIVE-9213 - Improve the mask pattern in QTestUtil to save partial directory info in test result (Dong Chen via Brock)

Modified:
    hive/branches/HIVE-8065/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java

Modified: hive/branches/HIVE-8065/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
URL: http://svn.apache.org/viewvc/hive/branches/HIVE-8065/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java?rev=1648357&r1=1648356&r2=1648357&view=diff
==============================================================================
--- hive/branches/HIVE-8065/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java (original)
+++ hive/branches/HIVE-8065/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java Mon Dec 29 15:12:50 2014
@@ -1208,6 +1208,7 @@ public class QTestUtil {
 
   private void maskPatterns(Pattern[] patterns, String fname) throws Exception {
     String maskPattern = "#### A masked pattern was here ####";
+    String partialMaskPattern = "#### A PARTIAL masked pattern was here ####";
 
     String line;
     BufferedReader in;
@@ -1221,9 +1222,24 @@ public class QTestUtil {
     out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
 
     boolean lastWasMasked = false;
+    boolean partialMaskWasMatched = false;
+    Matcher matcher;
     while (null != (line = in.readLine())) {
-      for (Pattern pattern : patterns) {
-        line = pattern.matcher(line).replaceAll(maskPattern);
+      if (clusterType == MiniClusterType.encrypted) {
+        for (Pattern pattern : partialReservedPlanMask) {
+          matcher = pattern.matcher(line);
+          if (matcher.find()) {
+            line = partialMaskPattern + " " + matcher.group(0);
+            partialMaskWasMatched = true;
+            break;
+          }
+        }
+      }
+
+      if (!partialMaskWasMatched) {
+        for (Pattern pattern : patterns) {
+          line = pattern.matcher(line).replaceAll(maskPattern);
+        }
       }
 
       if (line.equals(maskPattern)) {
@@ -1237,6 +1253,7 @@ public class QTestUtil {
         out.write(line);
         out.write("\n");
         lastWasMasked = false;
+        partialMaskWasMatched = false;
       }
     }
 
@@ -1280,6 +1297,11 @@ public class QTestUtil {
       ".*.hive-staging.*"
   });
 
+  private final Pattern[] partialReservedPlanMask = toPattern(new String[] {
+      "data/warehouse/(.*?/)+\\.hive-staging"  // the directory might be db/table/partition
+      //TODO: add more expected test result here
+  });
+
   public int checkCliDriverResults(String tname) throws Exception {
     assert(qMap.containsKey(tname));