2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 # client failure does not affect other clients
6 # Start load on clients (each client works on it's own directory).
7 # At defined (5-10 minutes) interval fail one random client and then fail mds.
8 # Reintegrate failed client after recovery completed,
9 # application errors are allowed for that client but not on other clients.
10 # 10 minute intervals and verify that no application errors occur.
12 # Test runs one of CLIENT_LOAD progs on remote clients.
17 # bug number for skipped test:
18 ALWAYS_EXCEPT="$RECOVERY_RANDOM_SCALE_EXCEPT"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
21 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
22 . $LUSTRE/tests/test-framework.sh
24 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
27 remote_mds_nodsh && skip_env "remote MDS with nodsh" && exit 0
28 remote_ost_nodsh && skip_env "remote OST with nodsh" && exit 0
30 [ -z "$CLIENTS" -o $CLIENTCOUNT -lt 3 ] &&
31 skip_env "need three or more clients" && exit 0
33 if [ -z "$SHARED_DIRECTORY" ] || ! check_shared_dir $SHARED_DIRECTORY; then
34 skip_env "SHARED_DIRECTORY should be specified with a shared directory \
35 which is accessable on all of the nodes"
39 [[ $FAILURE_MODE = SOFT ]] && \
40 log "WARNING: $0 is not functional with FAILURE_MODE = SOFT, bz22797"
42 # Application failures are allowed for the failed client
43 # but not for other clients.
46 if [ "$SLOW" = "no" ]; then
47 DURATION=${DURATION:-$((60 * 30))}
49 DURATION=${DURATION:-$((60 * 60 * 24))}
51 SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 10))} # 10 minutes
53 MINSLEEP=${MINSLEEP:-120}
54 REQFAIL_PERCENT=${REQFAIL_PERCENT:-3} # bug17839 comment 62
55 REQFAIL=${REQFAIL:-$((DURATION / SERVER_FAILOVER_PERIOD *
56 REQFAIL_PERCENT / 100))}
58 END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
59 LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
60 VMSTAT_PID_FILE=${VMSTAT_PID_FILE:-$TMP/vmstat.pid}
66 for facet in $MDTS ${FAILED_CLIENTS//,/ }; do
70 echo "$facet failed over $val times"
75 summary_and_cleanup () {
79 # Having not empty END_RUN_FILE means the failed loads only
80 if [ -s $END_RUN_FILE ]; then
81 print_end_run_file $END_RUN_FILE
85 echo $(date +'%F %H:%M:%S') Terminating clients loads ...
86 echo "$0" >> $END_RUN_FILE
88 [ $rc -eq 0 ] || result=FAIL
90 log "Duration: $DURATION
91 Server failover period: $SERVER_FAILOVER_PERIOD seconds
92 Exited after: $ELAPSED seconds
93 Number of failovers before exit:
95 Status: $result: rc=$rc"
97 # stop vmstat on OSS nodes
98 [ "$VMSTAT" ] && stop_process $(comma_list $(osts_nodes)) $VMSTAT_PID_FILE
100 # stop the client loads
101 stop_client_loads $NODES_TO_USE $LOAD_PID_FILE
103 if [ $rc -ne 0 ]; then
104 # we are interested in only on failed clients and servers
105 local failedclients=$(cat $END_RUN_FILE | grep -v $0)
106 # FIXME: need ostfailover-s nodes also for FLAVOR=OST
107 gather_logs $(comma_list $(osts_nodes) $(mdts_nodes) \
108 $mdsfailover_HOST $failedclients)
114 ################################## Main Flow ###################################
117 check_and_setup_lustre
118 rm -rf $DIR/[Rdfs][0-9]*
120 MAX_RECOV_TIME=$(max_recovery_time)
122 # The test node needs to be insulated from a lustre failure as much as possible,
123 # so not even loading the lustre modules is ideal.
125 # -- remove hostname from clients list
126 zconf_umount $HOSTNAME $MOUNT
127 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
128 NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $HOSTNAME)
130 check_progs_installed $NODES_TO_USE ${CLIENT_LOADS[@]}
132 MDTS=$(get_facets MDS)
134 # Fail a random client and then failover a random MDS.
135 test_fail_client_mds() {
141 trap summary_and_cleanup EXIT INT
143 # start vmstat on OSS nodes
144 [ "$VMSTAT" ] && start_vmstat $(comma_list $(osts_nodes)) $VMSTAT_PID_FILE
148 start_client_loads $NODES_TO_USE
150 echo client loads pids:
151 do_nodesv $NODES_TO_USE "cat $LOAD_PID_FILE" || exit 3
157 local start_ts=$(date +%s)
158 local current_ts=$start_ts
160 while [ $ELAPSED -lt $DURATION -a ! -e $END_RUN_FILE ]; do
161 # In order to perform the
162 # expected number of failovers, we need to account the following:
163 # 1) the time that has elapsed during the client load checking
164 # 2) time takes for failover
165 it_time_start=$(date +%s)
167 fail_client=$(get_random_entry $NODES_TO_USE)
168 client_var=$(node_var_name $fail_client)_nums
170 # store the list of failed clients
171 # lists are comma separated
172 FAILED_CLIENTS=$(expand_list $FAILED_CLIENTS $fail_client)
174 serverfacet=$(get_random_entry $MDTS)
175 var=${serverfacet}_nums
177 # Check that our client loads are still running. If any have died,
178 # that means they have died outside of recovery, which is unacceptable.
179 log "==== Checking the clients loads BEFORE failover -- failure NOT OK \
180 ELAPSED=$ELAPSED DURATION=$DURATION PERIOD=$SERVER_FAILOVER_PERIOD"
181 check_client_loads $NODES_TO_USE || exit 4
183 log "FAIL CLIENT $fail_client..."
184 shutdown_client $fail_client
186 log "Starting failover on $serverfacet"
187 facet_failover "$serverfacet" || exit 1
189 if ! wait_recovery_complete $serverfacet; then
190 echo "$serverfacet recovery is not completed!"
194 boot_node $fail_client
195 echo "Reintegrating $fail_client"
196 zconf_mount $fail_client $MOUNT || exit $?
197 client_up $fail_client || exit $?
199 # Increment the number of failovers
202 val=$((${!client_var} + 1))
203 eval $client_var=$val
205 # load script on failed clients could create END_RUN_FILE
206 # We shuold remove it and ignore the failure if this
207 # file contains the failed client only.
208 # We can not use ERRORS_OK when start all loads at the start of
209 # this script because the application errors allowed for random
210 # failed client only, but not for all clients.
211 if [ -e $END_RUN_FILE ]; then
213 read end_run_node < $END_RUN_FILE
214 [[ $end_run_node = $fail_client ]] &&
215 rm -f $END_RUN_FILE || exit 13
218 restart_client_loads $fail_client $ERRORS_OK || exit $?
220 # Check that not failed clients loads are still running.
221 # No application failures should occur on clients that were not failed.
222 log "==== Checking the clients loads AFTER failed client reintegrated \
224 if ! ERRORS_OK= check_client_loads \
225 $(exclude_items_from_list $NODES_TO_USE $fail_client); then
226 log "Client load failed. Exiting..."
230 current_ts=$(date +%s)
231 ELAPSED=$((current_ts - start_ts))
232 sleep=$((SERVER_FAILOVER_PERIOD - (current_ts - it_time_start)))
234 # Keep counting the number of iterations when
235 # time spent to failover and two client loads check exceeded
236 # the value ( SERVER_FAILOVER_PERIOD - MINSLEEP ).
237 if [ $sleep -lt $MINSLEEP ]; then
238 reqfail=$((reqfail + 1))
239 log "WARNING: failover, client reintegration and \
240 check_client_loads time exceeded SERVER_FAILOVER_PERIOD - MINSLEEP!
241 Failed to load the filesystem with I/O for a minimum period of \
242 $MINSLEEP $reqfail times ( REQFAIL=$REQFAIL ).
243 This iteration, the load was only applied for sleep=$sleep seconds.
244 Estimated max recovery time : $MAX_RECOV_TIME
245 Probably the hardware is taking excessively long time to boot.
246 Try to increase SERVER_FAILOVER_PERIOD (current is $SERVER_FAILOVER_PERIOD), \
248 [ $reqfail -gt $REQFAIL ] && exit 6
251 log "Number of failovers:
252 $(numfailovers) and counting..."
254 [ $((ELAPSED + sleep)) -ge $DURATION ] && break
256 if [ $sleep -gt 0 ]; then
257 echo "sleeping $sleep seconds... "
263 run_test fail_client_mds "fail client, then failover MDS"
265 zconf_mount $HOSTNAME $MOUNT || error "mount $MOUNT on $HOSTNAME failed"
266 client_up || error "start client on $HOSTNAME failed"
268 complete $(basename $0) $SECONDS
269 check_and_cleanup_lustre