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="10 $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}
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
116 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
117 echo $DOWN_CLIENTS | grep -q $c && continue
118 $PDSH $c touch $TESTDIR/${c}_$file || return 1
124 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
125 $PDSH $c rm $TESTDIR/${c}_$file
130 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
131 echo "$c mkdir $TESTDIR/$c"
132 $PDSH $c "mkdir $TESTDIR/$c && ls -l $TESTDIR/$c"
137 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
138 echo "rmdir $TESTDIR/$c"
139 $PDSH $LIVE_CLIENT "rmdir $TESTDIR/$c"
143 clients_recover_osts() {
145 # do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
148 check_and_setup_lustre
153 # 9 Different Failure Modes Combinations
154 echo "Starting Test 17 at `date`"
159 for i in $(seq $OSTCOUNT) ; do
164 run_test 0 "Fail all nodes, independently"
166 ############### First Failure Mode ###############
168 echo "Don't do a MDS - MDS Failure Case"
169 echo "This makes no sense"
171 run_test 1 "MDS/MDS failure"
172 ###################################################
174 ############### Second Failure Mode ###############
176 echo "Verify Lustre filesystem is up and running"
177 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
179 [ "$(facet_fstype ost1)" = "zfs" ] &&
180 skip "LU-2059: no local config for ZFS OSTs" && return
184 shutdown_facet $SINGLEMDS
185 reboot_facet $SINGLEMDS
187 # prepare for MDS failover
188 change_active $SINGLEMDS
189 reboot_facet $SINGLEMDS
197 echo "Reintegrating OST"
200 start_ost 1 || return 2
202 wait_for_facet $SINGLEMDS
203 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || return $?
207 clients_recover_osts ost1
208 echo "Verify reintegration"
209 clients_up || return 1
212 run_test 2 "Second Failure Mode: MDS/OST `date`"
213 ###################################################
216 ############### Third Failure Mode ###############
219 echo "Verify Lustre filesystem is up and running"
220 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
226 echo "Test Lustre stability after MDS failover"
230 echo "Failing 2 CLIENTS"
234 echo "Test Lustre stability after CLIENT failure"
238 echo "Reintegrating CLIENTS"
239 reintegrate_clients || return 1
241 clients_up || return 3
242 sleep 2 # give it a little time for fully recovered before next test
244 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
245 ###################################################
247 ############### Fourth Failure Mode ###############
249 echo "Fourth Failure Mode: OST/MDS `date`"
251 [ "$(facet_fstype ost1)" = "zfs" ] &&
252 skip "LU-2059: no local config for ZFS OSTs" && return
258 echo "Test Lustre stability after OST failure"
264 shutdown_facet $SINGLEMDS
265 reboot_facet $SINGLEMDS
267 # prepare for MDS failover
268 change_active $SINGLEMDS
269 reboot_facet $SINGLEMDS
276 echo "Reintegrating OST"
281 wait_for_facet $SINGLEMDS
282 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS
287 clients_recover_osts ost1
288 echo "Test Lustre stability after MDS failover"
289 clients_up || return 1
291 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
292 ###################################################
294 ############### Fifth Failure Mode ###############
296 [ $OSTCOUNT -lt 2 ] && skip_env "$OSTCOUNT < 2, not enough OSTs" && return 0
298 echo "Fifth Failure Mode: OST/OST `date`"
301 echo "Verify Lustre filesystem is up and running"
302 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
311 echo "Test Lustre stability after OST failure"
321 echo "Test Lustre stability after OST failure"
327 echo "Reintegrating OSTs"
333 clients_recover_osts ost1
334 clients_recover_osts ost2
339 clients_up || return 2
341 run_test 5 "Fifth Failure Mode: OST/OST `date`"
342 ###################################################
344 ############### Sixth Failure Mode ###############
346 echo "Sixth Failure Mode: OST/CLIENT `date`"
349 echo "Verify Lustre filesystem is up and running"
350 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
353 client_touch testfile || return 2
360 echo "Test Lustre stability after OST failure"
367 echo "Failing CLIENTs"
371 echo "Test Lustre stability after CLIENTs failure"
378 echo "Reintegrating OST/CLIENTs"
381 reintegrate_clients || return 1
384 wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20))
388 echo "Verifying mount"
389 [ -z "$(mounted_lustre_filesystems)" ] && return 3
392 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
393 ###################################################
396 ############### Seventh Failure Mode ###############
398 echo "Seventh Failure Mode: CLIENT/MDS `date`"
401 echo "Verify Lustre filesystem is up and running"
402 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
405 client_touch testfile || return 1
408 echo "Part 1: Failing CLIENT"
412 echo "Test Lustre stability after CLIENTs failure"
414 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
415 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
418 echo "Wait 1 minutes"
422 echo "Verify Lustre filesystem is up and running"
423 [ -z "$(mounted_lustre_filesystems)" ] && return 2
431 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
432 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
435 echo "Reintegrating CLIENTs"
436 reintegrate_clients || return 2
440 echo "wait 1 minutes"
443 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
444 ###################################################
447 ############### Eighth Failure Mode ###############
449 echo "Eighth Failure Mode: CLIENT/OST `date`"
452 echo "Verify Lustre filesystem is up and running"
453 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
456 client_touch testfile
459 echo "Failing CLIENTs"
463 echo "Test Lustre stability after CLIENTs failure"
465 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
466 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
469 echo "Wait 1 minutes"
473 echo "Verify Lustre filesystem is up and running"
474 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
477 client_touch testfile
485 echo "Test Lustre stability after OST failure"
489 #non-failout hangs forever here
490 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
491 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
494 echo "Reintegrating CLIENTs/OST"
495 reintegrate_clients || return 3
499 clients_up || return 1
500 client_touch testfile2 || return 2
503 echo "Wait 1 minutes"
506 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
507 ###################################################
510 ############### Ninth Failure Mode ###############
515 echo "Verify Lustre filesystem is up and running"
516 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
519 client_touch testfile || return 1
522 echo "Failing CLIENTs"
526 echo "Test Lustre stability after CLIENTs failure"
528 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
529 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
532 echo "Wait 1 minutes"
536 echo "Verify Lustre filesystem is up and running"
537 client_up $LIVE_CLIENT || return 3
538 client_touch testfile || return 4
541 echo "Failing CLIENTs"
545 echo "Test Lustre stability after CLIENTs failure"
547 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
548 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
551 echo "Reintegrating CLIENTs/CLIENTs"
552 reintegrate_clients || return 7
556 echo "Wait 1 minutes"
559 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
560 ###################################################
563 #Run availability after all failures
564 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
565 LOADTEST=${LOADTEST:-metadata-load.py}
566 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
568 run_test 10 "Running Availability for 6 hours..."
571 check_and_cleanup_lustre