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"
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`"
293 echo "Test Lustre stability after OST failure"
298 for i in $(seq $MDSCOUNT) ; do
302 # prepare for MDS failover
312 echo "Reintegrating OST"
317 for i in $(seq $MDSCOUNT) ; do
319 start_mdt $i || return $?
325 clients_recover_osts ost1
326 echo "Test Lustre stability after MDS failover"
327 clients_up || return 1
329 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
330 ###################################################
332 ############### Fifth Failure Mode ###############
334 [ $OSTCOUNT -lt 2 ] && skip_env "$OSTCOUNT < 2, not enough OSTs" && return 0
336 echo "Fifth Failure Mode: OST/OST `date`"
339 echo "Verify Lustre filesystem is up and running"
340 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
349 echo "Test Lustre stability after OST failure"
359 echo "Test Lustre stability after OST failure"
365 echo "Reintegrating OSTs"
371 clients_recover_osts ost1
372 clients_recover_osts ost2
377 clients_up || return 2
379 run_test 5 "Fifth Failure Mode: OST/OST `date`"
380 ###################################################
382 ############### Sixth Failure Mode ###############
384 echo "Sixth Failure Mode: OST/CLIENT `date`"
387 echo "Verify Lustre filesystem is up and running"
388 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
391 client_touch testfile || return 2
398 echo "Test Lustre stability after OST failure"
405 echo "Failing CLIENTs"
409 echo "Test Lustre stability after CLIENTs failure"
416 echo "Reintegrating OST/CLIENTs"
419 reintegrate_clients || return 1
422 wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20))
426 echo "Verifying mount"
427 [ -z "$(mounted_lustre_filesystems)" ] && return 3
430 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
431 ###################################################
434 ############### Seventh Failure Mode ###############
436 echo "Seventh Failure Mode: CLIENT/MDS `date`"
439 echo "Verify Lustre filesystem is up and running"
440 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
443 client_touch testfile || return 1
446 echo "Part 1: Failing CLIENT"
450 echo "Test Lustre stability after CLIENTs failure"
452 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
453 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
456 echo "Wait 1 minutes"
460 echo "Verify Lustre filesystem is up and running"
461 [ -z "$(mounted_lustre_filesystems)" ] && return 2
467 for i in $(seq $MDSCOUNT) ; do
471 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
472 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
475 echo "Reintegrating CLIENTs"
476 reintegrate_clients || return 2
480 echo "wait 1 minutes"
483 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
484 ###################################################
487 ############### Eighth Failure Mode ###############
489 echo "Eighth Failure Mode: CLIENT/OST `date`"
492 echo "Verify Lustre filesystem is up and running"
493 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
496 client_touch testfile
499 echo "Failing CLIENTs"
503 echo "Test Lustre stability after CLIENTs failure"
505 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
506 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
509 echo "Wait 1 minutes"
513 echo "Verify Lustre filesystem is up and running"
514 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
517 client_touch testfile
525 echo "Test Lustre stability after OST failure"
529 #non-failout hangs forever here
530 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
531 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
534 echo "Reintegrating CLIENTs/OST"
535 reintegrate_clients || return 3
539 clients_up || return 1
540 client_touch testfile2 || return 2
543 echo "Wait 1 minutes"
546 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
547 ###################################################
550 ############### Ninth Failure Mode ###############
555 echo "Verify Lustre filesystem is up and running"
556 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
559 client_touch testfile || return 1
562 echo "Failing CLIENTs"
566 echo "Test Lustre stability after CLIENTs failure"
568 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
569 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
572 echo "Wait 1 minutes"
576 echo "Verify Lustre filesystem is up and running"
577 client_up $LIVE_CLIENT || return 3
578 client_touch testfile || return 4
581 echo "Failing CLIENTs"
585 echo "Test Lustre stability after CLIENTs failure"
587 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
588 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
591 echo "Reintegrating CLIENTs/CLIENTs"
592 reintegrate_clients || return 7
596 echo "Wait 1 minutes"
599 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
600 ###################################################
602 ############### Tenth Failure Mode ###############
604 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
609 # prepare for MDS failover
619 echo "Reintegrating OST"
622 start_ost 1 || return 2
627 # prepare for MDS failover
632 start_mdt 1 || return $?
635 start_mdt 2 || return $?
639 clients_recover_osts ost1
640 echo "Verify reintegration"
641 clients_up || return 1
643 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
644 ###################################################
646 ############### Seventh Failure Mode ###############
648 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
649 echo "Verify Lustre filesystem is up and running"
650 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
656 echo "Test Lustre stability after MDS failover"
660 echo "Failing 2 CLIENTS"
664 echo "Test Lustre stability after CLIENT failure"
668 echo "Reintegrating CLIENTS"
669 reintegrate_clients || return 1
673 clients_up || return 3
674 sleep 2 # give it a little time for fully recovered before next test
676 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
677 ###################################################
680 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
681 echo "Verify Lustre filesystem is up and running"
682 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
693 echo "Failing 2 CLIENTS"
697 echo "Test Lustre stability after CLIENT failure"
701 echo "Reintegrating CLIENTS"
702 reintegrate_clients || return 1
704 clients_up || return 3
705 sleep 2 # give it a little time for fully recovered before next test
707 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
708 ###################################################
711 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
712 echo "Verify Lustre filesystem is up and running"
713 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
720 echo "Failing 2 CLIENTS"
724 echo "Test Lustre stability after CLIENT failure"
728 echo "Reintegrating CLIENTS"
729 reintegrate_clients || return 1
731 clients_up || return 3
732 sleep 2 # give it a little time for fully recovered before next test
736 clients_up || return 4
738 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
739 ###################################################
742 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
743 echo "Verify Lustre filesystem is up and running"
744 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
751 echo "Failing 2 CLIENTS"
755 echo "Test Lustre stability after CLIENT failure"
759 echo "Reintegrating CLIENTS"
760 reintegrate_clients || return 1
762 clients_up || return 3
763 sleep 2 # give it a little time for fully recovered before next test
767 clients_up || return 4
769 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
770 ###################################################
773 #Run availability after all failures
774 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
775 LOADTEST=${LOADTEST:-metadata-load.py}
776 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
778 run_test 15 "Running Availability for 6 hours..."
781 check_and_cleanup_lustre