Whamcloud - gitweb
LU-8739 test: disable DNE in racer for old MDSs
[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 $RACER_ENABLE_REMOTE_DIRS || $RACER_ENABLE_STRIPED_DIRS; then
20         RACER_PROGS+=' dir_remote'
21 fi
22
23 if $RACER_ENABLE_MIGRATION; then
24         RACER_PROGS+=' dir_migrate'
25 fi
26
27 racer_cleanup()
28 {
29         echo "racer cleanup"
30         for P in $RACER_PROGS; do
31                 killall -q $P.sh
32         done
33         trap 0
34
35         local TOT_WAIT=0
36         local MAX_WAIT=$DURATION
37         local SHORT_WAIT=5
38
39         local rc
40         while [[ $TOT_WAIT -le $MAX_WAIT ]]; do
41                 rc=0
42                 echo sleeping $SHORT_WAIT sec ...
43                 sleep $SHORT_WAIT
44                 # this only checks whether processes exist
45                 for P in $RACER_PROGS; do
46                         killall -0 $P.sh
47                         [[ $? -eq 0 ]] && (( rc+=1 ))
48                 done
49                 if [[ $rc -eq 0 ]]; then
50                         echo there should be NO racer processes:
51                         ps uww -C "${RACER_PROGS// /,}"
52                         return 0
53                 fi
54                 echo -n "Waited $(( TOT_WAIT + SHORT_WAIT)), rc=$rc "
55                 (( SHORT_WAIT+=SHORT_WAIT ))
56                 (( TOT_WAIT+=SHORT_WAIT ))
57         done
58         ps uww -C "${RACER_PROGS// /,}"
59         return 1
60 }
61
62 RC=0
63
64 echo "Running $0 for $DURATION seconds. CTRL-C to exit"
65 trap "
66         echo \"Cleaning up\" 
67         racer_cleanup
68         exit 0
69 " INT TERM
70
71 cd `dirname $0`
72 for N in `seq 1 $NUM_THREADS`; do
73         for P in $RACER_PROGS; do
74                 ./$P.sh $DIR $MAX_FILES &
75         done
76 done
77
78 sleep $DURATION
79 racer_cleanup || RC=$?
80
81 # Check our to see whether our test DIR is still available.
82 df $DIR
83 (( RC+=$? ))
84 [ $RC -eq 0 ] && echo "We survived $0 for $DURATION seconds."
85 exit $RC