#!/bin/bash # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ##### Remember, this is a velocity template set -x umask 0022 echo $$ ps -e -o pid,pgrp,user,args ps x -o "%p %r %y %x %c " chmod -R u+w $logDir rm -rf $logDir # makes $logDir and $logDir/tmp mkdir -p $logDir/tmp if [[ -n "${javaHomeForTests}" ]] then export JAVA_HOME=$javaHomeForTests export PATH=$JAVA_HOME/bin/:$PATH elif [[ -n "${javaHome}" ]] then export JAVA_HOME=$javaHome export PATH=$JAVA_HOME/bin/:$PATH fi export ANT_OPTS="-Xmx1g -XX:MaxPermSize=256m -Djava.io.tmpdir=$logDir/tmp ${antEnvOpts}" export M2_OPTS="-Xmx1g -XX:MaxPermSize=256m -Djava.io.tmpdir=$logDir/tmp ${mavenEnvOpts}" export HADOOP_ROOT_LOGGER=INFO,console export HADOOP_OPTS="-Dhive.log.dir=$logDir -Dhive.query.id=hadoop -Djava.io.tmpdir=$logDir/tmp" cd $localDir/$instanceName/${repositoryName}-source || exit 1 if [[ -s batch.pid ]] then while read pid do if kill -9 -$pid 2>/dev/null then echo "Killed process group $pid" sleep 1 fi done < batch.pid fi echo "$$" > batch.pid find ./ -name 'TEST-*.xml' -delete find ./ -name 'hive.log' -delete find ./ -name junit_metastore_db | xargs -r rm -rf ret=0 if [[ "${buildTool}" == "maven" ]] then testModule=$(find ./ -name '${testClass}.java' | awk -F'/' '{print $2}') if [[ -z "$testModule" ]] then testModule=./ fi pushd $testModule timeout 2h mvn -B -o test -Dmaven.repo.local=$localDir/$instanceName/maven \ $mavenArgs $mavenTestArgs $testArguments 1>$logDir/maven-test.txt 2>&1 $logDir/ant-test.txt 2>&1 > batch.pid wait $pid ret=$? if [[ $ret -ne 0 ]] then if [[ $numOfFailedTests -lt $maxSourceDirs ]] then cp -R $localDir/$instanceName/${repositoryName}-source $logDir/source else echo "Number of failed tests $numOfFailedTests exceeded threshold, not copying source" fi fi find ./ -type f -name hive.log | \ xargs -I {} sh -c 'f=$(basename {}); test -f ${logDir}/$f && f=$f-$(uuidgen); mv {} ${logDir}/$f' find ./ -type f -name 'TEST-*.xml' | \ xargs -I {} sh -c 'f=TEST-${batchName}-$(basename {}); test -f ${logDir}/$f && f=$f-$(uuidgen); mv {} ${logDir}/$f' if [[ -f $logDir/.log ]] then mv $logDir/.log $logDir/dot.log fi exit $ret