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 log "Checking clients are in FULL or IDLE state before next failover"
182 wait_clients_import_ready $NODES_TO_USE $serverfacet ||
183 echo "Client import is not ready, please consider to" \
184 "increase SERVER_FAILOVER_PERIOD=" \
185 "$SERVER_FAILOVER_PERIOD!"
187 log "Starting failover on $serverfacet"
188 facet_failover "$serverfacet" || exit 1
190 # Check that our client loads are still running during failover.
191 # No application failures should occur.
192 log "==== Check clients loads AFTER failover -- failure NOT OK"
193 if ! check_client_loads $NODES_TO_USE; then
194 log "Client load failed during failover. Exiting..."
198 # Increment the number of failovers.
202 current_ts=$(date +%s)
203 ELAPSED=$((current_ts - start_ts))
205 sleep=$((SERVER_FAILOVER_PERIOD - (current_ts - it_time_start)))
207 # Keep counting the number of iterations when
208 # time spent to failover and two client loads check exceeded
209 # the value ( SERVER_FAILOVER_PERIOD - MINSLEEP ).
210 if (( $sleep < $MINSLEEP )); then
211 reqfail=$((reqfail + 1))
214 WARNING: failover and two check_client_loads time exceeded: SERVER_FAILOVER_PERIOD - MINSLEEP!
215 Failed loading I/O for a min period of $MINSLEEP $reqfail times (REQFAIL=$REQFAIL)
216 This iteration, load only applied for sleep=$sleep seconds.
217 Estimated max recovery time: $MAX_RECOV_TIME
218 Probably hardware is taking excessively long time to boot.
219 Try increasing SERVER_FAILOVER_PERIOD (current is $SERVER_FAILOVER_PERIOD), bug 20918
221 (( $reqfail > $REQFAIL )) && exit 6
224 log "$serverfacet failed over ${!var} times, and counting..."
226 [ $((ELAPSED + sleep)) -ge $DURATION ] && break
228 if (( $sleep > 0 )); then
229 echo "sleeping $sleep seconds... "
236 ################################## Main Flow ###################################
237 check_and_setup_lustre
238 rm -rf $DIR/[Rdfs][0-9]*
241 MAX_RECOV_TIME=$(max_recovery_time)
243 # The test node needs to be insulated from a lustre failure as much as possible,
244 # so not even loading the lustre modules is ideal.
246 # -- remove hostname from clients list
247 zconf_umount $HOSTNAME $MOUNT
248 NODES_TO_USE=${NODES_TO_USE:-$CLIENTS}
249 NODES_TO_USE=$(exclude_items_from_list $NODES_TO_USE $HOSTNAME)
251 check_progs_installed $NODES_TO_USE "${CLIENT_LOADS[@]}"
253 MDTS=$(get_facets MDS)
254 OSTS=$(get_facets OST)
256 # Print informaiton about settings
257 run_info $SERVER_FAILOVER_PERIOD $DURATION $MINSLEEP $SLOW $REQFAIL \
258 $SHARED_DIRECTORY $END_RUN_FILE $LOAD_PID_FILE $VMSTAT_PID_FILE \
259 $CLIENTCOUNT $MDTS $OSTS
261 test_failover_mds() {
262 # failover a random MDS
265 run_test failover_mds "failover MDS"
267 test_failover_ost() {
268 # failover a random OST
271 run_test failover_ost "failover OST"
273 zconf_mount $HOSTNAME $MOUNT || error "mount $MOUNT on $HOSTNAME failed"
274 client_up || error "start client on $HOSTNAME failed"
277 check_and_cleanup_lustre