2 # Test multiple failures, AKA Test 17
6 LUSTRE=${LUSTRE:-`dirname $0`/..}
7 . $LUSTRE/tests/test-framework.sh
11 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13 ALWAYS_EXCEPT="10 $INSANITY_EXCEPT"
15 if [ "$FAILURE_MODE" = "HARD" ]; then
16 mixed_ost_devs && CONFIG_EXCEPTIONS="0 2 4 5 6 8" && \
17 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. " && \
18 echo "Except the tests: $CONFIG_EXCEPTIONS" && \
19 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
23 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
26 CLEANUP=${CLEANUP:-""}
30 SINGLECLIENT=${SINGLECLIENT:-$HOSTNAME}
31 LIVE_CLIENT=${LIVE_CLIENT:-$SINGLECLIENT}
32 FAIL_CLIENTS=${FAIL_CLIENTS:-$RCLIENTS}
34 assert_env mds_HOST MDS_MKFS_OPTS
35 assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
36 assert_env LIVE_CLIENT FSNAME
38 # FAIL_CLIENTS list should not contain the LIVE_CLIENT
39 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
41 # This can be a regexp, to allow more clients
42 CLIENTS=${CLIENTS:-"`comma_list $LIVE_CLIENT $FAIL_CLIENTS`"}
47 # fail clients round robin
49 # list of failable clients
50 FAIL_LIST=($FAIL_CLIENTS)
51 FAIL_NUM=${#FAIL_LIST[*]}
54 DOWN_NUM=0 # number of nodes currently down
56 # set next client to fail
58 FAIL_CLIENT=${FAIL_LIST[$FAIL_NEXT]}
59 FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
60 echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
65 if [ "$FAILURE_MODE" = HARD ]; then
67 while ping -w 3 -c 1 $client > /dev/null 2>&1; do
68 echo "waiting for node $client to fail"
71 elif [ "$FAILURE_MODE" = SOFT ]; then
72 zconf_umount $client $MOUNT -f
78 if [ "$FAILURE_MODE" = HARD ]; then
86 log "Request clients to fail: ${num}. Num of clients to fail: ${FAIL_NUM}, already failed: $DOWN_NUM"
87 if [ -z "$num" ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
88 num=$((FAIL_NUM - DOWN_NUM))
91 if [ -z "$num" ] || [ "$num" -le 0 ]; then
92 log "No clients failed!"
98 for i in `seq $num`; do
101 DOWN_CLIENTS="$DOWN_CLIENTS $client"
102 shutdown_client $client
105 echo "down clients: $DOWN_CLIENTS"
107 for client in $DOWN_CLIENTS; do
110 DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
114 reintegrate_clients() {
115 for client in $DOWN_CLIENTS; do
116 wait_for_host $client
117 echo "Restarting $client"
118 zconf_mount $client $MOUNT || return 1
125 start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
132 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
133 if echo $DOWN_CLIENTS | grep -q $c; then continue; fi
134 $PDSH $c touch $MOUNT/${c}_$file || return 1
140 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
141 $PDSH $c rm $MOUNT/${c}_$file
146 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
147 echo "$c mkdir $MOUNT/$c"
148 $PDSH $c "mkdir $MOUNT/$c"
149 $PDSH $c "ls -l $MOUNT/$c"
154 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
155 echo "rmdir $MOUNT/$c"
156 $PDSH $LIVE_CLIENT "rmdir $MOUNT/$c"
160 clients_recover_osts() {
162 # do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
165 cleanup_and_setup_lustre
167 # 9 Different Failure Modes Combinations
168 echo "Starting Test 17 at `date`"
171 facet_failover $SINGLEMDS
172 echo "Waiting for df pid: $DFPID"
173 wait $DFPID || { echo "df returned $?" && return 1; }
175 for i in $(seq $OSTCOUNT) ; do
176 facet_failover ost$i || return 4
177 echo "Waiting for df pid: $DFPID"
178 wait $DFPID || { echo "df returned $?" && return 3; }
182 run_test 0 "Fail all nodes, independently"
184 ############### First Failure Mode ###############
186 echo "Don't do a MDS - MDS Failure Case"
187 echo "This makes no sense"
189 run_test 1 "MDS/MDS failure"
190 ###################################################
192 ############### Second Failure Mode ###############
194 echo "Verify Lustre filesystem is up and running"
195 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
199 shutdown_facet $SINGLEMDS
200 reboot_facet $SINGLEMDS
202 # prepare for MDS failover
203 change_active $SINGLEMDS
204 reboot_facet $SINGLEMDS
212 echo "Reintegrating OST"
215 start_ost 1 || return 2
218 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || return $?
222 clients_recover_osts ost1
223 echo "Verify reintegration"
224 client_df || return 1
227 run_test 2 "Second Failure Mode: MDS/OST `date`"
228 ###################################################
231 ############### Third Failure Mode ###############
234 echo "Verify Lustre filesystem is up and running"
235 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
238 facet_failover $SINGLEMDS
239 wait $DFPID || echo df failed: $?
242 echo "Test Lustre stability after MDS failover"
246 echo "Failing 2 CLIENTS"
250 echo "Test Lustre stability after CLIENT failure"
254 echo "Reintegrating CLIENTS"
255 reintegrate_clients || return 1
257 client_df || return 3
258 sleep 2 # give it a little time for fully recovered before next test
260 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
261 ###################################################
263 ############### Fourth Failure Mode ###############
265 echo "Fourth Failure Mode: OST/MDS `date`"
271 echo "Test Lustre stability after OST failure"
277 shutdown_facet $SINGLEMDS
278 reboot_facet $SINGLEMDS
280 # prepare for MDS failover
281 change_active $SINGLEMDS
282 reboot_facet $SINGLEMDS
289 echo "Reintegrating OST"
295 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS
300 clients_recover_osts ost1
301 echo "Test Lustre stability after MDS failover"
302 client_df || return 1
304 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
305 ###################################################
307 ############### Fifth Failure Mode ###############
309 [ $OSTCOUNT -lt 2 ] && skip "$OSTCOUNT < 2, not enough OSTs" && return 0
311 echo "Fifth Failure Mode: OST/OST `date`"
314 echo "Verify Lustre filesystem is up and running"
315 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
324 echo "Test Lustre stability after OST failure"
334 echo "Test Lustre stability after OST failure"
340 echo "Reintegrating OSTs"
346 clients_recover_osts ost1
347 clients_recover_osts ost2
352 client_df || return 2
354 run_test 5 "Fifth Failure Mode: OST/OST `date`"
355 ###################################################
357 ############### Sixth Failure Mode ###############
359 echo "Sixth Failure Mode: OST/CLIENT `date`"
362 echo "Verify Lustre filesystem is up and running"
363 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
366 client_touch testfile || return 2
373 echo "Test Lustre stability after OST failure"
380 echo "Failing CLIENTs"
384 echo "Test Lustre stability after CLIENTs failure"
391 echo "Reintegrating OST/CLIENTs"
394 reintegrate_clients || return 1
397 wait_remote_prog df $((TIMEOUT * 3 + 10))
401 echo "Verifying mount"
402 [ -z "$(mounted_lustre_filesystems)" ] && return 3
405 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
406 ###################################################
409 ############### Seventh Failure Mode ###############
411 echo "Seventh Failure Mode: CLIENT/MDS `date`"
414 echo "Verify Lustre filesystem is up and running"
415 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
418 client_touch testfile || return 1
421 echo "Part 1: Failing CLIENT"
425 echo "Test Lustre stability after CLIENTs failure"
427 $PDSH $LIVE_CLIENT "ls -l $MOUNT"
428 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
431 echo "Wait 1 minutes"
435 echo "Verify Lustre filesystem is up and running"
436 [ -z "$(mounted_lustre_filesystems)" ] && return 2
442 facet_failover $SINGLEMDS
445 echo "Test Lustre stability after MDS failover"
446 wait $DFPID || echo "df on down clients fails " || return 1
447 $PDSH $LIVE_CLIENT "ls -l $MOUNT"
448 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
451 echo "Reintegrating CLIENTs"
452 reintegrate_clients || return 2
456 echo "wait 1 minutes"
459 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
460 ###################################################
463 ############### Eighth Failure Mode ###############
465 echo "Eighth Failure Mode: CLIENT/OST `date`"
468 echo "Verify Lustre filesystem is up and running"
469 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
472 client_touch testfile
475 echo "Failing CLIENTs"
479 echo "Test Lustre stability after CLIENTs failure"
481 $PDSH $LIVE_CLIENT "ls -l $MOUNT"
482 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
485 echo "Wait 1 minutes"
489 echo "Verify Lustre filesystem is up and running"
490 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
493 client_touch testfile
501 echo "Test Lustre stability after OST failure"
505 #non-failout hangs forever here
506 #$PDSH $LIVE_CLIENT "ls -l $MOUNT"
507 #$PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
510 echo "Reintegrating CLIENTs/OST"
511 reintegrate_clients || return 3
515 client_df || return 1
516 client_touch testfile2 || return 2
519 echo "Wait 1 minutes"
522 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
523 ###################################################
526 ############### Ninth Failure Mode ###############
531 echo "Verify Lustre filesystem is up and running"
532 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
535 client_touch testfile || return 1
538 echo "Failing CLIENTs"
542 echo "Test Lustre stability after CLIENTs failure"
544 $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 1
545 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 2
548 echo "Wait 1 minutes"
552 echo "Verify Lustre filesystem is up and running"
553 $PDSH $LIVE_CLIENT df $MOUNT || return 3
554 client_touch testfile || return 4
557 echo "Failing CLIENTs"
561 echo "Test Lustre stability after CLIENTs failure"
563 $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 5
564 $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 6
567 echo "Reintegrating CLIENTs/CLIENTs"
568 reintegrate_clients || return 7
572 echo "Wait 1 minutes"
575 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
576 ###################################################
579 #Run availability after all failures
580 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
581 LOADTEST=${LOADTEST:-metadata-load.py}
582 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
584 run_test 10 "Running Availability for 6 hours..."
586 equals_msg `basename $0`: test complete, cleaning up
587 check_and_cleanup_lustre
588 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true