2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:shiftwidth=4:softtabstop=4:tabstop=4:
5 # Test multiple failures, AKA Test 17
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 . $LUSTRE/tests/test-framework.sh
14 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 ALWAYS_EXCEPT="15 $INSANITY_EXCEPT"
19 if [ "$FAILURE_MODE" = "HARD" ]; then
20 skip_env "$TESTSUITE: is not functional with FAILURE_MODE = HARD, " \
21 "please use recovery-double-scale, bz20407"
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
28 CLEANUP=${CLEANUP:-""}
32 SINGLECLIENT=${SINGLECLIENT:-$HOSTNAME}
33 LIVE_CLIENT=${LIVE_CLIENT:-$SINGLECLIENT}
34 FAIL_CLIENTS=${FAIL_CLIENTS:-$RCLIENTS}
36 assert_env mds_HOST MDSCOUNT
37 assert_env ost_HOST OSTCOUNT
38 assert_env LIVE_CLIENT FSNAME
40 require_dsh_mds || exit 0
41 require_dsh_ost || exit 0
43 # FAIL_CLIENTS list should not contain the LIVE_CLIENT
44 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
47 TESTDIR=$DIR/d0.$TESTSUITE
50 # fail clients round robin
52 # list of failable clients
53 FAIL_LIST=($FAIL_CLIENTS)
54 FAIL_NUM=${#FAIL_LIST[*]}
57 DOWN_NUM=0 # number of nodes currently down
59 # set next client to fail
61 FAIL_CLIENT=${FAIL_LIST[$FAIL_NEXT]}
62 FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
63 echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
69 log "Request fail clients: $num, to fail: $FAIL_NUM, failed: $DOWN_NUM"
70 if [ -z "$num" ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
71 num=$((FAIL_NUM - DOWN_NUM))
74 if [ -z "$num" ] || [ "$num" -le 0 ]; then
75 log "No clients failed!"
81 for i in `seq $num`; do
84 DOWN_CLIENTS="$DOWN_CLIENTS $client"
85 shutdown_client $client
88 echo "down clients: $DOWN_CLIENTS"
90 for client in $DOWN_CLIENTS; do
93 DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
97 reintegrate_clients() {
98 for client in $DOWN_CLIENTS; do
100 echo "Restarting $client"
101 zconf_mount $client $MOUNT || return 1
109 start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
113 start mds$1 $(mdsdevname $1) $MDS_MOUNT_OPTS
120 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
121 echo $DOWN_CLIENTS | grep -q $c && continue
122 $PDSH $c touch $TESTDIR/${c}_$file || return 1
128 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
129 $PDSH $c rm $TESTDIR/${c}_$file
134 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
135 echo "$c mkdir $TESTDIR/$c"
136 $PDSH $c "mkdir $TESTDIR/$c && ls -l $TESTDIR/$c"
141 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
142 echo "rmdir $TESTDIR/$c"
143 $PDSH $LIVE_CLIENT "rmdir $TESTDIR/$c"
147 clients_recover_osts() {
149 # do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
152 check_and_setup_lustre
157 # 9 Different Failure Modes Combinations
158 echo "Starting Test 17 at `date`"
161 for i in $(seq $MDSCOUNT) ; do
165 for i in $(seq $OSTCOUNT) ; do
170 run_test 0 "Fail all nodes, independently"
172 ############### First Failure Mode ###############
174 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
181 # prepare for MDS failover
191 echo "Reintegrating MDS2"
194 start_mdt 2 || return 2
197 start_mdt 1 || return $?
201 echo "Verify reintegration"
202 clients_up || return 1
204 run_test 1 "MDS/MDS failure"
205 ###################################################
207 ############### Second Failure Mode ###############
209 echo "Verify Lustre filesystem is up and running"
210 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
214 for i in $(seq $MDSCOUNT) ; do
218 # prepare for MDS failover
229 echo "Reintegrating OST"
232 start_ost 1 || return 2
234 for i in $(seq $MDSCOUNT) ; do
236 start_mdt $i || return $?
241 clients_recover_osts ost1
242 echo "Verify reintegration"
243 clients_up || return 1
246 run_test 2 "Second Failure Mode: MDS/OST `date`"
247 ###################################################
249 ############### Third Failure Mode ###############
252 echo "Verify Lustre filesystem is up and running"
253 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
256 for i in $(seq $MDSCOUNT) ; do
261 echo "Test Lustre stability after MDS failover"
265 echo "Failing 2 CLIENTS"
269 echo "Test Lustre stability after CLIENT failure"
273 echo "Reintegrating CLIENTS"
274 reintegrate_clients || return 1
276 clients_up || return 3
277 sleep 2 # give it a little time for fully recovered before next test
279 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
280 ###################################################
282 ############### Fourth Failure Mode ###############
284 echo "Fourth Failure Mode: OST/MDS `date`"
290 echo "Test Lustre stability after OST failure"
295 for i in $(seq $MDSCOUNT) ; do
299 # prepare for MDS failover
309 echo "Reintegrating OST"
314 for i in $(seq $MDSCOUNT) ; do
316 start_mdt $i || return $?
322 clients_recover_osts ost1
323 echo "Test Lustre stability after MDS failover"
324 clients_up || return 1
326 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
327 ###################################################
329 ############### Fifth Failure Mode ###############
331 [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return 0
333 echo "Fifth Failure Mode: OST/OST `date`"
336 echo "Verify Lustre filesystem is up and running"
337 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
345 echo "Test Lustre stability after OST failure"
355 echo "Test Lustre stability after OST failure"
361 echo "Reintegrating OSTs"
367 clients_recover_osts ost1
368 clients_recover_osts ost2
373 clients_up || return 2
375 run_test 5 "Fifth Failure Mode: OST/OST `date`"
376 ###################################################
378 ############### Sixth Failure Mode ###############
380 echo "Sixth Failure Mode: OST/CLIENT `date`"
383 echo "Verify Lustre filesystem is up and running"
384 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
387 client_touch testfile || return 2
394 echo "Test Lustre stability after OST failure"
401 echo "Failing CLIENTs"
405 echo "Test Lustre stability after CLIENTs failure"
412 echo "Reintegrating OST/CLIENTs"
415 reintegrate_clients || return 1
418 wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20))
422 echo "Verifying mount"
423 [ -z "$(mounted_lustre_filesystems)" ] && return 3
426 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
427 ###################################################
430 ############### Seventh Failure Mode ###############
432 echo "Seventh Failure Mode: CLIENT/MDS `date`"
435 echo "Verify Lustre filesystem is up and running"
436 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
439 client_touch testfile || return 1
442 echo "Part 1: Failing CLIENT"
446 echo "Test Lustre stability after CLIENTs failure"
448 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
449 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
452 echo "Wait 1 minutes"
456 echo "Verify Lustre filesystem is up and running"
457 [ -z "$(mounted_lustre_filesystems)" ] && return 2
463 for i in $(seq $MDSCOUNT) ; do
467 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
468 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
471 echo "Reintegrating CLIENTs"
472 reintegrate_clients || return 2
476 echo "wait 1 minutes"
479 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
480 ###################################################
483 ############### Eighth Failure Mode ###############
485 echo "Eighth Failure Mode: CLIENT/OST `date`"
488 echo "Verify Lustre filesystem is up and running"
489 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
492 client_touch testfile
495 echo "Failing CLIENTs"
499 echo "Test Lustre stability after CLIENTs failure"
501 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
502 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
505 echo "Wait 1 minutes"
509 echo "Verify Lustre filesystem is up and running"
510 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
513 client_touch testfile
521 echo "Test Lustre stability after OST failure"
525 #non-failout hangs forever here
526 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
527 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
530 echo "Reintegrating CLIENTs/OST"
531 reintegrate_clients || return 3
535 clients_up || return 1
536 client_touch testfile2 || return 2
539 echo "Wait 1 minutes"
542 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
543 ###################################################
546 ############### Ninth Failure Mode ###############
551 echo "Verify Lustre filesystem is up and running"
552 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
555 client_touch testfile || return 1
558 echo "Failing CLIENTs"
562 echo "Test Lustre stability after CLIENTs failure"
564 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
565 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
568 echo "Wait 1 minutes"
572 echo "Verify Lustre filesystem is up and running"
573 client_up $LIVE_CLIENT || return 3
574 client_touch testfile || return 4
577 echo "Failing CLIENTs"
581 echo "Test Lustre stability after CLIENTs failure"
583 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
584 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
587 echo "Reintegrating CLIENTs/CLIENTs"
588 reintegrate_clients || return 7
592 echo "Wait 1 minutes"
595 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
596 ###################################################
598 ############### Tenth Failure Mode ###############
600 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
605 # prepare for MDS failover
615 echo "Reintegrating OST"
618 start_ost 1 || return 2
623 # prepare for MDS failover
628 start_mdt 1 || return $?
631 start_mdt 2 || return $?
635 clients_recover_osts ost1
636 echo "Verify reintegration"
637 clients_up || return 1
639 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
640 ###################################################
642 ############### Seventh Failure Mode ###############
644 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
645 echo "Verify Lustre filesystem is up and running"
646 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
652 echo "Test Lustre stability after MDS failover"
656 echo "Failing 2 CLIENTS"
660 echo "Test Lustre stability after CLIENT failure"
664 echo "Reintegrating CLIENTS"
665 reintegrate_clients || return 1
669 clients_up || return 3
670 sleep 2 # give it a little time for fully recovered before next test
672 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
673 ###################################################
676 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
677 echo "Verify Lustre filesystem is up and running"
678 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
689 echo "Failing 2 CLIENTS"
693 echo "Test Lustre stability after CLIENT failure"
697 echo "Reintegrating CLIENTS"
698 reintegrate_clients || return 1
700 clients_up || return 3
701 sleep 2 # give it a little time for fully recovered before next test
703 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
704 ###################################################
707 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
708 echo "Verify Lustre filesystem is up and running"
709 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
716 echo "Failing 2 CLIENTS"
720 echo "Test Lustre stability after CLIENT failure"
724 echo "Reintegrating CLIENTS"
725 reintegrate_clients || return 1
727 clients_up || return 3
728 sleep 2 # give it a little time for fully recovered before next test
732 clients_up || return 4
734 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
735 ###################################################
738 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
739 echo "Verify Lustre filesystem is up and running"
740 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
747 echo "Failing 2 CLIENTS"
751 echo "Test Lustre stability after CLIENT failure"
755 echo "Reintegrating CLIENTS"
756 reintegrate_clients || return 1
758 clients_up || return 3
759 sleep 2 # give it a little time for fully recovered before next test
763 clients_up || return 4
765 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
766 ###################################################
769 #Run availability after all failures
770 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
771 LOADTEST=${LOADTEST:-metadata-load.py}
772 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
774 run_test 15 "Running Availability for 6 hours..."
777 check_and_cleanup_lustre