hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1558973 - in /hive/trunk: cli/src/java/org/apache/hadoop/hive/cli/ hbase-handler/src/test/templates/ itests/util/src/main/java/org/apache/hadoop/hive/ql/ ql/src/java/org/apache/hadoop/hive/ql/session/ ql/src/test/templates/
Date Fri, 17 Jan 2014 01:24:57 GMT
Author: navis
Date: Fri Jan 17 01:24:57 2014
New Revision: 1558973

URL: http://svn.apache.org/r1558973
Log:
HIVE-6201 : Print failed query for qfile tests (Navis reviewed by Vikram Dixit K)

Modified:
    hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
    hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
    hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
    hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
    hive/trunk/ql/src/test/templates/TestCliDriver.vm
    hive/trunk/ql/src/test/templates/TestCompareCliDriver.vm
    hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm
    hive/trunk/ql/src/test/templates/TestParse.vm
    hive/trunk/ql/src/test/templates/TestParseNegative.vm

Modified: hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
URL: http://svn.apache.org/viewvc/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (original)
+++ hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java Fri Jan 17 01:24:57
2014
@@ -67,7 +67,6 @@ import org.apache.hadoop.hive.ql.session
 import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
 import org.apache.hadoop.hive.service.HiveClient;
 import org.apache.hadoop.hive.service.HiveServerException;
-import org.apache.hadoop.hive.shims.ShimLoader;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.thrift.TException;
 
@@ -99,6 +98,7 @@ public class CliDriver {
 
   public int processCmd(String cmd) {
     CliSessionState ss = (CliSessionState) SessionState.get();
+    ss.setLastCommand(cmd);
     // Flush the print stream, so it doesn't include output from the last command
     ss.err.flush();
     String cmd_trimmed = cmd.trim();

Modified: hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
URL: http://svn.apache.org/viewvc/hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm (original)
+++ hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm Fri Jan 17 01:24:57
2014
@@ -120,21 +120,17 @@ public class $className extends TestCase
       qt.clearTestSideEffects();
       int ecode = qt.executeClient(fname);
       if (ecode != 0) {
-        fail("Client Execution failed with error code = " + ecode);
+        qt.failed(ecode, fname, null);
       }
 
       ecode = qt.checkCliDriverResults(fname);
       if (ecode != 0) {
-        fail("Client execution results failed with error code = " + ecode);
+        qt.failedDiff(ecode, fname, null);
       }
       qt.clearPostTestEffects();
 
     } catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception");
+      qt.failed(e, fname, null);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;

Modified: hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
URL: http://svn.apache.org/viewvc/hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm (original)
+++ hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm Fri Jan 17 01:24:57
2014
@@ -120,21 +120,17 @@ public class $className extends TestCase
       qt.clearTestSideEffects();
       int ecode = qt.executeClient(fname);
       if (ecode == 0) {
-        fail("Client Execution failed with error code = " + ecode);
+        qt.failed(fname, null);
       }
 
       ecode = qt.checkCliDriverResults(fname);
       if (ecode != 0) {
-        fail("Client execution results failed with error code = " + ecode);
+        qt.failedDiff(ecode, fname, null);
       }
       qt.clearPostTestEffects();
 
     } catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception");
+      qt.failed(e, fname, null);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;

Modified: hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java (original)
+++ hive/trunk/itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java Fri Jan
17 01:24:57 2014
@@ -51,6 +51,7 @@ import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import junit.framework.Assert;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
@@ -1709,4 +1710,31 @@ public class QTestUtil {
     }
     return result;
   }
+
+  public void failed(int ecode, String fname, String debugHint) {
+    String command = SessionState.get() != null ? SessionState.get().getLastCommand() : null;
+    Assert.fail("Client Execution failed with error code = " + ecode +
+        (command != null ? " running " + command : "") + (debugHint != null ? debugHint :
""));
+  }
+
+  public void failed(String fname, String debugHint) {
+    String command = SessionState.get() != null ? SessionState.get().getLastCommand() : null;
+    Assert.fail("Client Execution was expected to fail, but succeeded with error code 0 "
+
+        (command != null ? " running " + command : "") + (debugHint != null ? debugHint :
""));
+  }
+
+  public void failedDiff(int ecode, String fname, String debugHint) {
+    Assert.fail("Client Execution results failed with error code = " + ecode +
+        (debugHint != null ? debugHint : ""));
+  }
+
+  public void failed(Throwable e, String fname, String debugHint) {
+    String command = SessionState.get() != null ? SessionState.get().getLastCommand() : null;
+    System.err.println("Exception: " + e.getMessage());
+    e.printStackTrace();
+    System.err.println("Failed query: " + fname);
+    System.err.flush();
+    Assert.fail("Unexpected exception" + (command != null ? " running " + command : "") +
+        (debugHint != null ? debugHint : ""));
+  }
 }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java Fri Jan 17
01:24:57 2014
@@ -116,6 +116,8 @@ public class SessionState {
    */
   private HiveOperation commandType;
 
+  private String lastCommand;
+
   private HiveAuthorizationProvider authorizer;
 
   private HiveAuthenticationProvider authenticator;
@@ -379,6 +381,14 @@ public class SessionState {
     return UUID.randomUUID().toString();
   }
 
+  public String getLastCommand() {
+    return lastCommand;
+  }
+
+  public void setLastCommand(String lastCommand) {
+    this.lastCommand = lastCommand;
+  }
+
   /**
    * This class provides helper routines to emit informational and error
    * messages to the user and log4j files while obeying the current session's

Modified: hive/trunk/ql/src/test/templates/TestCliDriver.vm
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestCliDriver.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestCliDriver.vm (original)
+++ hive/trunk/ql/src/test/templates/TestCliDriver.vm Fri Jan 17 01:24:57 2014
@@ -143,20 +143,15 @@ public class $className extends TestCase
       qt.cliInit(fname, false);
       int ecode = qt.executeClient(fname);
       if (ecode != 0) {
-        fail("Client Execution failed with error code = " + ecode + debugHint);
+        qt.failed(ecode, fname, debugHint);
       }
       ecode = qt.checkCliDriverResults(fname);
       if (ecode != 0) {
-        fail("Client execution results failed with error code = " + ecode
-            + debugHint);
+        qt.failedDiff(ecode, fname, debugHint);
       }
     }
     catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception" + debugHint);
+      qt.failed(e, fname, debugHint);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;

Modified: hive/trunk/ql/src/test/templates/TestCompareCliDriver.vm
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestCompareCliDriver.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestCompareCliDriver.vm (original)
+++ hive/trunk/ql/src/test/templates/TestCompareCliDriver.vm Fri Jan 17 01:24:57 2014
@@ -165,21 +165,17 @@ public class $className extends TestCase
         // TODO: will this work?
         ecode = qt.executeClient(versionFile, fname);
         if (ecode != 0) {
-          fail("Client Execution failed with error code = " + ecode + debugHint);
+          qt.failed(ecode, fname, debugHint);
         }
       }
 
       ecode = qt.checkCompareCliDriverResults(fname, outputs);
       if (ecode != 0) {
-        fail("Diff failed with exit code = " + ecode + debugHint);
+        qt.failedDiff(ecode, fname, debugHint);
       }
     }
     catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception" + debugHint);
+      qt.failed(e, fname, debugHint);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;

Modified: hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm (original)
+++ hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm Fri Jan 17 01:24:57 2014
@@ -141,22 +141,16 @@ public class $className extends TestCase
       qt.cliInit(fname, false);
       int ecode = qt.executeClient(fname);
       if (ecode == 0) {
-        fail("Client Execution was expected to fail, but succeeded with error code 0 "
-            + debugHint);
+        qt.failed(fname, debugHint);
       }
 
       ecode = qt.checkCliDriverResults(fname);
       if (ecode != 0) {
-        fail("Client execution results failed with error code = " + ecode
-            + debugHint);
+        qt.failedDiff(ecode, fname, debugHint);
       }
     }
     catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception" + debugHint);
+      qt.failed(e, fname, debugHint);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;

Modified: hive/trunk/ql/src/test/templates/TestParse.vm
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestParse.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestParse.vm (original)
+++ hive/trunk/ql/src/test/templates/TestParse.vm Fri Jan 17 01:24:57 2014
@@ -138,11 +138,7 @@ public class $className extends TestCase
       qt.getQMap().clear();
     }
     catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception" + debugHint);
+      qt.failed(e, fname, debugHint);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;

Modified: hive/trunk/ql/src/test/templates/TestParseNegative.vm
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestParseNegative.vm?rev=1558973&r1=1558972&r2=1558973&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestParseNegative.vm (original)
+++ hive/trunk/ql/src/test/templates/TestParseNegative.vm Fri Jan 17 01:24:57 2014
@@ -128,21 +128,17 @@ public class $className extends TestCase
     catch (ParseException pe) {
       int ecode = qt.checkNegativeResults(fname, pe);
       if (ecode != 0) {
-        fail("failed with error code = " + ecode + debugHint);
+        qt.failed(ecode, fname, debugHint);
       }
     }
     catch (SemanticException se) {
       int ecode = qt.checkNegativeResults(fname, se);
       if (ecode != 0) {
-        fail("failed with error code = " + ecode + debugHint);
+        qt.failedDiff(ecode, fname, debugHint);
       }
     }
     catch (Throwable e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.println("Failed query: " + fname);
-      System.err.flush();
-      fail("Unexpected exception" + debugHint);
+      qt.failed(e, fname, debugHint);
     }
 
     long elapsedTime = System.currentTimeMillis() - startTime;



Mime
View raw message