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 "$OSTCOUNT < 2, not enough 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"
346 echo "Test Lustre stability after OST failure"
356 echo "Test Lustre stability after OST failure"
362 echo "Reintegrating OSTs"
368 clients_recover_osts ost1
369 clients_recover_osts ost2
374 clients_up || return 2
376 run_test 5 "Fifth Failure Mode: OST/OST `date`"
377 ###################################################
379 ############### Sixth Failure Mode ###############
381 echo "Sixth Failure Mode: OST/CLIENT `date`"
384 echo "Verify Lustre filesystem is up and running"
385 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
388 client_touch testfile || return 2
395 echo "Test Lustre stability after OST failure"
402 echo "Failing CLIENTs"
406 echo "Test Lustre stability after CLIENTs failure"
413 echo "Reintegrating OST/CLIENTs"
416 reintegrate_clients || return 1
419 wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20))
423 echo "Verifying mount"
424 [ -z "$(mounted_lustre_filesystems)" ] && return 3
427 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
428 ###################################################
431 ############### Seventh Failure Mode ###############
433 echo "Seventh Failure Mode: CLIENT/MDS `date`"
436 echo "Verify Lustre filesystem is up and running"
437 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
440 client_touch testfile || return 1
443 echo "Part 1: Failing CLIENT"
447 echo "Test Lustre stability after CLIENTs failure"
449 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
450 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
453 echo "Wait 1 minutes"
457 echo "Verify Lustre filesystem is up and running"
458 [ -z "$(mounted_lustre_filesystems)" ] && return 2
464 for i in $(seq $MDSCOUNT) ; do
468 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
469 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
472 echo "Reintegrating CLIENTs"
473 reintegrate_clients || return 2
477 echo "wait 1 minutes"
480 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
481 ###################################################
484 ############### Eighth Failure Mode ###############
486 echo "Eighth Failure Mode: CLIENT/OST `date`"
489 echo "Verify Lustre filesystem is up and running"
490 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
493 client_touch testfile
496 echo "Failing CLIENTs"
500 echo "Test Lustre stability after CLIENTs failure"
502 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
503 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
506 echo "Wait 1 minutes"
510 echo "Verify Lustre filesystem is up and running"
511 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
514 client_touch testfile
522 echo "Test Lustre stability after OST failure"
526 #non-failout hangs forever here
527 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
528 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
531 echo "Reintegrating CLIENTs/OST"
532 reintegrate_clients || return 3
536 clients_up || return 1
537 client_touch testfile2 || return 2
540 echo "Wait 1 minutes"
543 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
544 ###################################################
547 ############### Ninth Failure Mode ###############
552 echo "Verify Lustre filesystem is up and running"
553 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
556 client_touch testfile || return 1
559 echo "Failing CLIENTs"
563 echo "Test Lustre stability after CLIENTs failure"
565 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
566 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
569 echo "Wait 1 minutes"
573 echo "Verify Lustre filesystem is up and running"
574 client_up $LIVE_CLIENT || return 3
575 client_touch testfile || return 4
578 echo "Failing CLIENTs"
582 echo "Test Lustre stability after CLIENTs failure"
584 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
585 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
588 echo "Reintegrating CLIENTs/CLIENTs"
589 reintegrate_clients || return 7
593 echo "Wait 1 minutes"
596 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
597 ###################################################
599 ############### Tenth Failure Mode ###############
601 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
606 # prepare for MDS failover
616 echo "Reintegrating OST"
619 start_ost 1 || return 2
624 # prepare for MDS failover
629 start_mdt 1 || return $?
632 start_mdt 2 || return $?
636 clients_recover_osts ost1
637 echo "Verify reintegration"
638 clients_up || return 1
640 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
641 ###################################################
643 ############### Seventh Failure Mode ###############
645 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
646 echo "Verify Lustre filesystem is up and running"
647 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
653 echo "Test Lustre stability after MDS failover"
657 echo "Failing 2 CLIENTS"
661 echo "Test Lustre stability after CLIENT failure"
665 echo "Reintegrating CLIENTS"
666 reintegrate_clients || return 1
670 clients_up || return 3
671 sleep 2 # give it a little time for fully recovered before next test
673 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
674 ###################################################
677 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
678 echo "Verify Lustre filesystem is up and running"
679 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
690 echo "Failing 2 CLIENTS"
694 echo "Test Lustre stability after CLIENT failure"
698 echo "Reintegrating CLIENTS"
699 reintegrate_clients || return 1
701 clients_up || return 3
702 sleep 2 # give it a little time for fully recovered before next test
704 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
705 ###################################################
708 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
709 echo "Verify Lustre filesystem is up and running"
710 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
717 echo "Failing 2 CLIENTS"
721 echo "Test Lustre stability after CLIENT failure"
725 echo "Reintegrating CLIENTS"
726 reintegrate_clients || return 1
728 clients_up || return 3
729 sleep 2 # give it a little time for fully recovered before next test
733 clients_up || return 4
735 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
736 ###################################################
739 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
740 echo "Verify Lustre filesystem is up and running"
741 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
748 echo "Failing 2 CLIENTS"
752 echo "Test Lustre stability after CLIENT failure"
756 echo "Reintegrating CLIENTS"
757 reintegrate_clients || return 1
759 clients_up || return 3
760 sleep 2 # give it a little time for fully recovered before next test
764 clients_up || return 4
766 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
767 ###################################################
770 #Run availability after all failures
771 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
772 LOADTEST=${LOADTEST:-metadata-load.py}
773 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
775 run_test 15 "Running Availability for 6 hours..."
778 check_and_cleanup_lustre