Author: hashutosh
Date: Tue Oct 1 22:13:34 2013
New Revision: 1528230
URL: http://svn.apache.org/r1528230
Log:
HIVE-5114 : add a target to run tests without rebuilding them (Sergey Shelukhin
& Brock Noland via Ashutosh Chauhan)
Modified:
hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
hive/trunk/build-common.xml
hive/trunk/build.xml
hive/trunk/common/build.xml
hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm
hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
hive/trunk/hcatalog/build-support/ant/build-common.xml
hive/trunk/hcatalog/build.xml
hive/trunk/hcatalog/storage-handlers/hbase/build.xml
hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java
hive/trunk/ql/src/test/templates/TestBeeLineDriver.vm
hive/trunk/ql/src/test/templates/TestCliDriver.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/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java
URL:
http://svn.apache.org/viewvc/hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java (original)
+++ hive/trunk/ant/src/org/apache/hadoop/hive/ant/QTestGenTask.java Tue Oct 1
22:13:34 2013
@@ -367,7 +367,7 @@ public class QTestGenTask extends Task {
Collections.sort(qFiles);
for (File qFile : qFiles) {
- qFilesMap.put(qFile.getName(), getEscapedCanonicalPath(qFile));
+ qFilesMap.put(qFile.getName(), relativePath(hiveRootDir, qFile));
}
// Make sure the output directory exists, if it doesn't
@@ -418,12 +418,12 @@ public class QTestGenTask extends Task {
// For each of the qFiles generate the test
VelocityContext ctx = new VelocityContext();
ctx.put("className", className);
- ctx.put("hiveRootDir", getEscapedCanonicalPath(hiveRootDir));
- ctx.put("queryDir", getEscapedCanonicalPath(queryDir));
+ ctx.put("hiveRootDir", escapePath(hiveRootDir.getCanonicalPath()));
+ ctx.put("queryDir", relativePath(hiveRootDir, queryDir));
ctx.put("qfiles", qFiles);
ctx.put("qfilesMap", qFilesMap);
- ctx.put("resultsDir", getEscapedCanonicalPath(resultsDir));
- ctx.put("logDir", getEscapedCanonicalPath(logDir));
+ ctx.put("resultsDir", relativePath(hiveRootDir, resultsDir));
+ ctx.put("logDir", relativePath(hiveRootDir, logDir));
ctx.put("clusterMode", clusterMode);
ctx.put("hadoopVersion", hadoopVersion);
@@ -447,8 +447,10 @@ public class QTestGenTask extends Task {
throw new BuildException("Generation failed", e);
}
}
-
- private static String getEscapedCanonicalPath(File file) throws IOException {
+ private String relativePath(File hiveRootDir, File file) {
+ return escapePath(hiveRootDir.toURI().relativize(file.toURI()).getPath());
+ }
+ private static String escapePath(String path) {
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
// Escape the backward slash in CanonicalPath if the unit test runs on
windows
// e.g. dir.getCanonicalPath() gets the absolute path of local
@@ -456,8 +458,8 @@ public class QTestGenTask extends Task {
// in compiler error in windows. Reason : the canonical path contains
backward
// slashes "C:\temp\etc\" and it is not a valid string in Java
// unless we escape the backward slashes.
- return file.getCanonicalPath().replace("\\", "\\\\");
+ return path.replace("\\", "\\\\");
}
- return file.getCanonicalPath();
+ return path;
}
}
Modified: hive/trunk/build-common.xml
URL:
http://svn.apache.org/viewvc/hive/trunk/build-common.xml?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/build-common.xml (original)
+++ hive/trunk/build-common.xml Tue Oct 1 22:13:34 2013
@@ -408,6 +408,10 @@
<!-- target to run the tests -->
<target name="test"
depends="test-conditions,gen-test,compile-test,test-jar,test-init">
+ <antcall target="testonly" />
+ </target>
+
+ <target name="testonly" depends="test-conditions,test-init">
<echo message="Project: ${ant.project.name}"/>
<property name="hadoop.testcp" refid="test.classpath"/>
<if>
@@ -478,6 +482,7 @@
<sysproperty key="hadoop.bin.path"
value="${test.hadoop.bin.path}${junit.script.extension}"/>
<sysproperty key="test.concurrency.num.threads"
value="${test.concurrency.num.threads}"/>
<sysproperty key="hive.home" value="${hive.root}/build/dist"/>
+ <sysproperty key="qfile" value="${qfile}"/>
<jvmarg line="${junit.jvm.args}"/>
<classpath refid="test.local.classpath"/>
Modified: hive/trunk/build.xml
URL:
http://svn.apache.org/viewvc/hive/trunk/build.xml?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/build.xml (original)
+++ hive/trunk/build.xml Tue Oct 1 22:13:34 2013
@@ -347,23 +347,38 @@
<echo message="Project: ${ant.project.name}"/>
<iterate target="compile-test" iterate="${iterate.hive.tests}"/>
</target>
-
+
<target name="test" depends="clean-test,jar-test" description="Run tests">
+ <property name="test.target.name" value="test"/>
+ <antcall target="testonly" />
+ </target>
+
+
+
+ <!-- target to run the tests -->
+ <target name="testonly">
+ <if>
+ <not><isset property="test.target.name"/></not>
+ <then><property name="test.target.name" value="testonly"/></then>
+ </if>
<echo message="Project: ${ant.project.name}"/>
<if>
+ <or>
<isset property="module"/>
+ <equals arg1="${test.target.name}" arg2="testonly"/>
+ </or>
<else>
<antcall target="test-shims">
<param name="hadoop.version.ant-internal"
value="${hadoop.security.version}" />
</antcall>
</else>
</if>
- <condition property="target.module" value="${module}"
else="${iterate.hive.test}">
+ <condition property="target.module" value="${module}"
else="${iterate.hive.tests}">
<isset property="module"/>
</condition>
<for keepgoing="${test.continue.on.failure}" list="${target.module}"
param="module">
<sequential>
- <ant antfile="@{module}/build.xml" target="test" inheritAll="false"
inheritRefs="true">
+ <ant antfile="@{module}/build.xml" target="${test.target.name}"
inheritAll="false" inheritRefs="true">
<property name="build.dir.hive" location="${build.dir.hive}"/>
<property name="is-offline" value="${is-offline}"/>
</ant>
Modified: hive/trunk/common/build.xml
URL:
http://svn.apache.org/viewvc/hive/trunk/common/build.xml?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/common/build.xml (original)
+++ hive/trunk/common/build.xml Tue Oct 1 22:13:34 2013
@@ -54,6 +54,14 @@ to call at top-level: ant deploy-contrib
<!-- target to run the tests -->
<target name="test"
depends="test-conditions,gen-test,compile-test,test-jar,test-init">
+ <antcall target="testonly" />
+ </target>
+
+
+
+ <!-- target to run the tests -->
+ <target name="testonly"
+ depends="test-conditions,test-init">
<echo message="Project: ${ant.project.name}"/>
<junit showoutput="${test.output}" printsummary="yes" haltonfailure="no"
fork="yes" maxmemory="512m" dir="${basedir}"
timeout="${test.junit.timeout}"
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=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm (original)
+++ hive/trunk/hbase-handler/src/test/templates/TestHBaseCliDriver.vm Tue Oct
1 22:13:34 2013
@@ -30,6 +30,7 @@ import org.apache.hadoop.hive.ql.session
public class $className extends TestCase {
+ private static final String HIVE_ROOT =
HBaseQTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
private HBaseQTestUtil qt;
private HBaseTestSetup setup;
@@ -42,16 +43,13 @@ public class $className extends TestCase
@Override
protected void setUp() {
try {
- boolean miniMR = false;
- if ("$clusterMode".equals("miniMR")) {
- miniMR = true;
- }
- qt = new HBaseQTestUtil("$resultsDir", "$logDir", miniMR, setup);
+ boolean miniMR = "$clusterMode".equals("miniMR");
+ qt = new HBaseQTestUtil((HIVE_ROOT + "$resultsDir"), (HIVE_ROOT +
"$logDir"), miniMR, setup);
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in setup");
}
}
@@ -62,21 +60,33 @@ public class $className extends TestCase
qt.shutdown();
}
catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in 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);
#foreach ($qf in $qfiles)
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- suite.addTest(new $className("testCliDriver_$tname", setup));
+ if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) {
+ suite.addTest(new $className("testCliDriver_$tname", setup));
+ }
#end
return setup;
}
@@ -85,9 +95,9 @@ public class $className extends TestCase
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- #set ($fpath = $qf.getCanonicalPath().replaceAll("\\","\\\\"))
+ #set ($fpath = $qfilesMap.get($fname))
public void testCliDriver_$tname() throws Exception {
- runTest("$tname", "$fname", "$fpath");
+ runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
}
#end
@@ -95,12 +105,12 @@ public class $className extends TestCase
private void runTest(String tname, String fname, String fpath) throws
Exception {
long startTime = System.currentTimeMillis();
try {
- System.out.println("Begin query: " + fname);
+ System.err.println("Begin query: " + fname);
qt.addFile(fpath);
if (qt.shouldBeSkipped(fname)) {
- System.out.println("Test " + fname + " skipped");
+ System.err.println("Test " + fname + " skipped");
return;
}
@@ -118,15 +128,15 @@ public class $className extends TestCase
qt.clearPostTestEffects();
} catch (Throwable e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.println("Failed query: " + fname);
- System.out.flush();
+ System.err.println("Failed query: " + fname);
+ System.err.flush();
fail("Unexpected exception");
}
long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
+ System.err.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
assertTrue("Test passed", true);
}
}
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=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
(original)
+++ hive/trunk/hbase-handler/src/test/templates/TestHBaseNegativeCliDriver.vm
Tue Oct 1 22:13:34 2013
@@ -12,6 +12,7 @@ import org.apache.hadoop.hive.hbase.HBas
public class $className extends TestCase {
+ private static final String HIVE_ROOT =
HBaseQTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
private HBaseQTestUtil qt;
private HBaseTestSetup setup;
@@ -24,17 +25,14 @@ public class $className extends TestCase
@Override
protected void setUp() {
try {
- boolean miniMR = false;
- if ("$clusterMode".equals("miniMR")) {
- miniMR = true;
- }
+ boolean miniMR = "$clusterMode".equals("miniMR");
- qt = new HBaseQTestUtil("$resultsDir", "$logDir", miniMR, setup);
+ qt = new HBaseQTestUtil((HIVE_ROOT + "$resultsDir"), (HIVE_ROOT +
"$logDir"), miniMR, setup);
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in setup");
}
}
@@ -45,21 +43,33 @@ public class $className extends TestCase
qt.shutdown();
}
catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in 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);
#foreach ($qf in $qfiles)
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- suite.addTest(new $className("testCliDriver_$tname", setup));
+ if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) {
+ suite.addTest(new $className("testCliDriver_$tname", setup));
+ }
#end
return setup;
}
@@ -68,9 +78,9 @@ public class $className extends TestCase
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- #set ($fpath = $qf.getCanonicalPath().replaceAll("\\","\\\\"))
+ #set ($fpath = $qfilesMap.get($fname))
public void testCliDriver_$tname() throws Exception {
- runTest("$tname", "$fname", "$fpath");
+ runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
}
#end
@@ -78,12 +88,12 @@ public class $className extends TestCase
private void runTest(String tname, String fname, String fpath) throws
Exception {
long startTime = System.currentTimeMillis();
try {
- System.out.println("Begin query: " + fname);
+ System.err.println("Begin query: " + fname);
qt.addFile(fpath);
if (qt.shouldBeSkipped(fname)) {
- System.out.println("Test " + fname + " skipped");
+ System.err.println("Test " + fname + " skipped");
return;
}
@@ -101,15 +111,15 @@ public class $className extends TestCase
qt.clearPostTestEffects();
} catch (Throwable e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.println("Failed query: " + fname);
- System.out.flush();
+ System.err.println("Failed query: " + fname);
+ System.err.flush();
fail("Unexpected exception");
}
long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
+ System.err.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
assertTrue("Test passed", true);
}
}
Modified: hive/trunk/hcatalog/build-support/ant/build-common.xml
URL:
http://svn.apache.org/viewvc/hive/trunk/hcatalog/build-support/ant/build-common.xml?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/hcatalog/build-support/ant/build-common.xml (original)
+++ hive/trunk/hcatalog/build-support/ant/build-common.xml Tue Oct 1 22:13:34
2013
@@ -93,6 +93,10 @@
</target>
<target name="test" depends="jar, compile-test">
+ <antcall target="testonly" />
+ </target>
+
+ <target name="testonly">
<echo message="${ant.project.name}"/>
<_junit srcDir="${basedir}/src/test/java"/>
</target>
Modified: hive/trunk/hcatalog/build.xml
URL:
http://svn.apache.org/viewvc/hive/trunk/hcatalog/build.xml?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/hcatalog/build.xml (original)
+++ hive/trunk/hcatalog/build.xml Tue Oct 1 22:13:34 2013
@@ -92,39 +92,47 @@
-->
<target name="gen-test" description="Generate tests, a no-op for hcat"/>
-
<target name="test" depends="jar" description="run unit tests">
+ <property name="test.target.name" value="test"/>
+ <antcall target="testonly" />
+ <!-- One checkstyle run for the whole repo. Runs after junit tests
+ to piggyback on resolved jars. -->
+ <path id="checkstyle.class.path">
+ <fileset dir="core/build/lib/test"/>
+ </path>
+ <antcall target="checkstyle" inheritRefs="true"/>
+ </target>
+
+ <target name="testonly">
+ <if>
+ <not><isset property="test.target.name"/></not>
+ <then><property name="test.target.name" value="testonly"/></then>
+ </if>
<mkdir dir="${test.result.dir}"/>
<!-- Placed in a parallel structure so that the tests keep going
even if some fail. Otherwise a failure in one of the earlier ant
call terminates the target and the rest do not run. -->
<parallel threadCount="1">
- <ant target="test" dir="core" inheritAll="false">
+ <ant target="${test.target.name}" dir="core" inheritAll="false">
<property name="test.result.dir"
location="${test.result.dir}"/>
</ant>
- <ant target="test" dir="hcatalog-pig-adapter" inheritAll="false">
+ <ant target="${test.target.name}" dir="hcatalog-pig-adapter"
inheritAll="false">
<property name="test.result.dir"
location="${test.result.dir}"/>
</ant>
- <ant target="test" dir="server-extensions" inheritAll="false">
+ <ant target="${test.target.name}" dir="server-extensions"
inheritAll="false">
<property name="test.result.dir"
location="${test.result.dir}"/>
</ant>
- <ant target="test" dir="webhcat/svr" inheritAll="false">
+ <ant target="${test.target.name}" dir="webhcat/svr"
inheritAll="false">
<property name="test.result.dir"
location="${test.result.dir}"/>
<property name="env.HIVE_HOME" value="${hive.dist.dir}"/>
<property name="env.HCAT_PREFIX"
value="${hive.dist.dir}/hcatalog"/>
</ant>
- <ant target="test" dir="webhcat/java-client" inheritAll="false">
+ <ant target="${test.target.name}" dir="webhcat/java-client"
inheritAll="false">
<property name="test.result.dir"
location="${test.result.dir}"/>
</ant>
- <ant target="test" dir="storage-handlers/hbase" inheritAll="false">
+ <ant target="${test.target.name}" dir="storage-handlers/hbase"
inheritAll="false">
<property name="test.result.dir"
location="${test.result.dir}"/>
</ant>
- <!-- One checkstyle run for the whole repo. Runs after junit tests
- to piggyback on resolved jars. -->
- <path id="checkstyle.class.path">
- <fileset dir="core/build/lib/test"/>
- </path>
- <antcall target="checkstyle" inheritRefs="true"/>
</parallel>
</target>
Modified: hive/trunk/hcatalog/storage-handlers/hbase/build.xml
URL:
http://svn.apache.org/viewvc/hive/trunk/hcatalog/storage-handlers/hbase/build.xml?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/hcatalog/storage-handlers/hbase/build.xml (original)
+++ hive/trunk/hcatalog/storage-handlers/hbase/build.xml Tue Oct 1 22:13:34
2013
@@ -127,14 +127,18 @@
<!-- Run the unit tests -->
<target name="test" depends="compile-test">
+ <antcall target="testonly" />
+ </target>
+
+ <target name="testonly">
<sequential>
<delete dir="${test.log.dir}"/>
- <delete dir="${test.tmp.dir}" />
+ <delete dir="${test.tmp.dir}" />
<delete dir="${test.data.dir}" />
- <mkdir dir="${test.log.dir}"/>
- <mkdir dir="${test.tmp.dir}" />
+ <mkdir dir="${test.log.dir}"/>
+ <mkdir dir="${test.tmp.dir}" />
<mkdir dir="${test.data.dir}" />
- <junit showoutput="${test.output}" printsummary="yes"
haltonfailure="no"
+ <junit showoutput="${test.output}" printsummary="yes"
haltonfailure="no"
fork="yes" maxmemory="512m" dir="${basedir}"
timeout="${test.timeout}"
errorProperty="tests.failed" failureProperty="tests.failed">
<classpath>
Modified: hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java (original)
+++ hive/trunk/ql/src/test/org/apache/hadoop/hive/ql/QTestUtil.java Tue Oct 1
22:13:34 2013
@@ -315,12 +315,7 @@ public class QTestUtil {
testFiles = dataDir;
- String ow = System.getProperty("test.output.overwrite");
- if ((ow != null) && ow.equalsIgnoreCase("true")) {
- overWrite = true;
- } else {
- overWrite = false;
- }
+ overWrite =
"true".equalsIgnoreCase(System.getProperty("test.output.overwrite"));
setup = new QTestSetup();
setup.preTest(conf);
@@ -1534,4 +1529,15 @@ public class QTestUtil {
+ "or try \"ant test ... -Dtest.silent=false\" to get more logs.");
System.err.flush();
}
+
+ public static String ensurePathEndsInSlash(String path) {
+ if(path == null) {
+ throw new NullPointerException("Path cannot be null");
+ }
+ if(path.endsWith(File.separator)) {
+ return path;
+ } else {
+ return path + File.separator;
+ }
+ }
}
Modified: hive/trunk/ql/src/test/templates/TestBeeLineDriver.vm
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestBeeLineDriver.vm?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestBeeLineDriver.vm (original)
+++ hive/trunk/ql/src/test/templates/TestBeeLineDriver.vm Tue Oct 1 22:13:34
2013
@@ -115,7 +115,7 @@ public class $className {
.setTestScriptDirectory(hiveRootDirectory + "/data/scripts");
long startTime = System.currentTimeMillis();
- System.out.println(">>> STARTED " + qFileName
+ System.err.println(">>> STARTED " + qFileName
+ " (Thread " + Thread.currentThread().getName() + ")");
try {
qClient.run();
@@ -128,7 +128,7 @@ public class $className {
String time = "(" + elapsedTime + "s)";
if (qClient.compareResults()) {
- System.out.println(">>> PASSED " + qFileName + " " + time);
+ System.err.println(">>> PASSED " + qFileName + " " + time);
} else {
if (qClient.hasErrors()) {
System.err.println(">>> FAILED " + qFileName + " (ERROR) " + time);
Modified: hive/trunk/ql/src/test/templates/TestCliDriver.vm
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestCliDriver.vm?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestCliDriver.vm (original)
+++ hive/trunk/ql/src/test/templates/TestCliDriver.vm Tue Oct 1 22:13:34 2013
@@ -29,25 +29,23 @@ import org.apache.hadoop.hive.ql.session
public class $className extends TestCase {
+ private static final String HIVE_ROOT =
QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
private static QTestUtil qt;
static {
try {
- boolean miniMR = false;
- String hadoopVer;
- if ("$clusterMode".equals("miniMR"))
- miniMR = true;
- hadoopVer = "$hadoopVersion";
- qt = new QTestUtil("$resultsDir", "$logDir", miniMR, hadoopVer);
+ boolean miniMR = "$clusterMode".equals("miniMR");
+ String hadoopVer = "$hadoopVersion";
+ qt = new QTestUtil((HIVE_ROOT + "$resultsDir"), (HIVE_ROOT + "$logDir"),
miniMR, hadoopVer);
// do a one time initialization
qt.cleanUp();
qt.createSources();
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in static initialization");
}
}
@@ -61,9 +59,9 @@ public class $className extends TestCase
try {
qt.clearTestSideEffects();
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in setup");
}
}
@@ -72,7 +70,7 @@ public class $className extends TestCase
* Dummy last test. This is only meant to shutdown qt
*/
public void testCliDriver_shutdown() {
- System.out.println ("Cleaning up " + "$className");
+ System.err.println ("Cleaning up " + "$className");
}
@Override
@@ -83,20 +81,32 @@ public class $className extends TestCase
qt.shutdown();
}
catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in 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();
#foreach ($qf in $qfiles)
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- suite.addTest(new $className("testCliDriver_$tname"));
+ if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) {
+ suite.addTest(new $className("testCliDriver_$tname"));
+ }
#end
suite.addTest(new $className("testCliDriver_shutdown"));
return suite;
@@ -111,7 +121,7 @@ public class $className extends TestCase
#set ($tname = $fname.substring(0, $eidx))
#set ($fpath = $qfilesMap.get($fname))
public void testCliDriver_$tname() throws Exception {
- runTest("$tname", "$fname", "$fpath");
+ runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
}
#end
@@ -119,7 +129,7 @@ public class $className extends TestCase
private void runTest(String tname, String fname, String fpath) throws
Exception {
long startTime = System.currentTimeMillis();
try {
- System.out.println("Begin query: " + fname);
+ System.err.println("Begin query: " + fname);
qt.addFile(fpath);
@@ -139,15 +149,15 @@ public class $className extends TestCase
}
}
catch (Throwable e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.println("Failed query: " + fname);
- System.out.flush();
+ System.err.println("Failed query: " + fname);
+ System.err.flush();
fail("Unexpected exception" + debugHint);
}
long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
+ System.err.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
assertTrue("Test passed", true);
}
}
Modified: hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm (original)
+++ hive/trunk/ql/src/test/templates/TestNegativeCliDriver.vm Tue Oct 1
22:13:34 2013
@@ -29,23 +29,21 @@ import org.apache.hadoop.hive.ql.exec.Ta
public class $className extends TestCase {
+ private static final String HIVE_ROOT =
QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
private static QTestUtil qt;
static {
try {
- boolean miniMR = false;
- String hadoopVer;
- if ("$clusterMode".equals("miniMR"))
- miniMR = true;
- hadoopVer = "$hadoopVersion";
- qt = new QTestUtil("$resultsDir", "$logDir", miniMR, hadoopVer);
+ boolean miniMR = "$clusterMode".equals("miniMR");
+ String hadoopVer = "$hadoopVersion";
+ qt = new QTestUtil((HIVE_ROOT + "$resultsDir"), (HIVE_ROOT + "$logDir"),
miniMR, hadoopVer);
// do a one time initialization
qt.cleanUp();
qt.createSources();
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in static initialization");
}
}
@@ -61,7 +59,7 @@ public class $className extends TestCase
}
catch (Throwable e) {
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in setup");
}
}
@@ -74,20 +72,32 @@ public class $className extends TestCase
qt.shutdown();
}
catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in 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();
#foreach ($qf in $qfiles)
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- suite.addTest(new $className("testNegativeCliDriver_$tname"));
+ if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) {
+ suite.addTest(new $className("testNegativeCliDriver_$tname"));
+ }
#end
suite.addTest(new $className("testNegativeCliDriver_shutdown"));
return suite;
@@ -97,7 +107,7 @@ public class $className extends TestCase
* Dummy last test. This is only meant to shutdown qt
*/
public void testNegativeCliDriver_shutdown() {
- System.out.println ("Cleaning up " + "$className");
+ System.err.println ("Cleaning up " + "$className");
}
static String debugHint = "\nSee build/ql/tmp/hive.log, "
@@ -109,7 +119,7 @@ public class $className extends TestCase
#set ($tname = $fname.substring(0, $eidx))
#set ($fpath = $qfilesMap.get($fname))
public void testNegativeCliDriver_$tname() throws Exception {
- runTest("$tname", "$fname", "$fpath");
+ runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
}
#end
@@ -117,12 +127,12 @@ public class $className extends TestCase
private void runTest(String tname, String fname, String fpath) throws
Exception {
long startTime = System.currentTimeMillis();
try {
- System.out.println("Begin query: " + fname);
+ System.err.println("Begin query: " + fname);
qt.addFile(fpath);
if (qt.shouldBeSkipped(fname)) {
- System.out.println("Test " + fname + " skipped");
+ System.err.println("Test " + fname + " skipped");
return;
}
@@ -140,15 +150,15 @@ public class $className extends TestCase
}
}
catch (Throwable e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.println("Failed query: " + fname);
- System.out.flush();
+ System.err.println("Failed query: " + fname);
+ System.err.flush();
fail("Unexpected exception" + debugHint);
}
long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
+ System.err.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
assertTrue("Test passed", true);
}
}
Modified: hive/trunk/ql/src/test/templates/TestParse.vm
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestParse.vm?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestParse.vm (original)
+++ hive/trunk/ql/src/test/templates/TestParse.vm Tue Oct 1 22:13:34 2013
@@ -29,20 +29,19 @@ import org.apache.hadoop.hive.ql.exec.Ta
public class $className extends TestCase {
+ private static final String HIVE_ROOT =
QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
private static QTestUtil qt;
static {
try {
- boolean miniMR = false;
- if ("$clusterMode".equals("miniMR"))
- miniMR = true;
+ boolean miniMR = "$clusterMode".equals("miniMR");
String hadoopVer = "$hadoopVersion";
- qt = new QTestUtil("$resultsDir", "$logDir", miniMR, hadoopVer);
+ qt = new QTestUtil((HIVE_ROOT + "$resultsDir"), (HIVE_ROOT + "$logDir"),
miniMR, hadoopVer);
qt.init(null);
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in static initialization");
}
}
@@ -60,21 +59,33 @@ public class $className extends TestCase
qt.shutdown();
}
catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in 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();
#foreach ($qf in $qfiles)
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- suite.addTest(new $className("testParse_$tname"));
+ if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) {
+ suite.addTest(new $className("testParse_$tname"));
+ }
#end
suite.addTest(new $className("testParse_shutdown"));
return suite;
@@ -84,7 +95,7 @@ public class $className extends TestCase
* Dummy last test. This is only meant to shutdown qt
*/
public void testParse_shutdown() {
- System.out.println ("Cleaning up " + "$className");
+ System.err.println ("Cleaning up " + "$className");
}
static String debugHint = "\nSee build/ql/tmp/hive.log, "
@@ -96,7 +107,7 @@ public class $className extends TestCase
#set ($tname = $fname.substring(0, $eidx))
#set ($fpath = $qfilesMap.get($fname))
public void testParse_$tname() throws Exception {
- runTest("$tname", "$fname", "$fpath");
+ runTest("$tname", "$fname", HIVE_ROOT + "$fpath");
}
#end
@@ -104,7 +115,7 @@ public class $className extends TestCase
private void runTest(String tname, String fname, String fpath) throws
Exception {
long startTime = System.currentTimeMillis();
try {
- System.out.println("Begin query: " + fname);
+ System.err.println("Begin query: " + fname);
qt.addFile(fpath);
org.apache.hadoop.hive.ql.exec.Operator.resetId();
@@ -121,19 +132,19 @@ public class $className extends TestCase
fail("Semantic Analysis has unexpected output with error code = " +
ecode
+ debugHint);
}
- System.out.println("Done query: " + fname);
+ System.err.println("Done query: " + fname);
qt.getQMap().clear();
}
catch (Throwable e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.println("Failed query: " + fname);
- System.out.flush();
+ System.err.println("Failed query: " + fname);
+ System.err.flush();
fail("Unexpected exception" + debugHint);
}
long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
+ System.err.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
assertTrue("Test passed", true);
}
}
Modified: hive/trunk/ql/src/test/templates/TestParseNegative.vm
URL:
http://svn.apache.org/viewvc/hive/trunk/ql/src/test/templates/TestParseNegative.vm?rev=1528230&r1=1528229&r2=1528230&view=diff
==============================================================================
--- hive/trunk/ql/src/test/templates/TestParseNegative.vm (original)
+++ hive/trunk/ql/src/test/templates/TestParseNegative.vm Tue Oct 1 22:13:34
2013
@@ -29,19 +29,18 @@ import org.apache.hadoop.hive.ql.exec.Ta
public class $className extends TestCase {
+ private static final String HIVE_ROOT =
QTestUtil.ensurePathEndsInSlash(System.getProperty("hive.root"));
private static QTestUtil qt;
-
+
static {
try {
- boolean miniMR = false;
- if ("$clusterMode".equals("miniMR"))
- miniMR = true;
+ boolean miniMR = "$clusterMode".equals("miniMR");
String hadoopVer = "$hadoopVersion";
- qt = new QTestUtil("$resultsDir", "$logDir", miniMR, hadoopVer);
+ qt = new QTestUtil((HIVE_ROOT + "$resultsDir"), (HIVE_ROOT + "$logDir"),
miniMR, hadoopVer);
} catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in static initialization");
}
}
@@ -58,9 +57,9 @@ public class $className extends TestCase
qt.shutdown();
}
catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.flush();
+ System.err.flush();
fail("Unexpected exception in tearDown");
}
}
@@ -69,17 +68,29 @@ public class $className extends TestCase
* Dummy last test. This is only meant to shutdown qt
*/
public void testParseNegative_shutdown() {
- System.out.println ("Cleaning up " + "$className");
+ 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();
#foreach ($qf in $qfiles)
#set ($fname = $qf.getName())
#set ($eidx = $fname.indexOf('.'))
#set ($tname = $fname.substring(0, $eidx))
- suite.addTest(new $className("testParseNegative_$tname"));
+ if(qFilesToExecute.isEmpty() || qFilesToExecute.contains("$fname")) {
+ suite.addTest(new $className("testParseNegative_$tname"));
+ }
#end
suite.addTest(new $className("testParseNegative_shutdown"));
return suite;
@@ -94,7 +105,7 @@ public class $className extends TestCase
#set ($tname = $fname.substring(0, $eidx))
#set ($fpath = $qfilesMap.get($fname))
public void testParseNegative_$tname() throws Exception {
- runTest("$tname", "$fname", "$fpath");
+ runTest("$tname", "$fname", (HIVE_ROOT + "$fpath"));
}
#end
@@ -102,7 +113,7 @@ public class $className extends TestCase
private void runTest(String tname, String fname, String fpath) throws
Exception {
long startTime = System.currentTimeMillis();
try {
- System.out.println("Begin query: " + fname);
+ System.err.println("Begin query: " + fname);
qt.addFile(fpath);
@@ -124,15 +135,15 @@ public class $className extends TestCase
}
}
catch (Throwable e) {
- System.out.println("Exception: " + e.getMessage());
+ System.err.println("Exception: " + e.getMessage());
e.printStackTrace();
- System.out.println("Failed query: " + fname);
- System.out.flush();
+ System.err.println("Failed query: " + fname);
+ System.err.flush();
fail("Unexpected exception" + debugHint);
}
long elapsedTime = System.currentTimeMillis() - startTime;
- System.out.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
+ System.err.println("Done query: " + fname + " elapsedTime=" +
elapsedTime/1000 + "s");
assertTrue("Test passed", true);
}
}