Whamcloud - gitweb
LU-12125 tests: allow racer to specify extra tasks
[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
76 fail_random_facet () {
77         local facets=${victims[@]}
78         facets=${facets// /,}
79
80         sleep $RACER_FAILOVER_PERIOD
81         while [ ! -f $racer_done ]; do
82                 local facet=$(get_random_entry $facets)
83                 facet_failover $facet
84                 sleep $RACER_FAILOVER_PERIOD
85         done
86 }
87
88 # run racer
89 test_1() {
90         local rrc=0
91         local rc=0
92         local clients=$CLIENTS
93         local RDIRS
94         local i
95         local racer_done=$TMP/racer_done
96
97         rm -f $racer_done
98
99         for d in ${RACERDIRS}; do
100                 is_mounted $d || continue
101
102                 RDIRS="$RDIRS $d/racer"
103                 mkdir -p $d/racer
104         #       lfs setstripe $d/racer -c -1
105                 if [ $MDSCOUNT -ge 2 ]; then
106                         for i in $(seq $((MDSCOUNT - 1))); do
107                                 RDIRS="$RDIRS $d/racer$i"
108                                 if [ ! -e $d/racer$i ]; then
109                                         $LFS mkdir -i $i $d/racer$i ||
110                                                 error "lfs mkdir $i failed"
111                                 fi
112                         done
113                 fi
114         done
115
116         local rpids=""
117         for rdir in $RDIRS; do
118                 do_nodes $clients "DURATION=$DURATION \
119                         MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT\
120                         RACER_ENABLE_REMOTE_DIRS=$RACER_ENABLE_REMOTE_DIRS \
121                         RACER_ENABLE_STRIPED_DIRS=$RACER_ENABLE_STRIPED_DIRS \
122                         RACER_ENABLE_MIGRATION=$RACER_ENABLE_MIGRATION \
123                         RACER_ENABLE_PFL=$RACER_ENABLE_PFL \
124                         RACER_ENABLE_DOM=$RACER_ENABLE_DOM \
125                         RACER_ENABLE_FLR=$RACER_ENABLE_FLR \
126                         RACER_MAX_CLEANUP_WAIT=$RACER_MAX_CLEANUP_WAIT \
127                         RACER_ENABLE_SEL=$RACER_ENABLE_SEL \
128                         RACER_EXTRA=$RACER_EXTRA \
129                         LFS=$LFS \
130                         LCTL=$LCTL \
131                         $racer $rdir $NUM_RACER_THREADS" &
132                 pid=$!
133                 rpids="$rpids $pid"
134         done
135
136         local failpid=""
137         if $RACER_FAILOVER; then
138                 fail_random_facet &
139                 failpid=$!
140                 echo racers failpid: $failpid
141         fi
142
143         local lss_pids=""
144         if $RACER_ENABLE_SNAPSHOT; then
145                 lss_gen_conf
146
147                 $LUSTRE/tests/racer/lss_create.sh &
148                 pid=$!
149                 lss_pids="$lss_pids $pid"
150
151                 $LUSTRE/tests/racer/lss_destroy.sh &
152                 pid=$!
153                 lss_pids="$lss_pids $pid"
154         fi
155
156         echo racers pids: $rpids
157         for pid in $rpids; do
158                 wait $pid
159                 rc=$?
160                 echo "pid=$pid rc=$rc"
161                 if [ $rc != 0 ]; then
162                     rrc=$((rrc + 1))
163                 fi
164         done
165
166         if $RACER_FAILOVER; then
167                 touch $racer_done
168                 wait $failpid
169                 rrc=$((rrc + $?))
170         fi
171
172         if $RACER_ENABLE_SNAPSHOT; then
173                 killall -q lss_create.sh
174                 killall -q lss_destroy.sh
175
176                 for pid in $lss_pids; do
177                         wait $pid
178                 done
179
180                 lss_cleanup
181         fi
182
183         return $rrc
184 }
185 run_test 1 "racer on clients: ${CLIENTS:-$(hostname)} DURATION=$DURATION"
186
187 complete $SECONDS
188 check_and_cleanup_lustre
189 exit_status