Whamcloud - gitweb
LU-7323 test: Unknown symbol mb_cache_create (err 0)" on RHEL7
[fs/lustre-release.git] / lustre / tests / racer / racer.sh
1 #!/bin/bash
2 #set -x
3
4 MAX_FILES=${MAX_FILES:-20}
5 DIR=${DIR:-$1}
6 DIR=${DIR:-"/mnt/lustre/racer"}
7 DURATION=${DURATION:-$((60*5))}
8 MDSCOUNT=${MDSCOUNT:-1}
9
10 NUM_THREADS=${NUM_THREADS:-$2}
11 NUM_THREADS=${NUM_THREADS:-3}
12
13 mkdir -p $DIR
14
15 RACER_PROGS="file_create dir_create file_rm file_rename file_link file_symlink \
16 file_list file_concat file_exec file_chown file_chmod file_mknod file_truncate \
17 file_delxattr file_getxattr file_setxattr"
18
19 if [ $MDSCOUNT -gt 1 ]; then
20         RACER_PROGS="${RACER_PROGS} dir_remote dir_migrate"
21 fi
22
23 racer_cleanup()
24 {
25         echo "racer cleanup"
26         for P in $RACER_PROGS; do
27                 killall -q $P.sh
28         done
29         trap 0
30
31         local TOT_WAIT=0
32         local MAX_WAIT=$DURATION
33         local SHORT_WAIT=5
34
35         local rc
36         while [[ $TOT_WAIT -le $MAX_WAIT ]]; do
37                 rc=0
38                 echo sleeping $SHORT_WAIT sec ...
39                 sleep $SHORT_WAIT
40                 # this only checks whether processes exist
41                 for P in $RACER_PROGS; do
42                         killall -0 $P.sh
43                         [[ $? -eq 0 ]] && (( rc+=1 ))
44                 done
45                 if [[ $rc -eq 0 ]]; then
46                         echo there should be NO racer processes:
47                         ps uww -C "${RACER_PROGS// /,}"
48                         return 0
49                 fi
50                 echo -n "Waited $(( TOT_WAIT + SHORT_WAIT)), rc=$rc "
51                 (( SHORT_WAIT+=SHORT_WAIT ))
52                 (( TOT_WAIT+=SHORT_WAIT ))
53         done
54         ps uww -C "${RACER_PROGS// /,}"
55         return 1
56 }
57
58 RC=0
59
60 echo "Running $0 for $DURATION seconds. CTRL-C to exit"
61 trap "
62         echo \"Cleaning up\" 
63         racer_cleanup
64         exit 0
65 " INT TERM
66
67 cd `dirname $0`
68 for N in `seq 1 $NUM_THREADS`; do
69         for P in $RACER_PROGS; do
70                 ./$P.sh $DIR $MAX_FILES &
71         done
72 done
73
74 sleep $DURATION
75 racer_cleanup || RC=$?
76
77 # Check our to see whether our test DIR is still available.
78 df $DIR
79 (( RC+=$? ))
80 [ $RC -eq 0 ] && echo "We survived $0 for $DURATION seconds."
81 exit $RC