diff --git a/accumulo-handler/src/test/templates/TestAccumuloCliDriver.vm b/accumulo-handler/src/test/templates/TestAccumuloCliDriver.vm index dd1ee64..0baf1bd 100644 --- a/accumulo-handler/src/test/templates/TestAccumuloCliDriver.vm +++ b/accumulo-handler/src/test/templates/TestAccumuloCliDriver.vm @@ -85,14 +85,38 @@ public class $className extends TestCase { } TestSuite suite = new TestSuite(); AccumuloTestSetup setup = new AccumuloTestSetup(suite); -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testCliDriver_$tname", setup)); + + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testCliDriver_"+tName, setup)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end return setup; } diff --git a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java index ca959c0..60c7764 100644 --- a/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java +++ b/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hive.ant; +import java.io.BufferedWriter; import java.io.File; import java.io.FileFilter; import java.io.FileWriter; @@ -453,6 +454,29 @@ public void execute() throws BuildException { hadoopVersion = ""; } + File qFileNames = new File(outputDirectory, className + "QFileNames.txt"); + String qFileNamesFile = qFileNames.getCanonicalPath(); + + if (qFileNames.exists()) { + if (!qFileNames.delete()) { + throw new Exception("Could not delete old query file names containing file " + + qFileNamesFile); + } + } + if (!qFileNames.createNewFile()) { + throw new Exception("Could not create query file names containing file " + + qFileNamesFile); + } + + FileWriter fw = new FileWriter(qFileNames.getCanonicalFile()); + BufferedWriter bw = new BufferedWriter(fw); + + for (File qFile: qFiles) { + bw.write(qFile.getName()); + bw.newLine(); + } + bw.close(); + // For each of the qFiles generate the test System.out.println("hiveRootDir = " + hiveRootDir); VelocityContext ctx = new VelocityContext(); @@ -464,6 +488,7 @@ public void execute() throws BuildException { System.out.println("queryDir = " + strQueryDir); ctx.put("queryDir", strQueryDir); ctx.put("qfiles", qFiles); + ctx.put("qFileNamesFile", qFileNamesFile); ctx.put("qfilesMap", qFilesMap); if (resultsDir != null) { ctx.put("resultsDir", relativePath(hiveRootDir, resultsDir)); diff --git a/hbase-handler/src/test/templates/TestHBaseCliDriver.vm b/hbase-handler/src/test/templates/TestHBaseCliDriver.vm index 69fad97..073148f 100644 --- a/hbase-handler/src/test/templates/TestHBaseCliDriver.vm +++ b/hbase-handler/src/test/templates/TestHBaseCliDriver.vm @@ -84,14 +84,38 @@ public class $className extends TestCase { } TestSuite suite = new TestSuite(); HBaseTestSetup setup = new HBaseTestSetup(suite); -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testCliDriver_$tname", setup)); + + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testCliDriver_"+tName, setup)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end return setup; } diff --git a/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm b/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm index 82f0584..99a9f8e 100644 --- a/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm +++ b/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm @@ -85,14 +85,38 @@ public class $className extends TestCase { } TestSuite suite = new TestSuite(); HBaseTestSetup setup = new HBaseTestSetup(suite); -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testCliDriver_$tname", setup)); + + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testCliDriver_"+tName, setup)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end return setup; } diff --git a/ql/src/test/templates/TestCliDriver.vm b/ql/src/test/templates/TestCliDriver.vm index 8827f12..c7ac652 100644 --- a/ql/src/test/templates/TestCliDriver.vm +++ b/ql/src/test/templates/TestCliDriver.vm @@ -108,15 +108,40 @@ public class $className extends TestCase { } } } + TestSuite suite = new TestSuite(); -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testCliDriver_$tname")); + + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testCliDriver_"+tName)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end suite.addTest(new $className("testCliDriver_shutdown")); return suite; } diff --git a/ql/src/test/templates/TestCompareCliDriver.vm b/ql/src/test/templates/TestCompareCliDriver.vm index 6b367d6..15ada97 100644 --- a/ql/src/test/templates/TestCompareCliDriver.vm +++ b/ql/src/test/templates/TestCompareCliDriver.vm @@ -110,17 +110,39 @@ public class $className extends TestCase { } } TestSuite suite = new TestSuite(); - - - -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if (qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testCompareCliDriver_$tname")); + + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testCompareCliDriver_"+tName)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end + suite.addTest(new $className("testCompareCliDriver_shutdown")); return suite; } diff --git a/ql/src/test/templates/TestNegativeCliDriver.vm b/ql/src/test/templates/TestNegativeCliDriver.vm index 742044a..9b96230 100644 --- a/ql/src/test/templates/TestNegativeCliDriver.vm +++ b/ql/src/test/templates/TestNegativeCliDriver.vm @@ -96,14 +96,39 @@ public class $className extends TestCase { } } TestSuite suite = new TestSuite(); -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testNegativeCliDriver_$tname")); + + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testNegativeCliDriver_"+tName)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end + suite.addTest(new $className("testNegativeCliDriver_shutdown")); return suite; } diff --git a/ql/src/test/templates/TestParseNegative.vm b/ql/src/test/templates/TestParseNegative.vm index 33b238e..2daea8b 100755 --- a/ql/src/test/templates/TestParseNegative.vm +++ b/ql/src/test/templates/TestParseNegative.vm @@ -90,14 +90,37 @@ public class $className extends TestCase { } TestSuite suite = new TestSuite(); -#foreach ($qf in $qfiles) - #set ($fname = $qf.getName()) - #set ($eidx = $fname.indexOf('.')) - #set ($tname = $fname.substring(0, $eidx)) - if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) { - suite.addTest(new $className("testParseNegative_$tname")); + try { + String qFileNamesFile = "$qFileNamesFile"; + File qFileNames = new File(qFileNamesFile); + FileReader fr = new FileReader(qFileNames.getCanonicalFile()); + BufferedReader br = new BufferedReader(fr); + String fName = null; + + while ((fName = br.readLine()) != null) { + if (fName.isEmpty() || fName.trim().equals("")) { + continue; + } + + int eIdx = fName.indexOf('.'); + + if (eIdx == -1) { + continue; + } + + String tName = fName.substring(0, eIdx); + + if (qFilesToExecute.isEmpty() || qFilesToExecute.contains(fName)) { + suite.addTest(new $className("testParseNegative_"+tName)); + } + } + br.close(); + } catch (Exception e) { + System.err.println("Exception: " + e.getMessage()); + e.printStackTrace(); + System.err.flush(); + fail("Unexpected exception in suite"); } -#end suite.addTest(new $className("testParseNegative_shutdown")); return suite; }