4 # * Licensed to the Apache Software Foundation (ASF) under one
5 # * or more contributor license agreements. See the NOTICE file
6 # * distributed with this work for additional information
7 # * regarding copyright ownership. The ASF licenses this file
8 # * to you under the Apache License, Version 2.0 (the
9 # * "License"); you may not use this file except in compliance
10 # * with the License. You may obtain a copy of the License at
12 # * http://www.apache.org/licenses/LICENSE-2.0
14 # * Unless required by applicable law or agreed to in writing, software
15 # * distributed under the License is distributed on an "AS IS" BASIS,
16 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # * See the License for the specific language governing permissions and
18 # * limitations under the License.
24 usage: $0 [options] [test-name...]
26 Run a set of hbase tests. Individual tests may be specified on the
27 command line or in a file using -f, with one test per line. Runs all
28 tests by default. Each specified tests should include the fully
29 qualified package name.
33 -c Run 'mvn clean' before running the tests
34 -f FILE Run the additional tests listed in the FILE
35 -u Only run unit tests. Default is to run
36 unit and integration tests
37 -n N Run each test N times. Default = 1.
38 -s N Print N slowest tests
39 -H Print which tests are hanging (if any)
40 -e Echo the maven call before running. Default: not enabled
41 -r Runs remotely, on the build server. Default: not enabled
54 # normalize path refs for surefire
55 if [[ "$0" != /* ]]; then
57 scriptDir
=`pwd`/$
(dirname $0)
60 scriptDir
=$
(dirname $0)
62 testDir
=$scriptDir/..
/..
/..
/target
/surefire-reports
64 while getopts "hcerHun:s:f:" OPTION
103 # add tests specified in a file
104 if [ ! -z $testFile ]; then
107 while read <&3 line
; do
108 if [ ! -z "$line" ]; then
109 test[$testIdx]="$line"
111 testIdx
=$
(($testIdx+1))
115 # add tests specified on cmd line
116 if [ ! -z $BASH_ARGC ]; then
117 shift $
(($OPTIND - 1))
118 for (( i
= $OPTIND; i
<= $BASH_ARGC; i
++ ))
121 testIdx
=$
(($testIdx+1))
126 echo "Running tests..."
129 for (( i
= 1 ; i
<= $numIters; i
++ ))
131 if [[ $numTests > 0 ]]; then
132 #Now loop through each test
133 for (( j
= 0; j
< $numTests; j
++ ))
135 # Create the general command
136 cmd
="nice -10 mvn $doClean $testType -Dtest=${test[$j]}"
138 # Add that is should run locally, if not on the server
139 if [ ${server} -eq 0 ]; then
140 cmd
="${cmd} -P localTests"
143 # Print the command, if we should
144 if [ ${echoUsage} -eq 1 ]; then
151 if [ $?
-ne 0 ]; then
152 echo "${test[$j]} failed, iteration: $i"
157 echo "EXECUTING ALL TESTS"
158 # Create the general command
159 cmd
="nice -10 mvn $doClean $testType"
161 # Add that is should run locally, if not on the server
162 if [ ${server} -eq 0 ]; then
163 cmd
="${cmd} -P localTests"
166 # Print the command, if we should
167 if [ ${echoUsage} -eq 1 ]; then
176 # Print a report of the slowest running tests
177 if [ ! -z $showSlowest ]; then
180 for (( i
= 0; i
< ${#test[@]}; i
++ ))
182 testNames
[$i]=$testDir/'TEST-'${test[$i]}'.xml'
185 echo "Slowest $showSlowest tests:"
187 awk '/<testsuite/ { \
190 split($7,testname,"="); \
191 split($3,time,"="); \
192 print testname[2]"\t"time[2]}' \
195 |
head -n $showSlowest
198 # Print a report of tests that hung
199 if [ ! -z $showHanging ]; then
200 echo "Hanging tests:"
201 find $testDir -type f
-name *.xml
-size 0k \