Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / qa / workunits / rados / test.sh
1 #!/bin/bash -ex
2
3 parallel=1
4 [ "$1" = "--serial" ] && parallel=0
5
6 color=""
7 [ -t 1 ] && color="--gtest_color=yes"
8
9 function cleanup() {
10     pkill -P $$ || true
11 }
12 trap cleanup EXIT ERR HUP INT QUIT
13
14 declare -A pids
15
16 for f in \
17     api_aio api_io api_list api_lock api_misc \
18     api_tier api_pool api_snapshots api_stat api_watch_notify api_cmd \
19     api_service \
20     api_c_write_operations \
21     api_c_read_operations \
22     list_parallel \
23     open_pools_parallel \
24     delete_pools_parallel \
25     watch_notify
26 do
27     if [ $parallel -eq 1 ]; then
28         r=`printf '%25s' $f`
29         bash -o pipefail -exc "ceph_test_rados_$f $color 2>&1 | tee ceph_test_rados_$f.log | sed \"s/^/$r: /\"" &
30         pid=$!
31         echo "test $f on pid $pid"
32         pids[$f]=$pid
33     else
34         ceph_test_rados_$f
35     fi
36 done
37
38 ret=0
39 if [ $parallel -eq 1 ]; then
40 for t in "${!pids[@]}"
41 do
42   pid=${pids[$t]}
43   if ! wait $pid
44   then
45     echo "error in $t ($pid)"
46     ret=1
47   fi
48 done
49 fi
50
51 exit $ret