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"
212 [ "$(facet_fstype ost1)" = "zfs" ] &&
213 skip "LU-2059: no local config for ZFS OSTs" && return
217 for i in $(seq $MDSCOUNT) ; do
221 # prepare for MDS failover
232 echo "Reintegrating OST"
235 start_ost 1 || return 2
237 for i in $(seq $MDSCOUNT) ; do
239 start_mdt $i || return $?
244 clients_recover_osts ost1
245 echo "Verify reintegration"
246 clients_up || return 1
249 run_test 2 "Second Failure Mode: MDS/OST `date`"
250 ###################################################
252 ############### Third Failure Mode ###############
255 echo "Verify Lustre filesystem is up and running"
256 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
259 for i in $(seq $MDSCOUNT) ; do
264 echo "Test Lustre stability after MDS failover"
268 echo "Failing 2 CLIENTS"
272 echo "Test Lustre stability after CLIENT failure"
276 echo "Reintegrating CLIENTS"
277 reintegrate_clients || return 1
279 clients_up || return 3
280 sleep 2 # give it a little time for fully recovered before next test
282 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
283 ###################################################
285 ############### Fourth Failure Mode ###############
287 echo "Fourth Failure Mode: OST/MDS `date`"
289 [ "$(facet_fstype ost1)" = "zfs" ] &&
290 skip "LU-2059: no local config for ZFS OSTs" && return
296 echo "Test Lustre stability after OST failure"
301 for i in $(seq $MDSCOUNT) ; do
305 # prepare for MDS failover
315 echo "Reintegrating OST"
320 for i in $(seq $MDSCOUNT) ; do
322 start_mdt $i || return $?
328 clients_recover_osts ost1
329 echo "Test Lustre stability after MDS failover"
330 clients_up || return 1
332 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
333 ###################################################
335 ############### Fifth Failure Mode ###############
337 [ $OSTCOUNT -lt 2 ] && skip_env "$OSTCOUNT < 2, not enough OSTs" && return 0
339 echo "Fifth Failure Mode: OST/OST `date`"
342 echo "Verify Lustre filesystem is up and running"
343 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
352 echo "Test Lustre stability after OST failure"
362 echo "Test Lustre stability after OST failure"
368 echo "Reintegrating OSTs"
374 clients_recover_osts ost1
375 clients_recover_osts ost2
380 clients_up || return 2
382 run_test 5 "Fifth Failure Mode: OST/OST `date`"
383 ###################################################
385 ############### Sixth Failure Mode ###############
387 echo "Sixth Failure Mode: OST/CLIENT `date`"
390 echo "Verify Lustre filesystem is up and running"
391 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
394 client_touch testfile || return 2
401 echo "Test Lustre stability after OST failure"
408 echo "Failing CLIENTs"
412 echo "Test Lustre stability after CLIENTs failure"
419 echo "Reintegrating OST/CLIENTs"
422 reintegrate_clients || return 1
425 wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20))
429 echo "Verifying mount"
430 [ -z "$(mounted_lustre_filesystems)" ] && return 3
433 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
434 ###################################################
437 ############### Seventh Failure Mode ###############
439 echo "Seventh Failure Mode: CLIENT/MDS `date`"
442 echo "Verify Lustre filesystem is up and running"
443 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
446 client_touch testfile || return 1
449 echo "Part 1: Failing CLIENT"
453 echo "Test Lustre stability after CLIENTs failure"
455 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
456 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
459 echo "Wait 1 minutes"
463 echo "Verify Lustre filesystem is up and running"
464 [ -z "$(mounted_lustre_filesystems)" ] && return 2
470 for i in $(seq $MDSCOUNT) ; do
474 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
475 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
478 echo "Reintegrating CLIENTs"
479 reintegrate_clients || return 2
483 echo "wait 1 minutes"
486 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
487 ###################################################
490 ############### Eighth Failure Mode ###############
492 echo "Eighth Failure Mode: CLIENT/OST `date`"
495 echo "Verify Lustre filesystem is up and running"
496 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
499 client_touch testfile
502 echo "Failing CLIENTs"
506 echo "Test Lustre stability after CLIENTs failure"
508 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
509 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
512 echo "Wait 1 minutes"
516 echo "Verify Lustre filesystem is up and running"
517 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
520 client_touch testfile
528 echo "Test Lustre stability after OST failure"
532 #non-failout hangs forever here
533 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
534 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
537 echo "Reintegrating CLIENTs/OST"
538 reintegrate_clients || return 3
542 clients_up || return 1
543 client_touch testfile2 || return 2
546 echo "Wait 1 minutes"
549 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
550 ###################################################
553 ############### Ninth Failure Mode ###############
558 echo "Verify Lustre filesystem is up and running"
559 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
562 client_touch testfile || return 1
565 echo "Failing CLIENTs"
569 echo "Test Lustre stability after CLIENTs failure"
571 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
572 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
575 echo "Wait 1 minutes"
579 echo "Verify Lustre filesystem is up and running"
580 client_up $LIVE_CLIENT || return 3
581 client_touch testfile || return 4
584 echo "Failing CLIENTs"
588 echo "Test Lustre stability after CLIENTs failure"
590 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
591 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
594 echo "Reintegrating CLIENTs/CLIENTs"
595 reintegrate_clients || return 7
599 echo "Wait 1 minutes"
602 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
603 ###################################################
605 ############### Tenth Failure Mode ###############
607 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
612 # prepare for MDS failover
622 echo "Reintegrating OST"
625 start_ost 1 || return 2
630 # prepare for MDS failover
635 start_mdt 1 || return $?
638 start_mdt 2 || return $?
642 clients_recover_osts ost1
643 echo "Verify reintegration"
644 clients_up || return 1
646 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
647 ###################################################
649 ############### Seventh Failure Mode ###############
651 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
652 echo "Verify Lustre filesystem is up and running"
653 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
659 echo "Test Lustre stability after MDS failover"
663 echo "Failing 2 CLIENTS"
667 echo "Test Lustre stability after CLIENT failure"
671 echo "Reintegrating CLIENTS"
672 reintegrate_clients || return 1
676 clients_up || return 3
677 sleep 2 # give it a little time for fully recovered before next test
679 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
680 ###################################################
683 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
684 echo "Verify Lustre filesystem is up and running"
685 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
696 echo "Failing 2 CLIENTS"
700 echo "Test Lustre stability after CLIENT failure"
704 echo "Reintegrating CLIENTS"
705 reintegrate_clients || return 1
707 clients_up || return 3
708 sleep 2 # give it a little time for fully recovered before next test
710 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
711 ###################################################
714 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
715 echo "Verify Lustre filesystem is up and running"
716 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
723 echo "Failing 2 CLIENTS"
727 echo "Test Lustre stability after CLIENT failure"
731 echo "Reintegrating CLIENTS"
732 reintegrate_clients || return 1
734 clients_up || return 3
735 sleep 2 # give it a little time for fully recovered before next test
739 clients_up || return 4
741 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
742 ###################################################
745 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
746 echo "Verify Lustre filesystem is up and running"
747 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
754 echo "Failing 2 CLIENTS"
758 echo "Test Lustre stability after CLIENT failure"
762 echo "Reintegrating CLIENTS"
763 reintegrate_clients || return 1
765 clients_up || return 3
766 sleep 2 # give it a little time for fully recovered before next test
770 clients_up || return 4
772 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
773 ###################################################
776 #Run availability after all failures
777 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
778 LOADTEST=${LOADTEST:-metadata-load.py}
779 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
781 run_test 15 "Running Availability for 6 hours..."
784 check_and_cleanup_lustre