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:35:09 UTC

svn commit: r1635883 - in /hive/trunk: 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/pig/ hcatalog/...

Author: jdere
Date: Fri Oct 31 23:35:09 2014
New Revision: 1635883

URL: http://svn.apache.org/r1635883
Log:
HIVE-8665: Fix misc unit tests on Windows (Jason Dere, reviewed by Thejas Nair)

Modified:
    hive/trunk/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java
    hive/trunk/common/src/test/resources/hive-exec-log4j-test.properties
    hive/trunk/common/src/test/resources/hive-log4j-test.properties
    hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java
    hive/trunk/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java
    hive/trunk/hcatalog/webhcat/java-client/pom.xml
    hive/trunk/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
    hive/trunk/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java
    hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
    hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
    hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java

Modified: hive/trunk/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java (original)
+++ hive/trunk/common/src/test/org/apache/hadoop/hive/conf/TestHiveLogging.java Fri Oct 31 23:35:09 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/trunk/common/src/test/resources/hive-exec-log4j-test.properties
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/test/resources/hive-exec-log4j-test.properties?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/common/src/test/resources/hive-exec-log4j-test.properties (original)
+++ hive/trunk/common/src/test/resources/hive-exec-log4j-test.properties Fri Oct 31 23:35:09 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/trunk/common/src/test/resources/hive-log4j-test.properties
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/test/resources/hive-log4j-test.properties?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/common/src/test/resources/hive-log4j-test.properties (original)
+++ hive/trunk/common/src/test/resources/hive-log4j-test.properties Fri Oct 31 23:35:09 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/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java (original)
+++ hive/trunk/hcatalog/core/src/test/java/org/apache/hive/hcatalog/cli/TestUseDatabase.java Fri Oct 31 23:35:09 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/trunk/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java (original)
+++ hive/trunk/hcatalog/hcatalog-pig-adapter/src/test/java/org/apache/hive/hcatalog/pig/TestHCatLoaderStorer.java Fri Oct 31 23:35:09 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/trunk/hcatalog/webhcat/java-client/pom.xml
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/java-client/pom.xml?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/hcatalog/webhcat/java-client/pom.xml (original)
+++ hive/trunk/hcatalog/webhcat/java-client/pom.xml Fri Oct 31 23:35:09 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/trunk/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java (original)
+++ hive/trunk/hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/TestHCatClient.java Fri Oct 31 23:35:09 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/trunk/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java (original)
+++ hive/trunk/itests/hive-unit-hadoop2/src/test/java/org/apache/hadoop/hive/ql/security/TestPasswordWithCredentialProvider.java Fri Oct 31 23:35:09 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/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/txn/compactor/TestCompactor.java Fri Oct 31 23:35:09 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/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcDriver2.java Fri Oct 31 23:35:09 2014
@@ -1805,6 +1805,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/trunk/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java
URL: http://svn.apache.org/viewvc/hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java?rev=1635883&r1=1635882&r2=1635883&view=diff
==============================================================================
--- hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java (original)
+++ hive/trunk/serde/src/test/org/apache/hadoop/hive/serde2/avro/TestTypeInfoToSchema.java Fri Oct 31 23:35:09 2014
@@ -80,6 +80,7 @@ public class TestTypeInfoToSchema {
 
   private TypeInfoToSchema typeInfoToSchema;
 
+  private final String lineSeparator = System.getProperty("line.separator");
 
   private String getAvroSchemaString(TypeInfo columnType) {
     return typeInfoToSchema.convert(
@@ -383,7 +384,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);
 
@@ -414,7 +415,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",