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
176 [ "$(facet_fstype mds2)" = "zfs" ] &&
177 skip "LU-2059: no local config for ZFS MDTs" && return
184 # prepare for MDS failover
194 echo "Reintegrating MDS2"
197 start_mdt 2 || return 2
200 start_mdt 1 || return $?
204 echo "Verify reintegration"
205 clients_up || return 1
207 run_test 1 "MDS/MDS failure"
208 ###################################################
210 ############### Second Failure Mode ###############
212 echo "Verify Lustre filesystem is up and running"
213 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
215 [ "$(facet_fstype ost1)" = "zfs" ] &&
216 skip "LU-2059: no local config for ZFS OSTs" && return
220 for i in $(seq $MDSCOUNT) ; do
224 # prepare for MDS failover
235 echo "Reintegrating OST"
238 start_ost 1 || return 2
240 for i in $(seq $MDSCOUNT) ; do
242 start_mdt $i || return $?
247 clients_recover_osts ost1
248 echo "Verify reintegration"
249 clients_up || return 1
252 run_test 2 "Second Failure Mode: MDS/OST `date`"
253 ###################################################
255 ############### Third Failure Mode ###############
258 echo "Verify Lustre filesystem is up and running"
259 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
262 for i in $(seq $MDSCOUNT) ; do
267 echo "Test Lustre stability after MDS failover"
271 echo "Failing 2 CLIENTS"
275 echo "Test Lustre stability after CLIENT failure"
279 echo "Reintegrating CLIENTS"
280 reintegrate_clients || return 1
282 clients_up || return 3
283 sleep 2 # give it a little time for fully recovered before next test
285 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
286 ###################################################
288 ############### Fourth Failure Mode ###############
290 echo "Fourth Failure Mode: OST/MDS `date`"
292 [ "$(facet_fstype ost1)" = "zfs" ] &&
293 skip "LU-2059: no local config for ZFS OSTs" && return
299 echo "Test Lustre stability after OST failure"
304 for i in $(seq $MDSCOUNT) ; do
308 # prepare for MDS failover
318 echo "Reintegrating OST"
323 for i in $(seq $MDSCOUNT) ; do
325 start_mdt $i || return $?
331 clients_recover_osts ost1
332 echo "Test Lustre stability after MDS failover"
333 clients_up || return 1
335 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
336 ###################################################
338 ############### Fifth Failure Mode ###############
340 [ $OSTCOUNT -lt 2 ] && skip_env "$OSTCOUNT < 2, not enough OSTs" && return 0
342 echo "Fifth Failure Mode: OST/OST `date`"
345 echo "Verify Lustre filesystem is up and running"
346 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
355 echo "Test Lustre stability after OST failure"
365 echo "Test Lustre stability after OST failure"
371 echo "Reintegrating OSTs"
377 clients_recover_osts ost1
378 clients_recover_osts ost2
383 clients_up || return 2
385 run_test 5 "Fifth Failure Mode: OST/OST `date`"
386 ###################################################
388 ############### Sixth Failure Mode ###############
390 echo "Sixth Failure Mode: OST/CLIENT `date`"
393 echo "Verify Lustre filesystem is up and running"
394 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
397 client_touch testfile || return 2
404 echo "Test Lustre stability after OST failure"
411 echo "Failing CLIENTs"
415 echo "Test Lustre stability after CLIENTs failure"
422 echo "Reintegrating OST/CLIENTs"
425 reintegrate_clients || return 1
428 wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20))
432 echo "Verifying mount"
433 [ -z "$(mounted_lustre_filesystems)" ] && return 3
436 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
437 ###################################################
440 ############### Seventh Failure Mode ###############
442 echo "Seventh Failure Mode: CLIENT/MDS `date`"
445 echo "Verify Lustre filesystem is up and running"
446 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
449 client_touch testfile || return 1
452 echo "Part 1: Failing CLIENT"
456 echo "Test Lustre stability after CLIENTs failure"
458 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
459 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
462 echo "Wait 1 minutes"
466 echo "Verify Lustre filesystem is up and running"
467 [ -z "$(mounted_lustre_filesystems)" ] && return 2
473 for i in $(seq $MDSCOUNT) ; do
477 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
478 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
481 echo "Reintegrating CLIENTs"
482 reintegrate_clients || return 2
486 echo "wait 1 minutes"
489 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
490 ###################################################
493 ############### Eighth Failure Mode ###############
495 echo "Eighth Failure Mode: CLIENT/OST `date`"
498 echo "Verify Lustre filesystem is up and running"
499 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
502 client_touch testfile
505 echo "Failing CLIENTs"
509 echo "Test Lustre stability after CLIENTs failure"
511 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
512 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
515 echo "Wait 1 minutes"
519 echo "Verify Lustre filesystem is up and running"
520 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
523 client_touch testfile
531 echo "Test Lustre stability after OST failure"
535 #non-failout hangs forever here
536 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
537 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
540 echo "Reintegrating CLIENTs/OST"
541 reintegrate_clients || return 3
545 clients_up || return 1
546 client_touch testfile2 || return 2
549 echo "Wait 1 minutes"
552 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
553 ###################################################
556 ############### Ninth Failure Mode ###############
561 echo "Verify Lustre filesystem is up and running"
562 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
565 client_touch testfile || return 1
568 echo "Failing CLIENTs"
572 echo "Test Lustre stability after CLIENTs failure"
574 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
575 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
578 echo "Wait 1 minutes"
582 echo "Verify Lustre filesystem is up and running"
583 client_up $LIVE_CLIENT || return 3
584 client_touch testfile || return 4
587 echo "Failing CLIENTs"
591 echo "Test Lustre stability after CLIENTs failure"
593 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
594 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
597 echo "Reintegrating CLIENTs/CLIENTs"
598 reintegrate_clients || return 7
602 echo "Wait 1 minutes"
605 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
606 ###################################################
608 ############### Tenth Failure Mode ###############
610 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
612 [ "$(facet_fstype ost1)" = "zfs" ] &&
613 skip "LU-2059: no local config for ZFS OSTs" && return
618 # prepare for MDS failover
628 echo "Reintegrating OST"
631 start_ost 1 || return 2
636 # prepare for MDS failover
641 start_mdt 1 || return $?
644 start_mdt 2 || return $?
648 clients_recover_osts ost1
649 echo "Verify reintegration"
650 clients_up || return 1
652 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
653 ###################################################
655 ############### Seventh Failure Mode ###############
657 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
658 echo "Verify Lustre filesystem is up and running"
659 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
665 echo "Test Lustre stability after MDS failover"
669 echo "Failing 2 CLIENTS"
673 echo "Test Lustre stability after CLIENT failure"
677 echo "Reintegrating CLIENTS"
678 reintegrate_clients || return 1
682 clients_up || return 3
683 sleep 2 # give it a little time for fully recovered before next test
685 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
686 ###################################################
689 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
690 echo "Verify Lustre filesystem is up and running"
691 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
702 echo "Failing 2 CLIENTS"
706 echo "Test Lustre stability after CLIENT failure"
710 echo "Reintegrating CLIENTS"
711 reintegrate_clients || return 1
713 clients_up || return 3
714 sleep 2 # give it a little time for fully recovered before next test
716 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
717 ###################################################
720 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
721 echo "Verify Lustre filesystem is up and running"
722 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
729 echo "Failing 2 CLIENTS"
733 echo "Test Lustre stability after CLIENT failure"
737 echo "Reintegrating CLIENTS"
738 reintegrate_clients || return 1
740 clients_up || return 3
741 sleep 2 # give it a little time for fully recovered before next test
745 clients_up || return 4
747 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
748 ###################################################
751 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
752 echo "Verify Lustre filesystem is up and running"
753 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
760 echo "Failing 2 CLIENTS"
764 echo "Test Lustre stability after CLIENT failure"
768 echo "Reintegrating CLIENTS"
769 reintegrate_clients || return 1
771 clients_up || return 3
772 sleep 2 # give it a little time for fully recovered before next test
776 clients_up || return 4
778 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
779 ###################################################
782 #Run availability after all failures
783 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
784 LOADTEST=${LOADTEST:-metadata-load.py}
785 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
787 run_test 15 "Running Availability for 6 hours..."
790 check_and_cleanup_lustre