You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by da...@apache.org on 2013/07/17 01:03:19 UTC

svn commit: r1503940 - in /hive/trunk: ./ hcatalog/ hcatalog/bin/ hcatalog/build-support/ant/ hcatalog/webhcat/svr/src/main/bin/ hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/

Author: daijy
Date: Tue Jul 16 23:03:19 2013
New Revision: 1503940

URL: http://svn.apache.org/r1503940
Log:
HIVE-4820 : webhcat_config.sh should set default values for HIVE_HOME and HCAT_PREFIX that work with default build tree structure (Eugene Koifman via Jianyong Dai)

Modified:
    hive/trunk/RELEASE_NOTES.txt
    hive/trunk/hcatalog/bin/hcat
    hive/trunk/hcatalog/build-support/ant/deploy.xml
    hive/trunk/hcatalog/build-support/ant/test.xml
    hive/trunk/hcatalog/build.xml
    hive/trunk/hcatalog/webhcat/svr/src/main/bin/webhcat_config.sh
    hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java

Modified: hive/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/hive/trunk/RELEASE_NOTES.txt?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/RELEASE_NOTES.txt (original)
+++ hive/trunk/RELEASE_NOTES.txt Tue Jul 16 23:03:19 2013
@@ -15,6 +15,7 @@ Release Notes - Hive - Version 0.11.0
     * [HIVE-4326] - Clean up remaining items in hive/hcatalog/historical/trunk
 
 ** Bug
+    * [HIVE-4820] - webhcat_config.sh should set default values for HIVE_HOME and HCAT_PREFIX that work with default build tree structure
     * [HIVE-2264] - Hive server is SHUTTING DOWN when invalid queries beeing executed.
     * [HIVE-2332] - If all of the parameters of distinct functions are exists in group by columns, query fails in runtime
     * [HIVE-2689] - ObjectInspectorConverters cannot convert Void types to Array/Map/Struct types.

Modified: hive/trunk/hcatalog/bin/hcat
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/bin/hcat?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/hcatalog/bin/hcat (original)
+++ hive/trunk/hcatalog/bin/hcat Tue Jul 16 23:03:19 2013
@@ -34,8 +34,14 @@ done                                    
 bin=`dirname "$this"`                                                            
 script=`basename "$this"`                                                        
 bin=`unset CDPATH; cd "$bin"; pwd`                                               
-this="$bin/$script"                                                              
-
+this="$bin/$script"
+#to preserve value of 'this' since any other file that defines 'this' and is sourced
+#here (e.g. hcat-config.sh) will overwrite it
+this_hcat=$this
+
+function echoerr() {
+    echo "${this_hcat}: $@" 1>&2
+}
 
 if [ -e "$bin/../libexec/hcat-config.sh" ]; then
   . "$bin"/../libexec/hcat-config.sh
@@ -60,7 +66,8 @@ done
 
 # check for hive in the path
 HIVE_IN_PATH=`which hive 2>/dev/null`
-if [ -f ${HIVE_IN_PATH} ]; then
+# looks like [ -f '' ] is true...
+if [ -n ${HIVE_IN_PATH} ]; then
   #dir of hive scrip
   HIVE_DIR=`dirname "$HIVE_IN_PATH"`
   #one level up for base dir
@@ -70,8 +77,14 @@ fi
 # HIVE_HOME env variable overrides hive in the path
 HIVE_HOME=${HIVE_HOME:-$HIVE_DIR}
 
+#if hive is not in path and not set by env, set it to default in build tree
+if [ -n ${HIVE_HOME} ]; then
+  HIVE_HOME="${bin}/../.."
+  echoerr "HIVE_HOME is not defined; assuming ${HIVE_HOME}";
+fi
+
 if [ "$HIVE_HOME" == "" ]; then
-  echo "Cannot find hive installation: \$HIVE_HOME must be set or hive must be in the path";
+  echo "${this_hcat}: Cannot find hive installation: \$HIVE_HOME must be set or hive must be in the path";
   exit 4;
 fi
 
@@ -87,13 +100,13 @@ fi
 
 HIVE_LIB_DIR=${HIVE_HOME}/lib
 if [ ! -d "$HIVE_LIB_DIR" ]; then
-  echo "Cannot find lib dir within HIVE_HOME : $HIVE_LIB_DIR";
+  echo "${this_hcat}: Cannot find lib dir within HIVE_HOME : $HIVE_LIB_DIR";
   exit 4;
 fi
 
 HIVE_CONF_DIR=${HIVE_CONF_DIR:-$HIVE_HOME/conf}
 if [ ! -d "$HIVE_CONF_DIR" ]; then
-  echo "Cannot find conf dir within HIVE_HOME : $HIVE_CONF_DIR";
+  echo "${this_hcat}: Cannot find conf dir within HIVE_HOME : $HIVE_CONF_DIR";
   exit 4;
 fi
 

Modified: hive/trunk/hcatalog/build-support/ant/deploy.xml
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/build-support/ant/deploy.xml?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/hcatalog/build-support/ant/deploy.xml (original)
+++ hive/trunk/hcatalog/build-support/ant/deploy.xml Tue Jul 16 23:03:19 2013
@@ -69,7 +69,7 @@
       <_mvnpublish module="testutils" />
     </target>
 
-    <target name="mvn-init" unless="mvn-init.complete">
+    <target name="mvn-init" unless="mvn-init.complete" description="Get Maven Ant Tasts jar and deploy all Hive jars to local Maven repo">
         <echo message="${ant.project.name}"/>
         <get src="${mvnrepo}/org/apache/maven/maven-ant-tasks/${maven-ant-tasks.version}/maven-ant-tasks-${maven-ant-tasks.version}.jar"
              dest="${path.to.basedir}/build/maven-ant-tasks-${maven-ant-tasks.version}.jar"

Modified: hive/trunk/hcatalog/build-support/ant/test.xml
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/build-support/ant/test.xml?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/hcatalog/build-support/ant/test.xml (original)
+++ hive/trunk/hcatalog/build-support/ant/test.xml Tue Jul 16 23:03:19 2013
@@ -47,6 +47,9 @@
         <sysproperty key="hive.metastore.warehouse.dir" value="${test.warehouse.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-->
+        <env key="HCAT_PREFIX" value="${env.HCAT_PREFIX}"/>
+        <env key="HIVE_HOME" value="${env.HIVE_HOME}"/>
         <classpath>
           <path refid="test.class.path"/>
           <pathelement location="${clover.jar}"/>

Modified: hive/trunk/hcatalog/build.xml
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/build.xml?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/hcatalog/build.xml (original)
+++ hive/trunk/hcatalog/build.xml Tue Jul 16 23:03:19 2013
@@ -28,6 +28,8 @@
     <property name="path.to.basedir" location="${basedir}"/>
     <property name="test.result.dir" location="${build.dir.hive}/hcatalog/test"
               description="location to place TEST-*.xml files so that hive's testreport includes them"/>
+    <property name="hive.dist.dir" location="${build.dir.hive}/dist"
+            description="where all hive build artifacts are placed to make binary tar ball"/>
     <loadproperties srcfile="${basedir}/build.properties"/>
 
     <!--
@@ -108,6 +110,8 @@
             </ant>
             <ant target="test" 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">
                 <property name="test.result.dir" location="${test.result.dir}"/>

Modified: hive/trunk/hcatalog/webhcat/svr/src/main/bin/webhcat_config.sh
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/svr/src/main/bin/webhcat_config.sh?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/hcatalog/webhcat/svr/src/main/bin/webhcat_config.sh (original)
+++ hive/trunk/hcatalog/webhcat/svr/src/main/bin/webhcat_config.sh Tue Jul 16 23:03:19 2013
@@ -18,6 +18,12 @@
 # under the License.
 
 
+# Print an error message and exit
+function die() {
+        echo "${this}: $@" 1>&2
+        exit 1
+}
+
 #====================================
 #Default config param values
 #====================================
@@ -71,6 +77,23 @@ else
 fi
 WEBHCAT_CONF_DIR="${WEBHCAT_CONF_DIR:-$DEFAULT_CONF_DIR}"
 
+#set defaults for HCAT_PREFIX, HIVE_HOME, TEMPLETON_HOME that work for default directory structure
+DEFAULT_HCAT_PREFIX="${WEBHCAT_PREFIX}"
+export HCAT_PREFIX="${HCAT_PREFIX:-$DEFAULT_HCAT_PREFIX}"
+if [ ! -f ${HCAT_PREFIX}/bin/hcat ]; then
+    die "HCAT_PREFIX=${HCAT_PREFIX} is invalid";
+fi
+DEFAULT_HIVE_HOME="${WEBHCAT_PREFIX}/.."
+export HIVE_HOME="${HIVE_HOME:-$DEFAULT_HIVE_HOME}"
+if [ ! -f ${HIVE_HOME}/bin/hive ]; then
+    die "HIVE_HOME=${HIVE_HOME} is invalid";
+fi
+DEFAULT_TEMPLETON_HOME="${WEBHCAT_PREFIX}"
+export TEMPLETON_HOME="${TEMPLETON_HOME:-$DEFAULT_TEMPLETON_HOME}"
+if [ ! -d ${TEMPLETON_HOME}/share/webhcat ]; then
+    die "TEMPLETON_HOME=${TEMPLETON_HOME} is invalid";
+fi
+
 #users can add various env vars to webhcat-env.sh in the conf
 #rather than having to export them before running the command
 if [ -f "${WEBHCAT_CONF_DIR}/webhcat-env.sh" ]; then
@@ -89,6 +112,6 @@ elif [ -f ${WEBHCAT_PREFIX}/bin/hadoop ]
   HADOOP_PREFIX=$WEBHCAT_PREFIX
 #otherwise see if HADOOP_PREFIX is defined
 elif [ ! -f ${HADOOP_PREFIX}/bin/hadoop ]; then
-  echo "Hadoop not found."
+  echo "${this}: Hadoop not found."
   exit 1
 fi

Modified: hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java
URL: http://svn.apache.org/viewvc/hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java?rev=1503940&r1=1503939&r2=1503940&view=diff
==============================================================================
--- hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java (original)
+++ hive/trunk/hcatalog/webhcat/svr/src/test/java/org/apache/hcatalog/templeton/TestWebHCatE2e.java Tue Jul 16 23:03:19 2013
@@ -28,6 +28,7 @@ import org.apache.commons.httpclient.met
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.hadoop.hive.ql.ErrorMsg;
 import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -62,8 +63,7 @@ public class TestWebHCatE2e {
     private static final String ERROR_CODE = "errorCode";
     private static Main templetonServer;
     private static final String charSet = "UTF-8";
-    //  "not ready due to HIVE-4820"
-    //@BeforeClass
+    @BeforeClass
     public static void startHebHcatInMem() {
         templetonServer = new Main(new String[] {"-D" + AppConfig.UNIT_TEST_MODE + "=true"});
         LOG.info("Starting Main");
@@ -78,7 +78,6 @@ public class TestWebHCatE2e {
             LOG.info("Main stopped");
         }
     }
-    @Ignore("not ready due to HIVE-4820")
     @Test
     public void getStatus() throws IOException {
         LOG.debug("+getStatus()");
@@ -100,7 +99,6 @@ public class TestWebHCatE2e {
      * Check that we return correct status code when the URL doesn't map to any method
      * in {@link Server}
      */
-    @Ignore("not ready due to HIVE-4820")
     @Test
     public void invalidPath() throws IOException {
         MethodCallRetVal p = doHttpCall(templetonBaseUrl + "/no_such_mapping/database", HTTP_METHOD_TYPE.GET);