|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -e |
| 3 | + |
| 4 | +die() { |
| 5 | + printf '%s\n' "$1" >&2 |
| 6 | + exit 1 |
| 7 | +} |
| 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= |
| 15 | + |
| 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 | + ;; |
| 50 | + |
| 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)" |
| 63 | +fi |
| 64 | + |
| 65 | +if [ -z "$CONFIG" ]; then |
| 66 | + die "No config specified (-c | --config)" |
| 67 | +fi |
| 68 | + |
| 69 | +if [ "$GROUP" != "yoko" ]; then |
| 70 | + TEST_EBIN=ebin |
| 71 | +else |
| 72 | + TEST_EBIN=~/yokozuna/riak_test/ebin |
| 73 | +fi |
| 74 | + |
| 75 | +LOG=$GROUP-$(date +"%FT%H%M")-${BACKEND:-default} |
| 76 | + |
| 77 | +BASE_DIR=${RES_DIR:-$LOG} |
| 78 | + |
| 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" |
| 83 | + |
| 84 | +# copy test beams |
| 85 | +echo "Copying beams" |
| 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 |
| 88 | + |
| 89 | +# run tests independently |
| 90 | +mkdir -p $BASE_DIR/results/$GROUP |
| 91 | + |
| 92 | +echo "Running tests" |
| 93 | + |
| 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 |
| 103 | + |
| 104 | +# output results |
| 105 | +echo "making 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