You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2013/09/04 08:10:22 UTC
svn commit: r1519915 - in /hive/trunk/hcatalog: build-support/ant/test.xml
build.properties
webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java
Author: thejas
Date: Wed Sep 4 06:10:22 2013
New Revision: 1519915
URL: http://svn.apache.org/r1519915
Log:
HIVE-4748 - Fix TempletonUtilsTest failure on Windows (Shuaishuai Nie via Thejas Nair)
Modified:
hive/trunk/hcatalog/build-support/ant/test.xml
hive/trunk/hcatalog/build.properties
hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java
Modified: hive/trunk/hcatalog/build-support/ant/test.xml
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/build-support/ant/test.xml?rev=1519915&r1=1519914&r2=1519915&view=diff
==============================================================================
--- hive/trunk/hcatalog/build-support/ant/test.xml (original)
+++ hive/trunk/hcatalog/build-support/ant/test.xml Wed Sep 4 06:10:22 2013
@@ -31,8 +31,10 @@
<delete dir="${test.logs}"/>
<delete dir="${test.warehouse.dir}"/>
+ <delete dir="${test.data.dir}"/>
<mkdir dir="${test.logs}"/>
<mkdir dir="${test.warehouse.dir}"/>
+ <mkdir dir="${test.data.dir}"/>
<junit showoutput="${test.output}"
printsummary="yes"
@@ -45,6 +47,7 @@
failureProperty="tests.failed">
<sysproperty key="hadoop.log.dir" value="${test.logs}"/>
<sysproperty key="hive.metastore.warehouse.dir" value="${test.warehouse.dir}"/>
+ <sysproperty key="test.data.dir" value="${test.data.dir}"/>
<sysproperty key="java.security.krb5.realm" value=""/> <!-- HADOOP-7489 -->
<sysproperty key="java.security.krb5.kdc" value=""/> <!-- HADOOP-7489 -->
<!--HCAT_PREFIX, HIVE_HOME are needed by WebHCat tests-->
Modified: hive/trunk/hcatalog/build.properties
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/build.properties?rev=1519915&r1=1519914&r2=1519915&view=diff
==============================================================================
--- hive/trunk/hcatalog/build.properties (original)
+++ hive/trunk/hcatalog/build.properties Wed Sep 4 06:10:22 2013
@@ -32,6 +32,7 @@ build.docs=${build.dir}/docs
build.javadoc=${build.docs}/api
dist.dir=${build.dir}/${final.name}
+test.data.dir=${build.dir}/data
test.dir=${build.dir}/test
test.classes=${test.dir}/classes
test.logs=${test.dir}/logs
Modified: hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java?rev=1519915&r1=1519914&r2=1519915&view=diff
==============================================================================
--- hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java (original)
+++ hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/tool/TestTempletonUtils.java Wed Sep 4 06:10:22 2013
@@ -18,12 +18,15 @@
*/
package org.apache.hcatalog.templeton.tool;
-import org.junit.Assert;
-
+import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.StringUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
public class TestTempletonUtils {
@@ -31,6 +34,27 @@ public class TestTempletonUtils {
"2011-12-15 18:12:21,758 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher - More information at: http://localhost:50030/jobdetails.jsp?jobid=job_201112140012_0047",
"2011-12-15 18:12:46,907 [main] INFO org.apache.pig.tools.pigstats.SimplePigStats - Script Statistics: "
};
+ public static final String testDataDir = System.getProperty("test.data.dir");
+ File tmpFile;
+ File usrFile;
+
+ @Before
+ public void setup() {
+ try {
+ tmpFile = new File(testDataDir, "tmp");
+ tmpFile.createNewFile();
+ usrFile = new File(testDataDir, "usr");
+ usrFile.createNewFile();
+ } catch (IOException ex) {
+ Assert.fail(ex.getMessage());
+ }
+ }
+
+ @After
+ public void tearDown() {
+ tmpFile.delete();
+ usrFile.delete();
+ }
@Test
public void testIssetString() {
@@ -57,8 +81,9 @@ public class TestTempletonUtils {
@Test
public void testExtractPercentComplete() {
Assert.assertNull(TempletonUtils.extractPercentComplete("fred"));
- for (String line : CONTROLLER_LINES)
+ for (String line : CONTROLLER_LINES) {
Assert.assertNull(TempletonUtils.extractPercentComplete(line));
+ }
String fifty = "2011-12-15 18:12:36,333 [main] INFO org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher - 50% complete";
Assert.assertEquals("50% complete", TempletonUtils.extractPercentComplete(fifty));
@@ -100,10 +125,10 @@ public class TestTempletonUtils {
public void testHadoopFsPath() {
try {
TempletonUtils.hadoopFsPath(null, null, null);
- TempletonUtils.hadoopFsPath("/tmp", null, null);
- TempletonUtils.hadoopFsPath("/tmp", new Configuration(), null);
+ TempletonUtils.hadoopFsPath(tmpFile.toURI().toString(), null, null);
+ TempletonUtils.hadoopFsPath(tmpFile.toURI().toString(), new Configuration(), null);
} catch (FileNotFoundException e) {
- Assert.fail("Couldn't find /tmp");
+ Assert.fail("Couldn't find " + tmpFile.toURI().toString());
} catch (Exception e) {
// This is our problem -- it means the configuration was wrong.
e.printStackTrace();
@@ -134,13 +159,15 @@ public class TestTempletonUtils {
public void testHadoopFsFilename() {
try {
Assert.assertEquals(null, TempletonUtils.hadoopFsFilename(null, null, null));
- Assert.assertEquals(null, TempletonUtils.hadoopFsFilename("/tmp", null, null));
- Assert.assertEquals("file:/tmp",
- TempletonUtils.hadoopFsFilename("/tmp",
- new Configuration(),
- null));
+ Assert.assertEquals(null,
+ TempletonUtils.hadoopFsFilename(tmpFile.toURI().toString(), null, null));
+ Assert.assertEquals(tmpFile.toURI().toString(),
+ TempletonUtils.hadoopFsFilename(tmpFile.toURI().toString(),
+ new Configuration(),
+ null));
} catch (FileNotFoundException e) {
Assert.fail("Couldn't find name for /tmp");
+ Assert.fail("Couldn't find name for " + tmpFile.toURI().toString());
} catch (Exception e) {
// Something else is wrong
e.printStackTrace();
@@ -161,15 +188,15 @@ public class TestTempletonUtils {
public void testHadoopFsListAsArray() {
try {
Assert.assertTrue(TempletonUtils.hadoopFsListAsArray(null, null, null) == null);
- Assert.assertTrue(TempletonUtils.hadoopFsListAsArray("/tmp, /usr",
- null, null) == null);
- String[] tmp2
- = TempletonUtils.hadoopFsListAsArray("/tmp,/usr",
- new Configuration(), null);
- Assert.assertEquals("file:/tmp", tmp2[0]);
- Assert.assertEquals("file:/usr", tmp2[1]);
+ Assert.assertTrue(TempletonUtils.hadoopFsListAsArray(
+ tmpFile.toURI().toString() + "," + usrFile.toString(), null, null) == null);
+ String[] tmp2 = TempletonUtils.hadoopFsListAsArray(
+ tmpFile.toURI().toString() + "," + usrFile.toURI().toString(),
+ new Configuration(), null);
+ Assert.assertEquals(tmpFile.toURI().toString(), tmp2[0]);
+ Assert.assertEquals(usrFile.toURI().toString(), tmp2[1]);
} catch (FileNotFoundException e) {
- Assert.fail("Couldn't find name for /tmp");
+ Assert.fail("Couldn't find name for " + tmpFile.toURI().toString());
} catch (Exception e) {
// Something else is wrong
e.printStackTrace();
@@ -191,12 +218,16 @@ public class TestTempletonUtils {
public void testHadoopFsListAsString() {
try {
Assert.assertTrue(TempletonUtils.hadoopFsListAsString(null, null, null) == null);
- Assert.assertTrue(TempletonUtils.hadoopFsListAsString("/tmp,/usr",
- null, null) == null);
- Assert.assertEquals("file:/tmp,file:/usr", TempletonUtils.hadoopFsListAsString
- ("/tmp,/usr", new Configuration(), null));
+ Assert.assertTrue(TempletonUtils.hadoopFsListAsString(
+ tmpFile.toURI().toString() + "," + usrFile.toURI().toString(),
+ null, null) == null);
+ Assert.assertEquals(
+ tmpFile.toURI().toString() + "," + usrFile.toURI().toString(),
+ TempletonUtils.hadoopFsListAsString(
+ tmpFile.toURI().toString() + "," + usrFile.toURI().toString(),
+ new Configuration(), null));
} catch (FileNotFoundException e) {
- Assert.fail("Couldn't find name for /tmp");
+ Assert.fail("Couldn't find name for " + tmpFile.toURI().toString());
} catch (Exception e) {
// Something else is wrong
e.printStackTrace();