Whamcloud - gitweb
New tag 2.14.52
[fs/lustre-release.git] / lustre / tests / racer.sh
1 #!/bin/bash
2 set -e
3
4 ONLY=${ONLY:-"$*"}
5
6 LUSTRE=${LUSTRE:-$(dirname $0)/..}
7 . $LUSTRE/tests/test-framework.sh
8 init_test_env $@
9 init_logging
10
11 build_test_filter
12
13 racer=$LUSTRE/tests/racer/racer.sh
14 echo racer: $racer with $MDSCOUNT MDTs
15
16 if [ "$SLOW" = "no" ]; then
17         DURATION=${DURATION:-300}
18 else
19         DURATION=${DURATION:-900}
20 fi
21 MOUNT_2=${MOUNT_2:-"yes"}
22
23 check_and_setup_lustre
24
25 CLIENTS=${CLIENTS:-$HOSTNAME}
26 RACERDIRS=${RACERDIRS:-"$DIR $DIR2"}
27 echo RACERDIRS=$RACERDIRS
28
29 RACER_FAILOVER=${RACER_FAILOVER:-false}
30 FAIL_TARGETS=${FAIL_TARGETS:-"MDS OST"}
31 RACER_FAILOVER_PERIOD=${RACER_FAILOVER_PERIOD:-60}
32
33 if $RACER_FAILOVER; then
34         declare -a  victims
35         for target in $FAIL_TARGETS; do
36                 victims=(${victims[@]} $(get_facets $target))
37         done
38         echo Victim facets ${victims[@]}
39 fi
40
41 #LU-4684
42 RACER_ENABLE_MIGRATION=false
43
44 if ((MDSCOUNT > 1 && "$MDS1_VERSION" >= $(version_code 2.8.0))); then
45         RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-true}
46         RACER_ENABLE_STRIPED_DIRS=${RACER_ENABLE_STRIPED_DIRS:-true}
47         RACER_ENABLE_MIGRATION=${RACER_ENABLE_MIGRATION:-true}
48 elif ((MDSCOUNT > 1 && "$MDS1_VERSION" >= $(version_code 2.5.0))); then
49         RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-true}
50 fi
51
52 [[ "$MDS1_VERSION" -lt $(version_code 2.9.54) ||
53    $(facet_fstype mgs) != zfs ]] && RACER_ENABLE_SNAPSHOT=false
54
55 [[ "$MDS1_VERSION" -le $(version_code 2.9.55) ]] &&
56         RACER_ENABLE_PFL=false
57
58 [[ "$MDS1_VERSION" -le $(version_code 2.10.53) ]] &&
59         RACER_ENABLE_DOM=false
60
61 [[ "$MDS1_VERSION" -lt $(version_code 2.10.55) ]] &&
62         RACER_ENABLE_FLR=false
63
64 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.12.0) ]] &&
65         RACER_ENABLE_SEL=false
66
67 RACER_ENABLE_REMOTE_DIRS=${RACER_ENABLE_REMOTE_DIRS:-false}
68 RACER_ENABLE_STRIPED_DIRS=${RACER_ENABLE_STRIPED_DIRS:-false}
69 RACER_ENABLE_MIGRATION=${RACER_ENABLE_MIGRATION:-false}
70 RACER_ENABLE_SNAPSHOT=${RACER_ENABLE_SNAPSHOT:-true}
71 RACER_ENABLE_PFL=${RACER_ENABLE_PFL:-true}
72 RACER_ENABLE_DOM=${RACER_ENABLE_DOM:-true}
73 RACER_ENABLE_FLR=${RACER_ENABLE_FLR:-true}
74 RACER_ENABLE_SEL=${RACER_ENABLE_SEL:-true}
75 RACER_EXTRA_LAYOUT=${RACER_EXTRA_LAYOUT:-""}
76
77 fail_random_facet () {
78         local facets=${victims[@]}
79         facets=${facets// /,}
80
81         sleep $RACER_FAILOVER_PERIOD
82         while [ ! -f $racer_done ]; do
83                 local facet=$(get_random_entry $facets)
84                 facet_failover $facet
85                 sleep $RACER_FAILOVER_PERIOD
86         done
87 }
88
89 # run racer
90 test_1() {
91         local rrc=0
92         local rc=0
93         local clients=$CLIENTS
94         local RDIRS
95         local i
96         local racer_done=$TMP/racer_done
97
98         rm -f $racer_done
99
100         for d in ${RACERDIRS}; do
101                 is_mounted $d || continue
102
103                 RDIRS="$RDIRS $d/racer"
104                 mkdir -p $d/racer
105                 if [[ -n "$RACER_EXTRA_LAYOUT" ]]; then
106                         $LFS setstripe $d/racer $RACER_EXTRA_LAYOUT ||
107                         error "setstripe $RACER_EXTRA_LAYOUT failed"
108                 fi
109                 if [ $MDSCOUNT -ge 2 ]; then
110                         for i in $(seq $((MDSCOUNT - 1))); do
111                                 RDIRS="$RDIRS $d/racer$i"
112                                 if [ ! -e $d/racer$i ]; then
113                                         $LFS mkdir -i $i $d/racer$i ||
114                                                 error "lfs mkdir $i failed"
115                                 fi
116                                 if [[ -n "$RACER_EXTRA_LAYOUT" ]]; then
117                                         $LFS setstripe $d/racer$i \
118                                                 $RACER_EXTRA_LAYOUT ||
119                                         error "setstripe \
120                                                 $RACER_EXTRA_LAYOUT failed"
121                                 fi
122                         done
123                 fi
124         done
125
126         local rpids=""
127         for rdir in $RDIRS; do
128                 do_nodes $clients "DURATION=$DURATION \
129                         MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT\
130                         RACER_ENABLE_REMOTE_DIRS=$RACER_ENABLE_REMOTE_DIRS \
131                         RACER_ENABLE_STRIPED_DIRS=$RACER_ENABLE_STRIPED_DIRS \
132                         RACER_ENABLE_MIGRATION=$RACER_ENABLE_MIGRATION \
133                         RACER_ENABLE_PFL=$RACER_ENABLE_PFL \
134                         RACER_ENABLE_DOM=$RACER_ENABLE_DOM \
135                         RACER_ENABLE_FLR=$RACER_ENABLE_FLR \
136                         RACER_MAX_CLEANUP_WAIT=$RACER_MAX_CLEANUP_WAIT \
137                         RACER_ENABLE_SEL=$RACER_ENABLE_SEL \
138                         RACER_EXTRA=$RACER_EXTRA \
139                         RACER_EXTRA_LAYOUT=\\\"$RACER_EXTRA_LAYOUT\\\" \
140                         RACER_PROGS=$RACER_PROGS \
141                         NUM_THREADS=$NUM_THREADS \
142                         MAX_FILES=$MAX_FILES \
143                         LFS=$LFS \
144                         LCTL=$LCTL \
145                         $racer $rdir $NUM_RACER_THREADS" &
146                 pid=$!
147                 rpids="$rpids $pid"
148         done
149
150         local failpid=""
151         if $RACER_FAILOVER; then
152                 fail_random_facet &
153                 failpid=$!
154                 echo racers failpid: $failpid
155         fi
156
157         local lss_pids=""
158         if $RACER_ENABLE_SNAPSHOT; then
159                 lss_gen_conf
160
161                 $LUSTRE/tests/racer/lss_create.sh &
162                 pid=$!
163                 lss_pids="$lss_pids $pid"
164
165                 $LUSTRE/tests/racer/lss_destroy.sh &
166                 pid=$!
167                 lss_pids="$lss_pids $pid"
168         fi
169
170         echo racers pids: $rpids
171         for pid in $rpids; do
172                 wait $pid
173                 rc=$?
174                 echo "pid=$pid rc=$rc"
175                 if [ $rc != 0 ]; then
176                     rrc=$((rrc + 1))
177                 fi
178         done
179
180         if $RACER_FAILOVER; then
181                 touch $racer_done
182                 wait $failpid
183                 rrc=$((rrc + $?))
184         fi
185
186         if $RACER_ENABLE_SNAPSHOT; then
187                 killall -q lss_create.sh
188                 killall -q lss_destroy.sh
189
190                 for pid in $lss_pids; do
191                         wait $pid
192                 done
193
194                 lss_cleanup
195         fi
196
197         return $rrc
198 }
199 run_test 1 "racer on clients: ${CLIENTS:-$(hostname)} DURATION=$DURATION"
200
201 complete $SECONDS
202 check_and_cleanup_lustre
203 exit_status