hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xu...@apache.org
Subject [23/23] hive git commit: Revert "HIVE-12330: Fix precommit Spark test part2 (Sergio Pena, reviewd by Szehon Ho)"
Date Wed, 18 Nov 2015 21:46:11 GMT
Revert "HIVE-12330: Fix precommit Spark test part2 (Sergio Pena, reviewd by Szehon Ho)"

This reverts commit c771306b469fdd215797e95c00fc12809b96009b.

Patch attached in HIVE-12434 doesn't include this commit.


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

Branch: refs/heads/master
Commit: fb944ee4963927ee363e597c9ee55868831503bc
Parents: de1b22f
Author: Xuefu Zhang <xzhang@Cloudera.com>
Authored: Wed Nov 18 13:44:21 2015 -0800
Committer: Xuefu Zhang <xzhang@Cloudera.com>
Committed: Wed Nov 18 13:44:21 2015 -0800

----------------------------------------------------------------------
 .../src/test/templates/TestHBaseCliDriver.vm    | 63 ++++++++++++-----
 .../templates/TestHBaseNegativeCliDriver.vm     | 64 ++++++++++++-----
 .../hadoop/hive/hbase/HBaseTestSetup.java       |  9 ++-
 ql/src/test/templates/TestCliDriver.vm          | 74 ++++++++++++++------
 ql/src/test/templates/TestCompareCliDriver.vm   | 71 +++++++++++++------
 ql/src/test/templates/TestNegativeCliDriver.vm  | 70 +++++++++++-------
 ql/src/test/templates/TestParseNegative.vm      | 65 +++++++++++------
 .../ptest2/src/main/resources/batch-exec.vm     |  2 +
 8 files changed, 291 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
----------------------------------------------------------------------
diff --git a/hbase-handler/src/test/templates/TestHBaseCliDriver.vm b/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
index 6f4a7c1..de0be32 100644
--- a/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
+++ b/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
@@ -17,25 +17,38 @@
  */
 package org.apache.hadoop.hive.cli;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.hadoop.hive.ql.QTestUtil;
 import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType;
 import org.apache.hadoop.hive.hbase.HBaseQTestUtil;
 import org.apache.hadoop.hive.hbase.HBaseTestSetup;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class $className {
+public class $className extends TestCase {
 
   private static final String HIVE_ROOT = HBaseQTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
   private HBaseQTestUtil qt;
-  private static HBaseTestSetup setup = new HBaseTestSetup();
+  private HBaseTestSetup setup;
 
-  @Before
-  public void setUp() {
+  public static class TestHBaseCliDriverAddTestFromQFiles implements QTestUtil.SuiteAddTestFunctor
{
+    public void addTestToSuite(TestSuite suite, Object setup, String tName) {
+      suite.addTest(new $className("testCliDriver_"+tName, (HBaseTestSetup)setup));
+    }
+  }
+
+  public $className(String name, HBaseTestSetup setup) {
+    super(name);
+    qt = null;
+    this.setup = setup;
+  }
+
+  @Override
+  protected void setUp() {
 
     MiniClusterType miniMR = MiniClusterType.valueForString("$clusterMode");
     String initScript = "$initScript";
@@ -52,11 +65,12 @@ public class $className {
     }
   }
 
-  @After
-  public void tearDown() {
+  @Override
+  protected void tearDown() {
     try {
       qt.shutdown();
-    } catch (Exception e) {
+    }
+    catch (Exception e) {
       System.err.println("Exception: " + e.getMessage());
       e.printStackTrace();
       System.err.flush();
@@ -64,9 +78,23 @@ public class $className {
     }
   }
 
-  @AfterClass
-  public static void closeHBaseConnections() throws Exception {
-    setup.tearDown();
+  public static Test suite() {
+    Set<String> qFilesToExecute = new HashSet<String>();
+    String qFiles = System.getProperty("qfile", "").trim();
+    if(!qFiles.isEmpty()) {
+      for(String qFile : qFiles.split(",")) {
+        qFile = qFile.trim();
+        if(!qFile.isEmpty()) {
+          qFilesToExecute.add(qFile);
+        }
+      }
+    }
+    TestSuite suite = new TestSuite();
+    HBaseTestSetup setup = new HBaseTestSetup(suite);
+
+    QTestUtil.addTestsToSuiteFromQfileNames("$qFileNamesFile", qFilesToExecute,
+      suite, setup, new TestHBaseCliDriverAddTestFromQFiles());
+    return setup;
   }
 
 #foreach ($qf in $qfiles)
@@ -74,7 +102,6 @@ public class $className {
   #set ($eidx = $fname.indexOf('.'))
   #set ($tname = $fname.substring(0, $eidx))
   #set ($fpath = $qfilesMap.get($fname))
-  @Test
   public void testCliDriver_$tname() throws Exception {
     runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
----------------------------------------------------------------------
diff --git a/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm b/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
index 043bd87..b402585 100644
--- a/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
+++ b/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
@@ -18,25 +18,38 @@
 
 package org.apache.hadoop.hive.cli;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
+import org.apache.hadoop.hive.ql.QTestUtil;
 import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType;
 import org.apache.hadoop.hive.hbase.HBaseQTestUtil;
 import org.apache.hadoop.hive.hbase.HBaseTestSetup;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
 
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class $className {
+public class $className extends TestCase {
 
   private static final String HIVE_ROOT = HBaseQTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
   private HBaseQTestUtil qt;
-  private static HBaseTestSetup setup = new HBaseTestSetup();
+  private HBaseTestSetup setup;
+
+  public static class TestHBaseNegativeCliDriverAddTestFromQFiles implements QTestUtil.SuiteAddTestFunctor
{
+    public void addTestToSuite(TestSuite suite, Object setup, String tName) {
+      suite.addTest(new $className("testCliDriver_"+tName, (HBaseTestSetup)setup));
+    }
+  }
+
+  public $className(String name, HBaseTestSetup setup) {
+    super(name);
+    qt = null;
+    this.setup = setup;
+  }
 
-  @Before
-  public void setUp() {
+  @Override
+  protected void setUp() {
 
     MiniClusterType miniMR = MiniClusterType.valueForString("$clusterMode");
     String initScript = "$initScript";
@@ -53,11 +66,12 @@ public class $className {
     }
   }
 
-  @After
-  public void tearDown() {
+  @Override
+  protected void tearDown() {
     try {
       qt.shutdown();
-    } catch (Exception e) {
+    }
+    catch (Exception e) {
       System.err.println("Exception: " + e.getMessage());
       e.printStackTrace();
       System.err.flush();
@@ -65,9 +79,24 @@ public class $className {
     }
   }
 
-  @AfterClass
-  public static void closeHBaseConnections() throws Exception {
-    setup.tearDown();
+  public static Test suite() {
+    Set<String> qFilesToExecute = new HashSet<String>();
+    String qFiles = System.getProperty("qfile", "").trim();
+    if(!qFiles.isEmpty()) {
+      for(String qFile : qFiles.split(",")) {
+        qFile = qFile.trim();
+        if(!qFile.isEmpty()) {
+          qFilesToExecute.add(qFile);
+        }
+      }
+    }
+
+    TestSuite suite = new TestSuite();
+    HBaseTestSetup setup = new HBaseTestSetup(suite);
+
+    QTestUtil.addTestsToSuiteFromQfileNames("$qFileNamesFile", qFilesToExecute,
+      suite, setup, new TestHBaseNegativeCliDriverAddTestFromQFiles());
+    return setup;
   }
 
 #foreach ($qf in $qfiles)
@@ -75,7 +104,6 @@ public class $className {
   #set ($eidx = $fname.indexOf('.'))
   #set ($tname = $fname.substring(0, $eidx))
   #set ($fpath = $qfilesMap.get($fname))
-  @Test
   public void testCliDriver_$tname() throws Exception {
     runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java
----------------------------------------------------------------------
diff --git a/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java b/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java
index e6383dc..300f1cf 100644
--- a/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java
+++ b/itests/util/src/main/java/org/apache/hadoop/hive/hbase/HBaseTestSetup.java
@@ -45,7 +45,7 @@ import org.apache.zookeeper.Watcher;
  * HBaseTestSetup defines HBase-specific test fixtures which are
  * reused across testcases.
  */
-public class HBaseTestSetup {
+public class HBaseTestSetup extends TestSetup {
 
   private MiniHBaseCluster hbaseCluster;
   private int zooKeeperPort;
@@ -54,6 +54,10 @@ public class HBaseTestSetup {
 
   private static final int NUM_REGIONSERVERS = 1;
 
+  public HBaseTestSetup(Test test) {
+    super(test);
+  }
+
   public HConnection getConnection() {
     return this.hbaseConn;
   }
@@ -166,7 +170,8 @@ public class HBaseTestSetup {
     return port;
   }
 
-  public void tearDown() throws Exception {
+  @Override
+  protected void tearDown() throws Exception {
     if (hbaseConn != null) {
       hbaseConn.close();
       hbaseConn = null;

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/ql/src/test/templates/TestCliDriver.vm
----------------------------------------------------------------------
diff --git a/ql/src/test/templates/TestCliDriver.vm b/ql/src/test/templates/TestCliDriver.vm
index fa638ae..01745da 100644
--- a/ql/src/test/templates/TestCliDriver.vm
+++ b/ql/src/test/templates/TestCliDriver.vm
@@ -17,21 +17,28 @@
  */
 package org.apache.hadoop.hive.cli;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
 import org.apache.hadoop.hive.ql.QTestUtil;
 import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.apache.hadoop.hive.ql.session.SessionState;
 
-public class $className {
+public class $className extends TestCase {
 
   private static final String HIVE_ROOT = QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
   private static QTestUtil qt;
 
+  public static class TestCliDriverAddTestFromQFiles implements QTestUtil.SuiteAddTestFunctor
{
+    public void addTestToSuite(TestSuite suite, Object setup, String tName) {
+      suite.addTest(new $className("testCliDriver_"+tName));
+    }
+  }
+
   static {
 
     MiniClusterType miniMR = MiniClusterType.valueForString("$clusterMode");
@@ -59,8 +66,12 @@ public class $className {
     }
   }
 
-  @Before
-  public void setUp() {
+  public $className(String name) {
+    super(name);
+  }
+
+  @Override
+  protected void setUp() {
     try {
       qt.clearTestSideEffects();
     } catch (Exception e) {
@@ -71,11 +82,21 @@ public class $className {
     }
   }
 
-  @After
-  public void tearDown() {
+  /**
+   * Dummy last test. This is only meant to shutdown qt
+   */
+  public void testCliDriver_shutdown() {
+    System.err.println ("Cleaning up " + "$className");
+  }
+
+  @Override
+  protected void tearDown() {
     try {
       qt.clearPostTestEffects();
-    } catch (Exception e) {
+      if (getName().equals("testCliDriver_shutdown"))
+        qt.shutdown();
+    }
+    catch (Exception e) {
       System.err.println("Exception: " + e.getMessage());
       e.printStackTrace();
       System.err.flush();
@@ -83,16 +104,24 @@ public class $className {
     }
   }
 
-  @AfterClass
-  public static void shutdown() throws Exception {
-    try {
-      qt.shutdown();
-    } catch (Exception e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.flush();
-      fail("Unexpected exception in shutdown");
+  public static Test suite() {
+    Set<String> qFilesToExecute = new HashSet<String>();
+    String qFiles = System.getProperty("qfile", "").trim();
+    if(!qFiles.isEmpty()) {
+      for(String qFile : qFiles.split(",")) {
+        qFile = qFile.trim();
+        if(!qFile.isEmpty()) {
+          qFilesToExecute.add(qFile);
+        }
+      }
     }
+
+    TestSuite suite = new TestSuite();
+
+    QTestUtil.addTestsToSuiteFromQfileNames("$qFileNamesFile", qFilesToExecute,
+      suite, null, new TestCliDriverAddTestFromQFiles());
+    suite.addTest(new $className("testCliDriver_shutdown"));
+    return suite;
   }
 
   static String debugHint = "\nSee ./ql/target/tmp/log/hive.log or ./itests/qtest/target/tmp/log/hive.log,
"
@@ -103,7 +132,6 @@ public class $className {
   #set ($eidx = $fname.indexOf('.'))
   #set ($tname = $fname.substring(0, $eidx))
   #set ($fpath = $qfilesMap.get($fname))
-  @Test
   public void testCliDriver_$tname() throws Exception {
     runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/ql/src/test/templates/TestCompareCliDriver.vm
----------------------------------------------------------------------
diff --git a/ql/src/test/templates/TestCompareCliDriver.vm b/ql/src/test/templates/TestCompareCliDriver.vm
index 5e44315..7f849e0 100644
--- a/ql/src/test/templates/TestCompareCliDriver.vm
+++ b/ql/src/test/templates/TestCompareCliDriver.vm
@@ -17,23 +17,29 @@
  */
 package org.apache.hadoop.hive.cli;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import java.io.*;
 import java.util.*;
+import java.util.Arrays;
 
 import org.apache.hadoop.hive.ql.QTestUtil;
 import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.fail;
+import org.apache.hadoop.hive.ql.session.SessionState;
 
-public class $className {
+public class $className extends TestCase {
 
   private static final String HIVE_ROOT = QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
   private static QTestUtil qt;
 
+  public static class TestCompareCliDriverAddTestFromQFiles implements QTestUtil.SuiteAddTestFunctor
{
+    public void addTestToSuite(TestSuite suite, Object setup, String tName) {
+      suite.addTest(new $className("testCompareCliDriver_"+tName));
+    }
+  }
+
   static {
 
     MiniClusterType miniMR = MiniClusterType.valueForString("$clusterMode");
@@ -60,8 +66,12 @@ public class $className {
     }
   }
 
-  @Before
-  public void setUp() {
+  public $className(String name) {
+    super(name);
+  }
+
+  @Override
+  protected void setUp() {
     try {
       qt.clearTestSideEffects();
     } catch (Exception e) {
@@ -72,11 +82,21 @@ public class $className {
     }
   }
 
-  @After
-  public void tearDown() {
+  /**
+   * Dummy last test. This is only meant to shutdown qt
+   */
+  public void testCompareCliDriver_shutdown() {
+    System.err.println ("Cleaning up " + "$className");
+  }
+
+  @Override
+  protected void tearDown() {
     try {
       qt.clearPostTestEffects();
-    } catch (Exception e) {
+      if (getName().equals("testCompareCliDriver_shutdown"))
+        qt.shutdown();
+    }
+    catch (Exception e) {
       System.err.println("Exception: " + e.getMessage());
       e.printStackTrace();
       System.err.flush();
@@ -84,16 +104,24 @@ public class $className {
     }
   }
 
-  @AfterClass
-  public static void shutdown() throws Exception {
-    try {
-      qt.shutdown();
-    } catch (Exception e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.flush();
-      fail("Unexpected exception in shutdown");
+  public static Test suite() {
+    Set<String> qFilesToExecute = new HashSet<String>();
+    String qFiles = System.getProperty("qfile", "").trim();
+    if(!qFiles.isEmpty()) {
+      for(String qFile : qFiles.split(",")) {
+        qFile = qFile.trim();
+        if(!qFile.isEmpty()) {
+          qFilesToExecute.add(qFile);
+        }
+      }
     }
+
+    TestSuite suite = new TestSuite();
+
+    QTestUtil.addTestsToSuiteFromQfileNames("$qFileNamesFile", qFilesToExecute,
+      suite, null, new TestCompareCliDriverAddTestFromQFiles());
+    suite.addTest(new $className("testCompareCliDriver_shutdown"));
+    return suite;
   }
 
   private Map<String, List<String>> versionFiles = new HashMap<String, List<String>>();
@@ -106,7 +134,6 @@ public class $className {
   #set ($eidx = $fname.indexOf('.'))
   #set ($tname = $fname.substring(0, $eidx))
   #set ($fpath = $qfilesMap.get($fname))
-  @Test
   public void testCompareCliDriver_$tname() throws Exception {
     runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/ql/src/test/templates/TestNegativeCliDriver.vm
----------------------------------------------------------------------
diff --git a/ql/src/test/templates/TestNegativeCliDriver.vm b/ql/src/test/templates/TestNegativeCliDriver.vm
index 85c1e7f..5f8ee8e 100644
--- a/ql/src/test/templates/TestNegativeCliDriver.vm
+++ b/ql/src/test/templates/TestNegativeCliDriver.vm
@@ -17,21 +17,28 @@
  */
 package org.apache.hadoop.hive.cli;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import java.io.*;
+import java.util.*;
+
 import org.apache.hadoop.hive.ql.QTestUtil;
 import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import org.apache.hadoop.hive.ql.exec.Task;
 
-public class $className {
+public class $className extends TestCase {
 
   private static final String HIVE_ROOT = QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
   private static QTestUtil qt;
 
+  public static class TestNegativeCliDriverAddTestFromQFiles implements QTestUtil.SuiteAddTestFunctor
{
+    public void addTestToSuite(TestSuite suite, Object setup, String tName) {
+      suite.addTest(new $className("testNegativeCliDriver_"+tName));
+    }
+  }
+
   static {
     MiniClusterType miniMR = MiniClusterType.valueForString("$clusterMode");
     String initScript = "$initScript";
@@ -52,22 +59,30 @@ public class $className {
     }
   }
 
-  @Before
-  public void setUp() {
+  public $className(String name) {
+    super(name);
+  }
+
+  @Override
+  protected void setUp() {
     try {
       qt.clearTestSideEffects();
-    } catch (Throwable e) {
+    }
+    catch (Throwable e) {
       e.printStackTrace();
       System.err.flush();
       fail("Unexpected exception in setup");
     }
   }
 
-  @After
-  public void tearDown() {
+  @Override
+  protected void tearDown() {
     try {
       qt.clearPostTestEffects();
-    } catch (Exception e) {
+      if (getName().equals("testNegativeCliDriver_shutdown"))
+        qt.shutdown();
+    }
+    catch (Exception e) {
       System.err.println("Exception: " + e.getMessage());
       e.printStackTrace();
       System.err.flush();
@@ -75,16 +90,24 @@ public class $className {
     }
   }
 
-  @AfterClass
-  public static void shutdown() throws Exception {
-    try {
-      qt.shutdown();
-    } catch (Exception e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.flush();
-      fail("Unexpected exception in shutdown");
+  public static Test suite() {
+    Set<String> qFilesToExecute = new HashSet<String>();
+    String qFiles = System.getProperty("qfile", "").trim();
+    if(!qFiles.isEmpty()) {
+      for(String qFile : qFiles.split(",")) {
+        qFile = qFile.trim();
+        if(!qFile.isEmpty()) {
+          qFilesToExecute.add(qFile);
+        }
+      }
     }
+
+    TestSuite suite = new TestSuite();
+
+    QTestUtil.addTestsToSuiteFromQfileNames("$qFileNamesFile", qFilesToExecute,
+      suite, null, new TestNegativeCliDriverAddTestFromQFiles());
+    suite.addTest(new $className("testNegativeCliDriver_shutdown"));
+    return suite;
   }
 
   /**
@@ -102,7 +125,6 @@ public class $className {
   #set ($eidx = $fname.indexOf('.'))
   #set ($tname = $fname.substring(0, $eidx))
   #set ($fpath = $qfilesMap.get($fname))
-  @Test
   public void testNegativeCliDriver_$tname() throws Exception {
     runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/ql/src/test/templates/TestParseNegative.vm
----------------------------------------------------------------------
diff --git a/ql/src/test/templates/TestParseNegative.vm b/ql/src/test/templates/TestParseNegative.vm
index a4397f7..c5e7bdf 100755
--- a/ql/src/test/templates/TestParseNegative.vm
+++ b/ql/src/test/templates/TestParseNegative.vm
@@ -17,23 +17,27 @@
  */
 package org.apache.hadoop.hive.ql.parse;
 
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
 import java.io.*;
 import java.util.*;
 
 import org.apache.hadoop.hive.ql.QTestUtil;
 import org.apache.hadoop.hive.ql.QTestUtil.MiniClusterType;
 import org.apache.hadoop.hive.ql.exec.Task;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
-public class $className {
+public class $className extends TestCase {
 
   private static final String HIVE_ROOT = QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
   private static QTestUtil qt;
+
+  public static class TestParseNegativeAddTestFromQFiles implements QTestUtil.SuiteAddTestFunctor
{
+    public void addTestToSuite(TestSuite suite, Object setup, String tName) {
+      suite.addTest(new $className("testParseNegative_"+tName));
+    }
+  }
  
   static {
 
@@ -53,11 +57,18 @@ public class $className {
     }
   }
 
-  @After
-  public void tearDown() {
+  public $className(String name) {
+    super(name);
+  }
+
+  @Override
+  protected void tearDown() {
     try {
       qt.clearPostTestEffects();
-    } catch (Exception e) {
+      if (getName().equals("testParseNegative_shutdown"))
+        qt.shutdown();
+    }
+    catch (Exception e) {
       System.err.println("Exception: " + e.getMessage());
       e.printStackTrace();
       System.err.flush();
@@ -65,16 +76,31 @@ public class $className {
     }
   }
 
-  @AfterClass
-  public static void shutdown() throws Exception {
-    try {
-      qt.shutdown();
-    } catch (Exception e) {
-      System.err.println("Exception: " + e.getMessage());
-      e.printStackTrace();
-      System.err.flush();
-      fail("Unexpected exception in shutdown");
+  /**
+   * Dummy last test. This is only meant to shutdown qt
+   */
+  public void testParseNegative_shutdown() {
+    System.err.println ("Cleaning up " + "$className");
+  }
+
+  public static Test suite() {
+    Set<String> qFilesToExecute = new HashSet<String>();
+    String qFiles = System.getProperty("qfile", "").trim();
+    if(!qFiles.isEmpty()) {
+      for(String qFile : qFiles.split(",")) {
+        qFile = qFile.trim();
+        if(!qFile.isEmpty()) {
+          qFilesToExecute.add(qFile);
+        }
+      }
     }
+
+    TestSuite suite = new TestSuite();
+
+    QTestUtil.addTestsToSuiteFromQfileNames("$qFileNamesFile", qFilesToExecute,
+      suite, null, new TestParseNegativeAddTestFromQFiles());
+    suite.addTest(new $className("testParseNegative_shutdown"));
+    return suite;
   }
 
   static String debugHint = "\nSee ./ql/target/tmp/log/hive.log or ./itests/qtest/target/tmp/log/hive.log,
"
@@ -85,7 +111,6 @@ public class $className {
   #set ($eidx = $fname.indexOf('.'))
   #set ($tname = $fname.substring(0, $eidx))
   #set ($fpath = $qfilesMap.get($fname))
-  @Test
   public void testParseNegative_$tname() throws Exception {
     runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
   }

http://git-wip-us.apache.org/repos/asf/hive/blob/fb944ee4/testutils/ptest2/src/main/resources/batch-exec.vm
----------------------------------------------------------------------
diff --git a/testutils/ptest2/src/main/resources/batch-exec.vm b/testutils/ptest2/src/main/resources/batch-exec.vm
index da3e0ac..c155851 100644
--- a/testutils/ptest2/src/main/resources/batch-exec.vm
+++ b/testutils/ptest2/src/main/resources/batch-exec.vm
@@ -62,6 +62,8 @@ then
     testModule=./
   fi
   pushd $testModule
+  #clean to force regeneration of class files (maven sometimes skips generation)
+  mvn clean -Dmaven.repo.local=$localDir/$instanceName/maven $mavenArgs
   timeout 2h mvn -B test -Dmaven.repo.local=$localDir/$instanceName/maven \
     $mavenArgs $mavenTestArgs $testArguments 1>$logDir/maven-test.txt 2>&1 </dev/null
&
 #[[


Mime
View raw message