You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jd...@apache.org on 2014/11/01 00:38:00 UTC
svn commit: r1635884 - in /hive/branches/branch-0.14:
common/src/test/org/apache/hadoop/hive/conf/ common/src/test/resources/
hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/
hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog...
Author: jdere
Date: Fri Oct 31 23:37:59 2014
New Revision: 1635884
URL: http://svn.apache.org/r1635884
Log:
HIVE-8665: Fix misc unit tests on Windows (Jason Dere, reviewd by Thejas Nair)
Modified:
hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java
hive/branches/branch-0.14/common/src/test/resources/hive-exec-log4j-test.properties
hive/branches/branch-0.14/common/src/test/resources/hive-log4j-test.properties
hive/branches/branch-0.14/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java
hive/branches/branch-0.14/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java
hive/branches/branch-0.14/hcatalog/webhcat/java-client/pom.xml
hive/branches/branch-0.14/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
hive/branches/branch-0.14/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java
hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
hive/branches/branch-0.14/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java
Modified: hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java (original)
+++ hive/branches/branch-0.14/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java Fri Oct 31 23:37:59 2014
@@ -18,6 +18,7 @@
package org.apache.hadoop.hive.conf;
import java.io.BufferedReader;
+import java.io.File;
import java.io.InputStreamReader;
import junit.framework.TestCase;
@@ -75,31 +76,37 @@ public class TestHiveLogging extends Tes
assertEquals(true, logCreated);
}
- private void RunTest(String cleanCmd, String findCmd, String logFile,
+ public void cleanLog(File logFile) {
+ if (logFile.exists()) {
+ logFile.delete();
+ }
+ File logFileDir = logFile.getParentFile();
+ if (logFileDir.exists()) {
+ logFileDir.delete();
+ }
+ }
+
+ private void RunTest(File logFile,
String hiveLog4jProperty, String hiveExecLog4jProperty) throws Exception {
// clean test space
- runCmd(cleanCmd);
+ cleanLog(logFile);
+ assertFalse(logFile + " should not exist", logFile.exists());
// config log4j with customized files
// check whether HiveConf initialize log4j correctly
configLog(hiveLog4jProperty, hiveExecLog4jProperty);
// check whether log file is created on test running
- runCmd(findCmd);
- getCmdOutput(logFile);
-
- // clean test space
- runCmd(cleanCmd);
+ assertTrue(logFile + " should exist", logFile.exists());
}
public void testHiveLogging() throws Exception {
- // customized log4j config log file to be: /tmp/TestHiveLogging/hiveLog4jTest.log
- String customLogPath = "/tmp/" + System.getProperty("user.name") + "-TestHiveLogging/";
+ // customized log4j config log file to be: /${test.tmp.dir}/TestHiveLogging/hiveLog4jTest.log
+ File customLogPath = new File(new File(System.getProperty("test.tmp.dir")),
+ System.getProperty("user.name") + "-TestHiveLogging/");
String customLogName = "hiveLog4jTest.log";
- String customLogFile = customLogPath + customLogName;
- String customCleanCmd = "rm -rf " + customLogFile;
- String customFindCmd = "find " + customLogPath + " -name " + customLogName;
- RunTest(customCleanCmd, customFindCmd, customLogFile,
+ File customLogFile = new File(customLogPath, customLogName);
+ RunTest(customLogFile,
"hive-log4j-test.properties", "hive-exec-log4j-test.properties");
}
}
Modified: hive/branches/branch-0.14/common/src/test/resources/hive-exec-log4j-test.properties
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/common/src/test/resources/hive-exec-log4j-test.properties?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/common/src/test/resources/hive-exec-log4j-test.properties (original)
+++ hive/branches/branch-0.14/common/src/test/resources/hive-exec-log4j-test.properties Fri Oct 31 23:37:59 2014
@@ -1,6 +1,6 @@
# Define some default values that can be overridden by system properties
hive.root.logger=INFO,FA
-hive.log.dir=/tmp/${user.name}-TestHiveLogging
+hive.log.dir=/${test.tmp.dir}/${user.name}-TestHiveLogging
hive.log.file=hiveExecLog4jTest.log
# Define the root logger to the system property "hadoop.root.logger".
Modified: hive/branches/branch-0.14/common/src/test/resources/hive-log4j-test.properties
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/common/src/test/resources/hive-log4j-test.properties?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/common/src/test/resources/hive-log4j-test.properties (original)
+++ hive/branches/branch-0.14/common/src/test/resources/hive-log4j-test.properties Fri Oct 31 23:37:59 2014
@@ -1,6 +1,6 @@
# Define some default values that can be overridden by system properties
hive.root.logger=WARN,DRFA
-hive.log.dir=/tmp/${user.name}-TestHiveLogging
+hive.log.dir=${test.tmp.dir}/${user.name}-TestHiveLogging
hive.log.file=hiveLog4jTest.log
# Define the root logger to the system property "hadoop.root.logger".
Modified: hive/branches/branch-0.14/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java (original)
+++ hive/branches/branch-0.14/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java Fri Oct 31 23:37:59 2014
@@ -64,7 +64,7 @@ public class TestUseDatabase extends Tes
String tmpDir = System.getProperty("test.tmp.dir");
File dir = new File(tmpDir + "/hive-junit-" + System.nanoTime());
- response = hcatDriver.run("alter table " + tblName + " add partition (b='2') location '" + dir.getAbsolutePath() + "'");
+ response = hcatDriver.run("alter table " + tblName + " add partition (b='2') location '" + dir.toURI().getPath() + "'");
assertEquals(0, response.getResponseCode());
assertNull(response.getErrorMessage());
Modified: hive/branches/branch-0.14/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java (original)
+++ hive/branches/branch-0.14/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java Fri Oct 31 23:37:59 2014
@@ -64,7 +64,7 @@ public class TestHCatLoaderStorer extend
TestHCatLoader.executeStatementOnDriver("create external table " + tblName +
" (my_small_int smallint, my_tiny_int tinyint)" +
" row format delimited fields terminated by '\t' stored as textfile location '" +
- dataDir + "'", driver);
+ dataDir.toURI().getPath() + "'", driver);
TestHCatLoader.dropTable(tblName2, driver);
TestHCatLoader.createTable(tblName2, "my_small_int smallint, my_tiny_int tinyint", null, driver,
"textfile");
Modified: hive/branches/branch-0.14/hcatalog/webhcat/java-client/pom.xml
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/hcatalog/webhcat/java-client/pom.xml?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/hcatalog/webhcat/java-client/pom.xml (original)
+++ hive/branches/branch-0.14/hcatalog/webhcat/java-client/pom.xml Fri Oct 31 23:37:59 2014
@@ -47,6 +47,13 @@
</dependency>
<!-- test intra-project -->
<dependency>
+ <groupId>org.apache.hive</groupId>
+ <artifactId>hive-exec</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.hive.hcatalog</groupId>
<artifactId>hive-hcatalog-core</artifactId>
<version>${project.version}</version>
Modified: hive/branches/branch-0.14/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java (original)
+++ hive/branches/branch-0.14/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java Fri Oct 31 23:37:59 2014
@@ -31,6 +31,7 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.HiveMetaStore;
import org.apache.hadoop.hive.metastore.api.PartitionEventType;
+import org.apache.hadoop.hive.ql.WindowsPathUtil;
import org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat;
import org.apache.hadoop.hive.ql.io.RCFileInputFormat;
import org.apache.hadoop.hive.ql.io.RCFileOutputFormat;
@@ -107,13 +108,17 @@ public class TestHCatClient {
@BeforeClass
public static void startMetaStoreServer() throws Exception {
+ hcatConf = new HiveConf(TestHCatClient.class);
+ if (Shell.WINDOWS) {
+ WindowsPathUtil.convertPathsFromWindowsToHdfs(hcatConf);
+ }
+
Thread t = new Thread(new RunMS(msPort));
t.start();
Thread.sleep(10000);
securityManager = System.getSecurityManager();
System.setSecurityManager(new NoExitSecurityManager());
- hcatConf = new HiveConf(TestHCatClient.class);
hcatConf.setVar(HiveConf.ConfVars.METASTOREURIS, "thrift://localhost:"
+ msPort);
hcatConf.setIntVar(HiveConf.ConfVars.METASTORETHRIFTCONNECTIONRETRIES, 3);
Modified: hive/branches/branch-0.14/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java (original)
+++ hive/branches/branch-0.14/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java Fri Oct 31 23:37:59 2014
@@ -81,7 +81,7 @@ public class TestPasswordWithCredentialP
conf.set("hadoop.security.credential.clear-text-fallback", "true");
// Set up CredentialProvider
- conf.set("hadoop.security.credential.provider.path", "jceks://file/" + tmpDir + "/test.jks");
+ conf.set("hadoop.security.credential.provider.path", "jceks://file/" + tmpDir.toURI().getPath() + "/test.jks");
// CredentialProvider/CredentialProviderFactory may not exist, depending on the version of
// hadoop-2 being used to build Hive. Use reflection to do the following lines
Modified: hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java (original)
+++ hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java Fri Oct 31 23:37:59 2014
@@ -140,7 +140,7 @@ public class TestCompactor {
executeStatementOnDriver("CREATE EXTERNAL TABLE " + tblNameStg + "(a INT, b STRING)" +
" ROW FORMAT DELIMITED FIELDS TERMINATED BY '\\t' LINES TERMINATED BY '\\n'" +
" STORED AS TEXTFILE" +
- " LOCATION '" + stagingFolder.newFolder() + "'", driver);
+ " LOCATION '" + stagingFolder.newFolder().toURI().getPath() + "'", driver);
executeStatementOnDriver("load data local inpath '" + BASIC_FILE_NAME +
"' overwrite into table " + tblNameStg, driver);
Modified: hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/branches/branch-0.14/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java Fri Oct 31 23:37:59 2014
@@ -1724,6 +1724,7 @@ public void testParseUrlHttpMode() throw
ResultSet rs = stmt.executeQuery("SELECT 1 AS a, 2 AS a from " + tableName);
assertTrue(rs.next());
assertEquals(1, rs.getInt("a"));
+ rs.close();
}
Modified: hive/branches/branch-0.14/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.14/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java?rev=1635884&r1=1635883&r2=1635884&view=diff
==============================================================================
--- hive/branches/branch-0.14/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java (original)
+++ hive/branches/branch-0.14/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java Fri Oct 31 23:37:59 2014
@@ -66,6 +66,7 @@ public class TestTypeInfoToSchema {
private TypeInfoToSchema typeInfoToSchema;
+ private final String lineSeparator = System.getProperty("line.separator");
private String getAvroSchemaString(TypeInfo columnType) {
return typeInfoToSchema.convert(
@@ -356,7 +357,7 @@ public class TestTypeInfoToSchema {
LOGGER.info("structTypeInfo is " + structTypeInfo);
final String specificSchema = IOUtils.toString(Resources.getResource("avro-struct.avsc")
- .openStream()).replace("\n", "");
+ .openStream()).replace(lineSeparator, "");
String expectedSchema = genSchema(
specificSchema);
@@ -387,7 +388,7 @@ public class TestTypeInfoToSchema {
superStructTypeInfo.setAllStructFieldTypeInfos(superTypeInfos);
final String specificSchema = IOUtils.toString(Resources.getResource("avro-nested-struct.avsc")
- .openStream()).replace("\n", "");
+ .openStream()).replace(lineSeparator, "");
String expectedSchema = genSchema(
specificSchema);
Assert.assertEquals("Test for nested struct's avro schema failed",