|
1 | 1 | #!/usr/bin/env bash |
2 | 2 | set -e |
3 | 3 |
|
4 | | -# $1 is group $2 is backend and $3 is config $4 is results directory |
| 4 | +die() { |
| 5 | + printf '%s\n' "$1" >&2 |
| 6 | + exit 1 |
| 7 | +} |
5 | 8 |
|
| 9 | +# Initialize all the option variables. |
| 10 | +# This ensures we are not contaminated by variables from the environment. |
| 11 | +GROUP= |
| 12 | +CONFIG= |
| 13 | +RES_DIR= |
| 14 | +BACKEND= |
6 | 15 |
|
7 | | -echo "Running $1 with $2 and config $CONFIG" |
| 16 | +while :; do |
| 17 | + case $1 in |
| 18 | + -g|--group) |
| 19 | + if [ "$2" ]; then |
| 20 | + GROUP=$2 |
| 21 | + shift |
| 22 | + else |
| 23 | + die 'ERROR: "--group | -g" requires value (e.g. kv)' |
| 24 | + fi |
| 25 | + ;; |
| 26 | + -c|--config) |
| 27 | + if [ "$2" ]; then |
| 28 | + CONFIG=$2 |
| 29 | + shift |
| 30 | + else |
| 31 | + die 'ERROR: "--config | -c" required (e.g. "spine")' |
| 32 | + fi |
| 33 | + ;; |
| 34 | + -r|--res_dir) |
| 35 | + if [ "$2" ]; then |
| 36 | + RES_DIR=$2 |
| 37 | + shift |
| 38 | + else |
| 39 | + die 'ERROR: "--res_dir | -r" value required if flag present' |
| 40 | + fi |
| 41 | + ;; |
| 42 | + -b|--backend) |
| 43 | + if [ "$2" ]; then |
| 44 | + BACKEND=$2 |
| 45 | + shift |
| 46 | + else |
| 47 | + die 'ERROR: "--backend | -b" value required if flag present' |
| 48 | + fi |
| 49 | + ;; |
8 | 50 |
|
9 | | -if [ "$1" != "yoko" ]; then |
10 | | - TEST_EBIN=ebin |
11 | | -else |
12 | | - TEST_EBIN=~/yokozuna/riak_test/ebin |
| 51 | + -?*) |
| 52 | + printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2 |
| 53 | + ;; |
| 54 | + *) |
| 55 | + break |
| 56 | + esac |
| 57 | + |
| 58 | + shift |
| 59 | +done |
| 60 | + |
| 61 | +if [ -z "$GROUP" ]; then |
| 62 | + die "No group specified (-g | --group)" |
13 | 63 | fi |
14 | 64 |
|
15 | | -if [ "$1" != "2i" ]; then |
16 | | - BACKEND=${2:-bitcask} |
| 65 | +if [ -z "$CONFIG" ]; then |
| 66 | + die "No config specified (-c | --config)" |
| 67 | +fi |
| 68 | + |
| 69 | +if [ "$GROUP" != "yoko" ]; then |
| 70 | + TEST_EBIN=ebin |
17 | 71 | else |
18 | | - BACKEND=eleveldb |
| 72 | + TEST_EBIN=~/yokozuna/riak_test/ebin |
19 | 73 | fi |
20 | 74 |
|
21 | | -LOG=$1-$(date +"%FT%H%M")-$BACKEND |
| 75 | +LOG=$GROUP-$(date +"%FT%H%M")-${BACKEND:-default} |
22 | 76 |
|
23 | | -CONFIG=${3:-rtdev} |
24 | | -BASE_DIR=${4:-$LOG} |
| 77 | +BASE_DIR=${RES_DIR:-$LOG} |
25 | 78 |
|
26 | | -echo "Backend is $BACKEND" |
| 79 | +echo "Running $GROUP with config $CONFIG" |
| 80 | +echo "Backend is ${BACKEND:-unspecified/default}" |
| 81 | +echo "Res dir is $BASE_DIR" |
| 82 | +echo "Test ebin $TEST_EBIN" |
27 | 83 |
|
28 | 84 | # copy test beams |
29 | 85 | echo "Copying beams" |
30 | | -mkdir -p $BASE_DIR/group_tests/$1 |
31 | | -while read t; do cp $TEST_EBIN/$t.beam $BASE_DIR/group_tests/$1;done <groups/$1 |
| 86 | +mkdir -p $BASE_DIR/group_tests/$GROUP |
| 87 | +while read t; do cp $TEST_EBIN/$t.beam $BASE_DIR/group_tests/$GROUP;done <groups/$GROUP |
32 | 88 |
|
33 | 89 | # run tests independently |
34 | | -mkdir -p $BASE_DIR/results/$1 |
| 90 | +mkdir -p $BASE_DIR/results/$GROUP |
| 91 | + |
35 | 92 | echo "Running tests" |
36 | 93 |
|
37 | | -for t in $BASE_DIR/group_tests/$1/*; do ./riak_test --batch -c $CONFIG -b $BACKEND -t $t; done | tee $BASE_DIR/results/$1/log |
| 94 | +if [ -z "$BACKEND"]; then |
| 95 | + BECMD= |
| 96 | +else |
| 97 | + BECMD="-b $BACKEND" |
| 98 | +fi |
| 99 | + |
| 100 | +echo "backend cmd $BECMD" |
| 101 | + |
| 102 | +for t in $BASE_DIR/group_tests/$GROUP/*; do ./riak_test --batch -c $CONFIG $BECMD -t $t; done | tee $BASE_DIR/results/$GROUP/log |
38 | 103 |
|
39 | 104 | # output results |
40 | 105 | echo "making summary" |
41 | | -while read t; do grep $t-$BACKEND $BASE_DIR/results/$1/log ;done <groups/$1 | tee $BASE_DIR/results/$1/summary |
| 106 | +while read t; do grep $t- $BASE_DIR/results/$GROUP/log ;done <groups/$GROUP | tee $BASE_DIR/results/$GROUP/summary |
0 commit comments