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 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
39 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
41 # FAIL_CLIENTS list should not contain the LIVE_CLIENT
42 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
45 TESTDIR=$DIR/d0.$(basename $0 .sh)
48 # fail clients round robin
50 # list of failable clients
51 FAIL_LIST=($FAIL_CLIENTS)
52 FAIL_NUM=${#FAIL_LIST[*]}
55 DOWN_NUM=0 # number of nodes currently down
57 # set next client to fail
59 FAIL_CLIENT=${FAIL_LIST[$FAIL_NEXT]}
60 FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
61 echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
67 log "Request clients to fail: ${num}. Num of clients to fail: ${FAIL_NUM}, already failed: $DOWN_NUM"
68 if [ -z "$num" ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
69 num=$((FAIL_NUM - DOWN_NUM))
72 if [ -z "$num" ] || [ "$num" -le 0 ]; then
73 log "No clients failed!"
79 for i in `seq $num`; do
82 DOWN_CLIENTS="$DOWN_CLIENTS $client"
83 shutdown_client $client
86 echo "down clients: $DOWN_CLIENTS"
88 for client in $DOWN_CLIENTS; do
91 DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
95 reintegrate_clients() {
96 for client in $DOWN_CLIENTS; do
98 echo "Restarting $client"
99 zconf_mount $client $MOUNT || return 1
106 start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
113 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
114 if echo $DOWN_CLIENTS | grep -q $c; then continue; fi
115 $PDSH $c touch $TESTDIR/${c}_$file || return 1
121 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
122 $PDSH $c rm $TESTDIR/${c}_$file
127 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
128 echo "$c mkdir $TESTDIR/$c"
129 $PDSH $c "mkdir $TESTDIR/$c && ls -l $TESTDIR/$c"
134 for c in $LIVE_CLIENT $FAIL_CLIENTS; do
135 echo "rmdir $TESTDIR/$c"
136 $PDSH $LIVE_CLIENT "rmdir $TESTDIR/$c"
140 clients_recover_osts() {
142 # do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
145 check_and_setup_lustre
150 # 9 Different Failure Modes Combinations
151 echo "Starting Test 17 at `date`"
156 for i in $(seq $OSTCOUNT) ; do
161 run_test 0 "Fail all nodes, independently"
163 ############### First Failure Mode ###############
165 echo "Don't do a MDS - MDS Failure Case"
166 echo "This makes no sense"
168 run_test 1 "MDS/MDS failure"
169 ###################################################
171 ############### Second Failure Mode ###############
173 echo "Verify Lustre filesystem is up and running"
174 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
178 shutdown_facet $SINGLEMDS
179 reboot_facet $SINGLEMDS
181 # prepare for MDS failover
182 change_active $SINGLEMDS
183 reboot_facet $SINGLEMDS
191 echo "Reintegrating OST"
194 start_ost 1 || return 2
197 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || return $?
201 clients_recover_osts ost1
202 echo "Verify reintegration"
203 client_df || return 1
206 run_test 2 "Second Failure Mode: MDS/OST `date`"
207 ###################################################
210 ############### Third Failure Mode ###############
213 echo "Verify Lustre filesystem is up and running"
214 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
220 echo "Test Lustre stability after MDS failover"
224 echo "Failing 2 CLIENTS"
228 echo "Test Lustre stability after CLIENT failure"
232 echo "Reintegrating CLIENTS"
233 reintegrate_clients || return 1
235 client_df || return 3
236 sleep 2 # give it a little time for fully recovered before next test
238 run_test 3 "Thirdb Failure Mode: MDS/CLIENT `date`"
239 ###################################################
241 ############### Fourth Failure Mode ###############
243 echo "Fourth Failure Mode: OST/MDS `date`"
249 echo "Test Lustre stability after OST failure"
255 shutdown_facet $SINGLEMDS
256 reboot_facet $SINGLEMDS
258 # prepare for MDS failover
259 change_active $SINGLEMDS
260 reboot_facet $SINGLEMDS
267 echo "Reintegrating OST"
273 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS
278 clients_recover_osts ost1
279 echo "Test Lustre stability after MDS failover"
280 client_df || return 1
282 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
283 ###################################################
285 ############### Fifth Failure Mode ###############
287 [ $OSTCOUNT -lt 2 ] && skip "$OSTCOUNT < 2, not enough OSTs" && return 0
289 echo "Fifth Failure Mode: OST/OST `date`"
292 echo "Verify Lustre filesystem is up and running"
293 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
302 echo "Test Lustre stability after OST failure"
312 echo "Test Lustre stability after OST failure"
318 echo "Reintegrating OSTs"
324 clients_recover_osts ost1
325 clients_recover_osts ost2
330 client_df || return 2
332 run_test 5 "Fifth Failure Mode: OST/OST `date`"
333 ###################################################
335 ############### Sixth Failure Mode ###############
337 echo "Sixth Failure Mode: OST/CLIENT `date`"
340 echo "Verify Lustre filesystem is up and running"
341 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
344 client_touch testfile || return 2
351 echo "Test Lustre stability after OST failure"
358 echo "Failing CLIENTs"
362 echo "Test Lustre stability after CLIENTs failure"
369 echo "Reintegrating OST/CLIENTs"
372 reintegrate_clients || return 1
375 wait_remote_prog df $((TIMEOUT * 3 + 10))
379 echo "Verifying mount"
380 [ -z "$(mounted_lustre_filesystems)" ] && return 3
383 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
384 ###################################################
387 ############### Seventh Failure Mode ###############
389 echo "Seventh Failure Mode: CLIENT/MDS `date`"
392 echo "Verify Lustre filesystem is up and running"
393 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
396 client_touch testfile || return 1
399 echo "Part 1: Failing CLIENT"
403 echo "Test Lustre stability after CLIENTs failure"
405 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
406 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
409 echo "Wait 1 minutes"
413 echo "Verify Lustre filesystem is up and running"
414 [ -z "$(mounted_lustre_filesystems)" ] && return 2
422 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
423 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
426 echo "Reintegrating CLIENTs"
427 reintegrate_clients || return 2
431 echo "wait 1 minutes"
434 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
435 ###################################################
438 ############### Eighth Failure Mode ###############
440 echo "Eighth Failure Mode: CLIENT/OST `date`"
443 echo "Verify Lustre filesystem is up and running"
444 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
447 client_touch testfile
450 echo "Failing CLIENTs"
454 echo "Test Lustre stability after CLIENTs failure"
456 $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
457 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
460 echo "Wait 1 minutes"
464 echo "Verify Lustre filesystem is up and running"
465 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
468 client_touch testfile
476 echo "Test Lustre stability after OST failure"
480 #non-failout hangs forever here
481 #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
482 #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
485 echo "Reintegrating CLIENTs/OST"
486 reintegrate_clients || return 3
490 client_df || return 1
491 client_touch testfile2 || return 2
494 echo "Wait 1 minutes"
497 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
498 ###################################################
501 ############### Ninth Failure Mode ###############
506 echo "Verify Lustre filesystem is up and running"
507 [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
510 client_touch testfile || return 1
513 echo "Failing CLIENTs"
517 echo "Test Lustre stability after CLIENTs failure"
519 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
520 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
523 echo "Wait 1 minutes"
527 echo "Verify Lustre filesystem is up and running"
528 $PDSH $LIVE_CLIENT df $MOUNT || return 3
529 client_touch testfile || return 4
532 echo "Failing CLIENTs"
536 echo "Test Lustre stability after CLIENTs failure"
538 $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
539 $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
542 echo "Reintegrating CLIENTs/CLIENTs"
543 reintegrate_clients || return 7
547 echo "Wait 1 minutes"
550 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
551 ###################################################
554 #Run availability after all failures
555 DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
556 LOADTEST=${LOADTEST:-metadata-load.py}
557 $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
559 run_test 10 "Running Availability for 6 hours..."
561 equals_msg `basename $0`: test complete, cleaning up
562 check_and_cleanup_lustre
563 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true