| #!/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 test -Dmaven.repo.local=$localDir/$instanceName/maven \ |
| $mavenArgs $mavenTestArgs $testArguments 1>$logDir/maven-test.txt 2>&1 </dev/null & |
| #[[ |
| pid=$! |
| ]]# |
| popd |
| elif [[ "${buildTool}" == "ant" ]] |
| then |
| timeout 2h ant ${antTestTarget} -Dtest.junit.output.format=xml \ |
| -Divy.default.ivy.user.dir=$localDir/$instanceName/ivy \ |
| -Divy.default.always.check.exact.revision=false \ |
| -Divy.cache.ttl.default=eternal -Divy.checkmodified=false \ |
| -Dmvn.local.repo=$localDir/$instanceName/maven \ |
| $antArgs $antTestArgs $testArguments 1>$logDir/ant-test.txt 2>&1 </dev/null & |
| #[[ |
| pid=$! |
| ]]# |
| else |
| echo "Unknown build tool ${buildTool}" |
| exit 127 |
| fi |
| echo $pid >> batch.pid |
| wait $pid |
| ret=$? |
| find ./ -type f -name hive.log -o -name spark.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 |