2 # Test multiple failures, AKA Test 17
6 LUSTRE=${LUSTRE:-`dirname $0`/..}
7 . $LUSTRE/tests/test-framework.sh
11 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13 ALWAYS_EXCEPT="10 $INSANITY_EXCEPT"
15 if [ "$FAILURE_MODE" = "HARD" ]; then
16 mixed_ost_devs && CONFIG_EXCEPTIONS="0 2 4 5 6 8" && \
17 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. " && \
18 echo "Except the tests: $CONFIG_EXCEPTIONS" && \
19 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
23 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
26 CLEANUP=${CLEANUP:-""}
30 SINGLECLIENT=${SINGLECLIENT:-$HOSTNAME}
31 LIVE_CLIENT=${LIVE_CLIENT:-$SINGLECLIENT}
32 FAIL_CLIENTS=${FAIL_CLIENTS:-$RCLIENTS}
34 assert_env mds_HOST MDS_MKFS_OPTS
35 assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
36 assert_env LIVE_CLIENT FSNAME
38 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
39 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
41 # FAIL_CLIENTS list should not contain the LIVE_CLIENT
42 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
47 # fail clients round robin
49 # list of failable clients
50 FAIL_LIST=($FAIL_CLIENTS)
51 FAIL_NUM=${#FAIL_LIST[*]}
54 DOWN_NUM=0 # number of nodes currently down
56 # set next client to fail
58 FAIL_CLIENT=${FAIL_LIST[$FAIL_NEXT]}
59 FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
60 echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
66 log "Request clients to fail: ${num}. Num of clients to fail: ${FAIL_NUM}, already failed: $DOWN_NUM"
67 if [ -z "$num" ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
68 num=$((FAIL_NUM - DOWN_NUM))
71 if [ -z "$num" ] || [ "$num" -le 0 ]; then
72 log "No clients failed!"
78 for i in `seq $num`; do
81 DOWN_CLIENTS="$DOWN_CLIENTS $client"
82 shutdown_client $client
85 echo "down clients: $DOWN_CLIENTS"
87 for client in $DOWN_CLIENTS; do
90 DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
94 reintegrate_clients() {
95 for client in $DOWN_CLIENTS; do
97 echo "Restarting $client"
98 zconf_mount $client $MOUNT || return 1
105 start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
112 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
113 if echo $DOWN_CLIENTS | grep -q $c; then continue; fi
114 $PDSH $c touch $MOUNT/${c}_$file || return 1
120 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
121 $PDSH $c rm $MOUNT/${c}_$file
126 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
127 echo "$c mkdir $MOUNT/$c"
128 $PDSH $c "mkdir $MOUNT/$c"
129 $PDSH $c "ls -l $MOUNT/$c"
134 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
135 echo "rmdir $MOUNT/$c"
136 $PDSH $LIVE_CLIENT "rmdir $MOUNT/$c"
140 clients_recover_osts() {
142 # do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
145 check_and_setup_lustre
147 # 9 Different Failure Modes Combinations
148 echo "Starting Test 17 at `date`"
151 facet_failover $SINGLEMDS
152 echo "Waiting for df pid: $DFPID"
153 wait $DFPID || { echo "df returned $?" && return 1; }
155 for i in $(seq $OSTCOUNT) ; do
156 facet_failover ost$i || return 4
157 echo "Waiting for df pid: $DFPID"
158 wait $DFPID || { echo "df returned $?" && return 3; }
162 run_test 0 "Fail all nodes, independently"
164 ############### First Failure Mode ###############
166 echo "Don't do a MDS - MDS Failure Case"
167 echo "This makes no sense"
169 run_test 1 "MDS/MDS failure"
170 ###################################################
172 ############### Second Failure Mode ###############
174 echo "Verify Lustre filesystem is up and running"
175 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
179 shutdown_facet $SINGLEMDS
180 reboot_facet $SINGLEMDS
182 # prepare for MDS failover
183 change_active $SINGLEMDS
184 reboot_facet $SINGLEMDS
192 echo "Reintegrating OST"
195 start_ost 1 || return 2
198 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || return $?
202 clients_recover_osts ost1
203 echo "Verify reintegration"
204 client_df || return 1
207 run_test 2 "Second Failure Mode: MDS/OST `date`"
208 ###################################################
211 ############### Third Failure Mode ###############
214 echo "Verify Lustre filesystem is up and running"
215 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
218 facet_failover $SINGLEMDS
219 wait $DFPID || echo df failed: $?
222 echo "Test Lustre stability after MDS failover"
226 echo "Failing 2 CLIENTS"
230 echo "Test Lustre stability after CLIENT failure"
234 echo "Reintegrating CLIENTS"
235 reintegrate_clients || return 1
237 client_df || return 3
238 sleep 2 # give it a little time for fully recovered before next test
240 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
241 ###################################################
243 ############### Fourth Failure Mode ###############
245 echo "Fourth Failure Mode: OST/MDS `date`"
251 echo "Test Lustre stability after OST failure"
257 shutdown_facet $SINGLEMDS
258 reboot_facet $SINGLEMDS
260 # prepare for MDS failover
261 change_active $SINGLEMDS
262 reboot_facet $SINGLEMDS
269 echo "Reintegrating OST"
275 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS
280 clients_recover_osts ost1
281 echo "Test Lustre stability after MDS failover"
282 client_df || return 1
284 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
285 ###################################################
287 ############### Fifth Failure Mode ###############
289 [ $OSTCOUNT -lt 2 ] && skip "$OSTCOUNT < 2, not enough OSTs" && return 0
291 echo "Fifth Failure Mode: OST/OST `date`"
294 echo "Verify Lustre filesystem is up and running"
295 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
304 echo "Test Lustre stability after OST failure"
314 echo "Test Lustre stability after OST failure"
320 echo "Reintegrating OSTs"
326 clients_recover_osts ost1
327 clients_recover_osts ost2
332 client_df || return 2
334 run_test 5 "Fifth Failure Mode: OST/OST `date`"
335 ###################################################
337 ############### Sixth Failure Mode ###############
339 echo "Sixth Failure Mode: OST/CLIENT `date`"
342 echo "Verify Lustre filesystem is up and running"
343 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
346 client_touch testfile || return 2
353 echo "Test Lustre stability after OST failure"
360 echo "Failing CLIENTs"
364 echo "Test Lustre stability after CLIENTs failure"
371 echo "Reintegrating OST/CLIENTs"
374 reintegrate_clients || return 1
377 wait_remote_prog df $((TIMEOUT * 3 + 10))
381 echo "Verifying mount"
382 [ -z "$(mounted_lustre_filesystems)" ] && return 3
385 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
386 ###################################################
389 ############### Seventh Failure Mode ###############
391 echo "Seventh Failure Mode: CLIENT/MDS `date`"
394 echo "Verify Lustre filesystem is up and running"
395 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
398 client_touch testfile || return 1
401 echo "Part 1: Failing CLIENT"
405 echo "Test Lustre stability after CLIENTs failure"
407 $PDSH $LIVE_CLIENT "ls -l $MOUNT"
408 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
411 echo "Wait 1 minutes"
415 echo "Verify Lustre filesystem is up and running"
416 [ -z "$(mounted_lustre_filesystems)" ] && return 2
422 facet_failover $SINGLEMDS
425 echo "Test Lustre stability after MDS failover"
426 wait $DFPID || echo "df on down clients fails " || return 1
427 $PDSH $LIVE_CLIENT "ls -l $MOUNT"
428 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
431 echo "Reintegrating CLIENTs"
432 reintegrate_clients || return 2
436 echo "wait 1 minutes"
439 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
440 ###################################################
443 ############### Eighth Failure Mode ###############
445 echo "Eighth Failure Mode: CLIENT/OST `date`"
448 echo "Verify Lustre filesystem is up and running"
449 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
452 client_touch testfile
455 echo "Failing CLIENTs"
459 echo "Test Lustre stability after CLIENTs failure"
461 $PDSH $LIVE_CLIENT "ls -l $MOUNT"
462 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
465 echo "Wait 1 minutes"
469 echo "Verify Lustre filesystem is up and running"
470 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
473 client_touch testfile
481 echo "Test Lustre stability after OST failure"
485 #non-failout hangs forever here
486 #$PDSH $LIVE_CLIENT "ls -l $MOUNT"
487 #$PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
490 echo "Reintegrating CLIENTs/OST"
491 reintegrate_clients || return 3
495 client_df || return 1
496 client_touch testfile2 || return 2
499 echo "Wait 1 minutes"
502 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
503 ###################################################
506 ############### Ninth Failure Mode ###############
511 echo "Verify Lustre filesystem is up and running"
512 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
515 client_touch testfile || return 1
518 echo "Failing CLIENTs"
522 echo "Test Lustre stability after CLIENTs failure"
524 $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 1
525 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 2
528 echo "Wait 1 minutes"
532 echo "Verify Lustre filesystem is up and running"
533 $PDSH $LIVE_CLIENT df $MOUNT || return 3
534 client_touch testfile || return 4
537 echo "Failing CLIENTs"
541 echo "Test Lustre stability after CLIENTs failure"
543 $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 5
544 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 6
547 echo "Reintegrating CLIENTs/CLIENTs"
548 reintegrate_clients || return 7
552 echo "Wait 1 minutes"
555 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
556 ###################################################
559 #Run availability after all failures
560 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
561 LOADTEST=${LOADTEST:-metadata-load.py}
562 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
564 run_test 10 "Running Availability for 6 hours..."
566 equals_msg `basename $0`: test complete, cleaning up
567 check_and_cleanup_lustre
568 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true