Whamcloud - gitweb
LU-10657 utils: fd leak in mirror_split()
[fs/lustre-release.git] / lustre / tests / racer.sh
1 #!/bin/bash
2 #set -vx
3 set -e
4
5 ONLY=${ONLY:-"$*"}
6 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
7 . $LUSTRE/tests/test-framework.sh
8 init_test_env $@
9 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
10 init_logging
11
12 racer=$LUSTRE/tests/racer/racer.sh
13 echo racer: $racer with $MDSCOUNT MDTs
14
15 if [ "$SLOW" = "no" ]; then
16     DURATION=${DURATION:-300}
17 else
18     DURATION=${DURATION:-900}
19 fi
20 MOUNT_2=${MOUNT_2:-"yes"}
21
22 build_test_filter
23 check_and_setup_lustre
24
25 CLIENTS=${CLIENTS:-$HOSTNAME}
26 RACERDIRS=${RACERDIRS:-"$DIR $DIR2"}
27 echo RACERDIRS=$RACERDIRS
28
29 if ((MDSCOUNT > 1 &&
30      $(lustre_version_code $SINGLEMDS) >= $(version_code 2.8.0))); then
31         RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-true}
32         RACER_ENABLE_STRIPED_DIRS=${RACER_ENABLE_STRIPED_DIRS:-true}
33         RACER_ENABLE_MIGRATION=${RACER_ENABLE_MIGRATION:-true}
34 elif ((MDSCOUNT > 1 &&
35        $(lustre_version_code $SINGLEMDS) >= $(version_code 2.5.0))); then
36         RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-true}
37 fi
38
39 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ||
40    $(facet_fstype mgs) != zfs ]] && RACER_ENABLE_SNAPSHOT=false
41
42 RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-false}
43 RACER_ENABLE_STRIPED_DIRS=${RACER_ENABLE_STRIPED_DIRS:-false}
44 RACER_ENABLE_MIGRATION=${RACER_ENABLE_MIGRATION:-false}
45 RACER_ENABLE_SNAPSHOT=${RACER_ENABLE_SNAPSHOT:-true}
46 RACER_ENABLE_DOM=${RACER_ENABLE_DOM:-false}
47
48 check_progs_installed $CLIENTS $racer ||
49         { skip_env "$racer not found" && exit 0; }
50
51 # run racer
52 test_1() {
53         local rrc=0
54         local rc=0
55         local clients=$CLIENTS
56         local RDIRS
57         local i
58
59         for d in ${RACERDIRS}; do
60                 is_mounted $d || continue
61
62                 RDIRS="$RDIRS $d/racer"
63                 mkdir -p $d/racer
64         #       lfs setstripe $d/racer -c -1
65                 if [ $MDSCOUNT -ge 2 ]; then
66                         for i in $(seq $((MDSCOUNT - 1))); do
67                                 RDIRS="$RDIRS $d/racer$i"
68                                 if [ ! -e $d/racer$i ]; then
69                                         $LFS mkdir -i $i $d/racer$i ||
70                                                 error "lfs mkdir $i failed"
71                                 fi
72                         done
73                 fi
74         done
75
76         local rpids=""
77         for rdir in $RDIRS; do
78                 do_nodes $clients "DURATION=$DURATION \
79                         MDSCOUNT=$MDSCOUNT \
80                         RACER_ENABLE_REMOTE_DIRS=$RACER_ENABLE_REMOTE_DIRS \
81                         RACER_ENABLE_STRIPED_DIRS=$RACER_ENABLE_STRIPED_DIRS \
82                         RACER_ENABLE_MIGRATION=$RACER_ENABLE_MIGRATION \
83                         RACER_ENABLE_DOM=$RACER_ENABLE_DOM \
84                         LFS=$LFS \
85                         $racer $rdir $NUM_RACER_THREADS" &
86                 pid=$!
87                 rpids="$rpids $pid"
88         done
89
90         local lss_pids=""
91         if $RACER_ENABLE_SNAPSHOT; then
92                 lss_gen_conf
93
94                 $LUSTRE/tests/racer/lss_create.sh &
95                 pid=$!
96                 lss_pids="$lss_pids $pid"
97
98                 $LUSTRE/tests/racer/lss_destroy.sh &
99                 pid=$!
100                 lss_pids="$lss_pids $pid"
101         fi
102
103         echo racers pids: $rpids
104         for pid in $rpids; do
105                 wait $pid
106                 rc=$?
107                 echo "pid=$pid rc=$rc"
108                 if [ $rc != 0 ]; then
109                     rrc=$((rrc + 1))
110                 fi
111         done
112
113         if $RACER_ENABLE_SNAPSHOT; then
114                 killall -q lss_create.sh
115                 killall -q lss_destroy.sh
116
117                 for pid in $lss_pids; do
118                         wait $pid
119                 done
120
121                 lss_cleanup
122         fi
123
124         return $rrc
125 }
126 run_test 1 "racer on clients: ${CLIENTS:-$(hostname)} DURATION=$DURATION"
127
128 complete $SECONDS
129 check_and_cleanup_lustre
130 exit_status