4 # For duration of 24 hours repeatedly failover a random MDS at
5 # 10 minute intervals and verify that no application errors occur.
7 # Test runs one of CLIENT_LOAD progs on remote clients.
12 LUSTRE=${LUSTRE:-$(dirname $0)/..}
13 . $LUSTRE/tests/test-framework.sh
17 # bug number for skipped test:
18 ALWAYS_EXCEPT="$RECOVERY_MDS_SCALE_EXCEPT"
19 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
23 remote_mds_nodsh && skip_env "remote MDS with nodsh"
24 remote_ost_nodsh && skip_env "remote OST with nodsh"
26 (( $CLIENTCOUNT < 3 )) &&
27 skip_env "need three or more clients"
29 # SHARED_DIRECTORY should be specified with a shared directory which is
30 # accessable on all of the nodes
31 if [ -z "$SHARED_DIRECTORY" ] || ! check_shared_dir $SHARED_DIRECTORY; then
32 skip_env "SHARED_DIRECTORY not set"
35 ERRORS_OK="" # No application failures should occur during this test.
37 if [ "$SLOW" = "no" ]; then
38 DURATION=${DURATION:-$((60 * 30))}
40 DURATION=${DURATION:-$((60 * 60 * 24))}
42 SERVER_FAILOVER_PERIOD=${SERVER_FAILOVER_PERIOD:-$((60 * 10))} # 10 minutes
44 MINSLEEP=${MINSLEEP:-120}
45 REQFAIL_PERCENT=${REQFAIL_PERCENT:-3} # bug17839 comment 62
46 # round up the result of integer division: C=(A + (B - 1)) / B
47 REQFAIL=${REQFAIL:-$(((DURATION * REQFAIL_PERCENT + (SERVER_FAILOVER_PERIOD *
48 100 - 1 )) / SERVER_FAILOVER_PERIOD / 100))}
50 END_RUN_FILE=${END_RUN_FILE:-$SHARED_DIRECTORY/end_run_file}
51 LOAD_PID_FILE=${LOAD_PID_FILE:-$TMP/client-load.pid}
52 VMSTAT_PID_FILE=${VMSTAT_PID_FILE:-$TMP/vmstat.pid}
57 $oput "******* Run Information *******"
58 $oput "SERVER_FAILOVER_PERIOD:$1"
63 $oput "SHARED_DIRECTORY:$6"
64 $oput "END_RUN_FILE:$7"
65 $oput "LOAD_PID_FILE:$8"
66 $oput "VMSTAT_PID_FILE:$9"
67 $oput "CLIENTCOUNT:$10"
70 $oput "*******************************"
73 server_numfailovers () {
75 local var=${facet}_numfailovers
78 [[ ${!var} ]] && val=${!var}
82 servers_numfailovers () {
86 for facet in ${MDTS//,/ } ${OSTS//,/ }; do
87 echo "$facet: $(server_numfailovers $facet) times"
91 summary_and_cleanup () {
94 # Having not empty END_RUN_FILE means the failed loads only
95 if [ -s $END_RUN_FILE ]; then
96 print_end_run_file $END_RUN_FILE
100 echo $(date +'%F %H:%M:%S') Terminating clients loads ...
101 echo "$0" >> $END_RUN_FILE
103 (( $rc == 0 )) || result=FAIL
105 log "Duration: $DURATION"
106 log "Server failover period: $SERVER_FAILOVER_PERIOD seconds"
107 log "Exited after: $ELAPSED seconds"
108 log "Number of failovers before exit:"
109 log "$(servers_numfailovers)"
110 log "Status: $result: rc=$rc"
112 # stop vmstat on OSS nodes
114 stop_process $(comma_list $(osts_nodes)) $VMSTAT_PID_FILE
116 # stop the client loads
117 stop_client_loads $NODES_TO_USE $LOAD_PID_FILE
119 if (( $rc != 0 )); then
120 # we are interested in only on failed clients and servers
121 local failedclients=$(cat $END_RUN_FILE | grep -v $0)
122 gather_logs $(comma_list $(all_server_nodes) $failedclients)
129 local flavor=${1:-"MDS"}
134 [ "$flavor" = "MDS" ] && servers=$MDTS || servers=$OSTS
136 stack_trap summary_and_cleanup EXIT INT
138 # start vmstat on OSS nodes
140 start_vmstat $(comma_list $(osts_nodes)) $VMSTAT_PID_FILE
144 start_client_loads $NODES_TO_USE
146 echo client loads pids:
147 do_nodesv $NODES_TO_USE "cat $LOAD_PID_FILE" || exit 3
153 local start_ts=$(date +%s)
154 local current_ts=$start_ts
156 while [ $ELAPSED -lt $DURATION -a ! -e $END_RUN_FILE ]; do
157 # In order to perform the
158 # expected number of failovers, we need to account the
160 # 1) the time that has elapsed during the client load checking
161 # 2) time takes for failover
162 it_time_start=$(date +%s)
164 serverfacet=$(get_random_entry $servers)
165 var=${serverfacet}_numfailovers
167 # Check that our client loads are still running. If any have
168 # died, that means they have died outside of recovery, which
170 log "==== Check clients loads BEFORE failover -- failure NOT OK \
171 ELAPSED=$ELAPSED DURATION=$DURATION \
172 PERIOD=$SERVER_FAILOVER_PERIOD"
173 check_client_loads $NODES_TO_USE || exit 4
175 log "Wait $serverfacet recovery complete before next failover"
176 if ! wait_recovery_complete $serverfacet; then
177 echo "$serverfacet recovery is not completed!"
181 local want="FULL\|IDLE"
182 log "Checking clients are in $want state before next failover"
183 wait_clients_import_state $NODES_TO_USE $serverfacet "$want" ||
184 echo "Client import not $want, please consider to" \
185 "increase SERVER_FAILOVER_PERIOD=" \
186 "$SERVER_FAILOVER_PERIOD!"
188 log "Starting failover on $serverfacet"
189 facet_failover "$serverfacet" || exit 1
191 # Check that our client loads are still running during failover.
192 # No application failures should occur.
193 log "==== Check clients loads AFTER failover -- failure NOT OK"
194 if ! check_client_loads $NODES_TO_USE; then
195 log "Client load failed during failover. Exiting..."
199 # Increment the number of failovers.
203 current_ts=$(date +%s)
204 ELAPSED=$((current_ts - start_ts))
206 sleep=$((SERVER_FAILOVER_PERIOD - (current_ts - it_time_start)))
208 # Keep counting the number of iterations when
209 # time spent to failover and two client loads check exceeded
210 # the value ( SERVER_FAILOVER_PERIOD - MINSLEEP ).
211 if (( $sleep < $MINSLEEP )); then
212 reqfail=$((reqfail + 1))
215 WARNING: failover and two check_client_loads time exceeded: SERVER_FAILOVER_PERIOD - MINSLEEP!
216 Failed loading I/O for a min period of $MINSLEEP $reqfail times (REQFAIL=$REQFAIL)
217 This iteration, load only applied for sleep=$sleep seconds.
218 Estimated max recovery time: $MAX_RECOV_TIME
219 Probably hardware is taking excessively long time to boot.
220 Try increasing SERVER_FAILOVER_PERIOD (current is $SERVER_FAILOVER_PERIOD), bug 20918
222 (( $reqfail > $REQFAIL )) && exit 6
225 log "$serverfacet failed over ${!var} times, and counting..."
227 [ $((ELAPSED + sleep)) -ge $DURATION ] && break
229 if (( $sleep > 0 )); then
230 echo "sleeping $sleep seconds... "
237 ################################## Main Flow ###################################
238 check_and_setup_lustre
239 rm -rf $DIR/[Rdfs][0-9]*
242 MAX_RECOV_TIME=$(max_recovery_time)
244 # The test node needs to be insulated from a lustre failure as much as possible,
245 # so not even loading the lustre modules is ideal.
247 # -- remove hostname from clients list
248 zconf_umount $HOSTNAME $MOUNT
249 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
250 NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $HOSTNAME)
252 check_progs_installed $NODES_TO_USE "${CLIENT_LOADS[@]}"
254 MDTS=$(get_facets MDS)
255 OSTS=$(get_facets OST)
257 # Print informaiton about settings
258 run_info $SERVER_FAILOVER_PERIOD $DURATION $MINSLEEP $SLOW $REQFAIL \
259 $SHARED_DIRECTORY $END_RUN_FILE $LOAD_PID_FILE $VMSTAT_PID_FILE \
260 $CLIENTCOUNT $MDTS $OSTS
262 test_failover_mds() {
263 # failover a random MDS
266 run_test failover_mds "failover MDS"
268 test_failover_ost() {
269 # failover a random OST
272 run_test failover_ost "failover OST"
274 zconf_mount $HOSTNAME $MOUNT || error "mount $MOUNT on $HOSTNAME failed"
275 client_up || error "start client on $HOSTNAME failed"
278 check_and_cleanup_lustre