Roll forward to release 1.7.1 (same as 1.7.0)
[voldemort/jeffpc.git] / bin / repeat-junit.sh
blob352abc6b4bbaf1ee425f493dc9f5203e6ca682ba
1 #!/bin/bash -e
3 # Copyright 2012 LinkedIn, Inc
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 # use this file except in compliance with the License. You may obtain a copy of
7 # the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations under
15 # the License.
17 usage() {
18 echo
19 echo "Usage:"
20 echo "bin/repeat-junit.sh num_times"
21 echo
22 cat <<EOF
23 Invoke bin/repeat-junit.sh from the root of a Voldemort
24 checkout. bin/repeat-junit.sh invokes 'ant junit' num_times.
26 The argument num_times must be an integer.
28 The pretty html junit output that ends up in dist/junit-reports on a
29 single invocation of 'ant junit' is collected in a temp
30 directory. This circumvents the normal behavior of ant in which
31 dist/junit-reports is overwritten with each invocation of 'ant
32 junit'.
34 bin/repeat-junit.sh is useful to run after making some substantial
35 changes, or when trying to track down intermittent failures (that
36 occur more on your local box then on a Hudson test machine...).
37 EOF
40 if [ $# != 1 ]; then
41 echo "ERROR: Incorrect number of arguments: $# provided, 1 needed." >&2
42 usage
43 exit 1
46 NUMTIMES=$1
47 if [[ ! $NUMTIMES == +([0-9]) ]]
48 then
49 echo "ERROR: argument num_times is not an integer: $NUMTIMES." >&2
50 usage
51 exit 1
54 TMPDIR=`mktemp -d -p '/tmp/'`
56 for ((i=1;i<=$NUMTIMES;i++)); do
57 echo
58 echo "STARTING ITERATION $i"
59 echo
61 # Run junit and capture stdout to .out and stderr to .err
62 junitiout="$TMPDIR/junit-$i.out"
63 junitierr="$TMPDIR/junit-$i.err"
64 ant junit > >(tee $junitiout) 2> >(tee $junitierr >&2)
66 # Collect results
67 junitidir="$TMPDIR/junit-reports-$i"
68 echo
69 echo "COLLECTING RESULTS OF ITERATION $i IN $junitidir"
70 cp -r dist/junit-reports $junitidir
71 mv $junitiout $junitidir
72 mv $junitierr $junitidir
73 done