Whamcloud - gitweb
LU-3409 llite: silence lockdep warning in ll_md_blocking_ast
[fs/lustre-release.git] / lustre / tests / insanity.sh
1 #!/bin/bash
2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:shiftwidth=4:softtabstop=4:tabstop=4:
4 #
5 # Test multiple failures, AKA Test 17
6
7 set -e
8
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 . $LUSTRE/tests/test-framework.sh
11
12 init_test_env $@
13
14 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
15 init_logging
16 #              
17 ALWAYS_EXCEPT="15  $INSANITY_EXCEPT"
18
19 if [ "$FAILURE_MODE" = "HARD" ]; then
20         skip_env "$TESTSUITE: is not functional with FAILURE_MODE = HARD, " \
21                 "please use recovery-double-scale, bz20407"
22         exit 0
23 fi
24
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
26
27 SETUP=${SETUP:-""}
28 CLEANUP=${CLEANUP:-""}
29
30 build_test_filter
31
32 SINGLECLIENT=${SINGLECLIENT:-$HOSTNAME}
33 LIVE_CLIENT=${LIVE_CLIENT:-$SINGLECLIENT}
34 FAIL_CLIENTS=${FAIL_CLIENTS:-$RCLIENTS}
35
36 assert_env mds_HOST MDSCOUNT
37 assert_env ost_HOST OSTCOUNT
38 assert_env LIVE_CLIENT FSNAME
39
40 require_dsh_mds || exit 0
41 require_dsh_ost || exit 0
42
43 # FAIL_CLIENTS list should not contain the LIVE_CLIENT
44 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
45
46 DIR=${DIR:-$MOUNT}
47 TESTDIR=$DIR/d0.$TESTSUITE
48
49 #####
50 # fail clients round robin
51
52 # list of failable clients
53 FAIL_LIST=($FAIL_CLIENTS)
54 FAIL_NUM=${#FAIL_LIST[*]}
55 FAIL_NEXT=0
56 typeset -i  FAIL_NEXT
57 DOWN_NUM=0   # number of nodes currently down
58
59 # set next client to fail
60 set_fail_client() {
61     FAIL_CLIENT=${FAIL_LIST[$FAIL_NEXT]}
62     FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
63     echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
64 }
65
66 fail_clients() {
67         num=$1
68
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))
72         fi
73     
74     if [ -z "$num" ] || [ "$num" -le 0 ]; then
75         log "No clients failed!"
76         return
77     fi
78
79     client_mkdirs
80
81     for i in `seq $num`; do
82        set_fail_client
83        client=$FAIL_CLIENT
84        DOWN_CLIENTS="$DOWN_CLIENTS $client"
85        shutdown_client $client
86     done
87
88     echo "down clients: $DOWN_CLIENTS"
89
90         for client in $DOWN_CLIENTS; do
91                 boot_node $client
92         done
93         DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
94         client_rmdirs
95 }
96
97 reintegrate_clients() {
98         for client in $DOWN_CLIENTS; do
99                 wait_for_host $client
100                 echo "Restarting $client"
101                 zconf_mount $client $MOUNT || return 1
102         done
103
104         DOWN_CLIENTS=""
105         DOWN_NUM=0
106 }
107
108 start_ost() {
109         start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
110 }
111
112 start_mdt() {
113         start mds$1 $(mdsdevname $1) $MDS_MOUNT_OPTS
114 }
115
116 trap exit INT
117
118 client_touch() {
119         file=$1
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
123         done
124 }
125
126 client_rm() {
127         file=$1
128         for c in $LIVE_CLIENT $FAIL_CLIENTS; do
129                 $PDSH $c rm $TESTDIR/${c}_$file
130         done
131 }
132
133 client_mkdirs() {
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"
137         done
138 }
139
140 client_rmdirs() {
141         for c in $LIVE_CLIENT $FAIL_CLIENTS; do
142                 echo "rmdir $TESTDIR/$c"
143                 $PDSH $LIVE_CLIENT "rmdir $TESTDIR/$c"
144         done
145 }
146
147 clients_recover_osts() {
148     facet=$1
149 #    do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
150 }
151
152 check_and_setup_lustre
153
154 rm -rf $TESTDIR
155 mkdir -p $TESTDIR
156
157 # 9 Different Failure Modes Combinations
158 echo "Starting Test 17 at `date`"
159
160 test_0() {
161         for i in $(seq $MDSCOUNT) ; do
162                 fail mds$i
163         done
164
165     for i in $(seq $OSTCOUNT) ; do
166         fail ost$i
167     done
168     return 0
169 }
170 run_test 0 "Fail all nodes, independently"
171
172 ############### First Failure Mode ###############
173 test_1() {
174         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
175
176         clients_up
177
178         shutdown_facet mds1
179         reboot_facet mds1
180
181         # prepare for MDS failover
182         change_active mds1
183         reboot_facet mds1
184
185         clients_up &
186         DFPID=$!
187         sleep 5
188
189         shutdown_facet mds2
190
191         echo "Reintegrating MDS2"
192         reboot_facet mds2
193         wait_for_facet mds2
194         start_mdt 2 || return 2
195
196         wait_for_facet mds1
197         start_mdt 1 || return $?
198
199         #Check FS
200         wait $DFPID
201         echo "Verify reintegration"
202         clients_up || return 1
203 }
204 run_test 1 "MDS/MDS failure"
205 ###################################################
206
207 ############### Second Failure Mode ###############
208 test_2() {
209         echo "Verify Lustre filesystem is up and running"
210         [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
211
212         [ "$(facet_fstype ost1)" = "zfs" ] &&
213                 skip "LU-2059: no local config for ZFS OSTs" && return
214
215     clients_up
216
217         for i in $(seq $MDSCOUNT) ; do
218                 shutdown_facet mds$i
219                 reboot_facet mds$i
220
221                 # prepare for MDS failover
222                 change_active mds$i
223                 reboot_facet mds$i
224         done
225
226     clients_up &
227     DFPID=$!
228     sleep 5
229
230     shutdown_facet ost1
231
232     echo "Reintegrating OST"
233     reboot_facet ost1
234     wait_for_facet ost1
235     start_ost 1 || return 2
236
237         for i in $(seq $MDSCOUNT) ; do
238                 wait_for_facet mds$i
239                 start_mdt $i || return $?
240         done
241
242     #Check FS
243     wait $DFPID
244     clients_recover_osts ost1
245     echo "Verify reintegration"
246     clients_up || return 1
247
248 }
249 run_test 2 "Second Failure Mode: MDS/OST `date`"
250 ###################################################
251
252 ############### Third Failure Mode ###############
253 test_3() {
254     #Create files
255     echo "Verify Lustre filesystem is up and running"
256     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
257
258     #MDS Portion
259         for i in $(seq $MDSCOUNT) ; do
260                 fail mds$i
261         done
262     #Check FS
263
264     echo "Test Lustre stability after MDS failover"
265     clients_up
266
267     #CLIENT Portion
268     echo "Failing 2 CLIENTS"
269     fail_clients 2
270     
271     #Check FS
272     echo "Test Lustre stability after CLIENT failure"
273     clients_up
274     
275     #Reintegration
276     echo "Reintegrating CLIENTS"
277     reintegrate_clients || return 1
278
279     clients_up || return 3
280     sleep 2 # give it a little time for fully recovered before next test
281 }
282 run_test 3  "Thirdb Failure Mode: MDS/CLIENT `date`"
283 ###################################################
284
285 ############### Fourth Failure Mode ###############
286 test_4() {
287         echo "Fourth Failure Mode: OST/MDS `date`"
288
289         [ "$(facet_fstype ost1)" = "zfs" ] &&
290                 skip "LU-2059: no local config for ZFS OSTs" && return
291
292     #OST Portion
293     shutdown_facet ost1
294
295     #Check FS
296     echo "Test Lustre stability after OST failure"
297     clients_up &
298     DFPIDA=$!
299     sleep 5
300
301         for i in $(seq $MDSCOUNT) ; do
302                 shutdown_facet mds$i
303                 reboot_facet mds$i
304
305                 # prepare for MDS failover
306                 change_active mds$i
307                 reboot_facet mds$i
308         done
309
310     clients_up &
311     DFPIDB=$!
312     sleep 5
313
314     #Reintegration
315     echo "Reintegrating OST"
316     reboot_facet ost1
317     wait_for_facet ost1
318     start_ost 1
319
320         for i in $(seq $MDSCOUNT) ; do
321                 wait_for_facet mds$i
322                 start_mdt $i || return $?
323         done
324     #Check FS
325
326     wait $DFPIDA
327     wait $DFPIDB
328     clients_recover_osts ost1
329     echo "Test Lustre stability after MDS failover"
330     clients_up || return 1
331 }
332 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
333 ###################################################
334
335 ############### Fifth Failure Mode ###############
336 test_5() {
337     [ $OSTCOUNT -lt 2 ] && skip_env "$OSTCOUNT < 2, not enough OSTs" && return 0
338
339     echo "Fifth Failure Mode: OST/OST `date`"
340
341     #Create files
342     echo "Verify Lustre filesystem is up and running"
343     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
344
345     clients_up
346     
347     #OST Portion
348     shutdown_facet ost1
349     reboot_facet ost1
350     
351     #Check FS
352     echo "Test Lustre stability after OST failure"
353     clients_up &
354     DFPIDA=$!
355     sleep 5
356     
357     #OST Portion
358     shutdown_facet ost2
359     reboot_facet ost2
360
361     #Check FS
362     echo "Test Lustre stability after OST failure"
363     clients_up &
364     DFPIDB=$!
365     sleep 5
366
367     #Reintegration
368     echo "Reintegrating OSTs"
369     wait_for_facet ost1
370     start_ost 1
371     wait_for_facet ost2
372     start_ost 2
373     
374     clients_recover_osts ost1
375     clients_recover_osts ost2
376     sleep $TIMEOUT
377
378     wait $DFPIDA
379     wait $DFPIDB
380     clients_up || return 2
381 }
382 run_test 5 "Fifth Failure Mode: OST/OST `date`"
383 ###################################################
384
385 ############### Sixth Failure Mode ###############
386 test_6() {
387     echo "Sixth Failure Mode: OST/CLIENT `date`"
388
389     #Create files
390     echo "Verify Lustre filesystem is up and running"
391     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
392
393     clients_up
394     client_touch testfile || return 2
395         
396     #OST Portion
397     shutdown_facet ost1
398     reboot_facet ost1
399
400     #Check FS
401     echo "Test Lustre stability after OST failure"
402     clients_up &
403     DFPIDA=$!
404     echo DFPIDA=$DFPIDA
405     sleep 5
406
407     #CLIENT Portion
408     echo "Failing CLIENTs"
409     fail_clients
410     
411     #Check FS
412     echo "Test Lustre stability after CLIENTs failure"
413     clients_up &
414     DFPIDB=$!
415     echo DFPIDB=$DFPIDB
416     sleep 5
417     
418     #Reintegration
419     echo "Reintegrating OST/CLIENTs"
420     wait_for_facet ost1
421     start_ost 1
422     reintegrate_clients || return 1
423     sleep 5 
424
425     wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20)) 
426     wait $DFPIDA
427     wait $DFPIDB
428
429     echo "Verifying mount"
430     [ -z "$(mounted_lustre_filesystems)" ] && return 3
431     clients_up
432 }
433 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
434 ###################################################
435
436
437 ############### Seventh Failure Mode ###############
438 test_7() {
439     echo "Seventh Failure Mode: CLIENT/MDS `date`"
440
441     #Create files
442     echo "Verify Lustre filesystem is up and running"
443     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
444
445     clients_up
446     client_touch testfile  || return 1
447
448     #CLIENT Portion
449     echo "Part 1: Failing CLIENT"
450     fail_clients 2
451     
452     #Check FS
453     echo "Test Lustre stability after CLIENTs failure"
454     clients_up
455     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
456     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
457     
458     #Sleep
459     echo "Wait 1 minutes"
460     sleep 60
461
462     #Create files
463     echo "Verify Lustre filesystem is up and running"
464     [ -z "$(mounted_lustre_filesystems)" ] && return 2
465
466     clients_up
467     client_rm testfile
468
469     #MDS Portion
470         for i in $(seq $MDSCOUNT) ; do
471                 fail mds$i
472         done
473
474     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
475     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
476
477     #Reintegration
478     echo "Reintegrating CLIENTs"
479     reintegrate_clients || return 2
480     clients_up
481     
482     #Sleep
483     echo "wait 1 minutes"
484     sleep 60
485 }
486 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
487 ###################################################
488
489
490 ############### Eighth Failure Mode ###############
491 test_8() {
492     echo "Eighth Failure Mode: CLIENT/OST `date`"
493
494     #Create files
495     echo "Verify Lustre filesystem is up and running"
496     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
497
498     clients_up
499     client_touch testfile
500         
501     #CLIENT Portion
502     echo "Failing CLIENTs"
503     fail_clients 2
504
505     #Check FS
506     echo "Test Lustre stability after CLIENTs failure"
507     clients_up
508     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
509     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
510
511     #Sleep
512     echo "Wait 1 minutes"
513     sleep 60
514
515     #Create files
516     echo "Verify Lustre filesystem is up and running"
517     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
518
519     clients_up
520     client_touch testfile
521
522
523     #OST Portion
524     shutdown_facet ost1
525     reboot_facet ost1
526
527     #Check FS
528     echo "Test Lustre stability after OST failure"
529     clients_up &
530     DFPID=$!
531     sleep 5
532     #non-failout hangs forever here
533     #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
534     #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
535     
536     #Reintegration
537     echo "Reintegrating CLIENTs/OST"
538     reintegrate_clients || return 3
539     wait_for_facet ost1
540     start_ost 1
541     wait $DFPID
542     clients_up || return 1
543     client_touch testfile2 || return 2
544
545     #Sleep
546     echo "Wait 1 minutes"
547     sleep 60
548 }
549 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
550 ###################################################
551
552
553 ############### Ninth Failure Mode ###############
554 test_9() {
555     echo 
556
557     #Create files
558     echo "Verify Lustre filesystem is up and running"
559     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
560
561     clients_up
562     client_touch testfile || return 1
563         
564     #CLIENT Portion
565     echo "Failing CLIENTs"
566     fail_clients 2
567
568     #Check FS
569     echo "Test Lustre stability after CLIENTs failure"
570     clients_up
571     $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
572     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
573
574     #Sleep
575     echo "Wait 1 minutes"
576     sleep 60
577
578     #Create files
579     echo "Verify Lustre filesystem is up and running"
580     client_up $LIVE_CLIENT || return 3
581     client_touch testfile || return 4
582
583     #CLIENT Portion
584     echo "Failing CLIENTs"
585     fail_clients 2
586     
587     #Check FS
588     echo "Test Lustre stability after CLIENTs failure"
589     clients_up
590     $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
591     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
592
593     #Reintegration
594     echo "Reintegrating  CLIENTs/CLIENTs"
595     reintegrate_clients || return 7
596     clients_up
597     
598     #Sleep
599     echo "Wait 1 minutes"
600     sleep 60
601 }
602 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
603 ###################################################
604
605 ############### Tenth Failure Mode ###############
606 test_10() {
607         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
608
609         shutdown_facet mds1
610         reboot_facet mds1
611
612         # prepare for MDS failover
613         change_active mds1
614         reboot_facet mds1
615
616         clients_up &
617         DFPID=$!
618         sleep 5
619
620         shutdown_facet ost1
621
622         echo "Reintegrating OST"
623         reboot_facet ost1
624         wait_for_facet ost1
625         start_ost 1 || return 2
626
627         shutdown_facet mds2
628         reboot_facet mds2
629
630         # prepare for MDS failover
631         change_active mds2
632         reboot_facet mds2
633
634         wait_for_facet mds1
635         start_mdt 1 || return $?
636
637         wait_for_facet mds2
638         start_mdt 2 || return $?
639
640         #Check FS
641         wait $DFPID
642         clients_recover_osts ost1
643         echo "Verify reintegration"
644         clients_up || return 1
645 }
646 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
647 ###################################################
648
649 ############### Seventh Failure Mode ###############
650 test_11() {
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"
654
655         #MDS Portion
656         fail mds1
657         #Check FS
658
659         echo "Test Lustre stability after MDS failover"
660         clients_up
661
662         #CLIENT Portion
663         echo "Failing 2 CLIENTS"
664         fail_clients 2
665
666         #Check FS
667         echo "Test Lustre stability after CLIENT failure"
668         clients_up
669
670         #Reintegration
671         echo "Reintegrating CLIENTS"
672         reintegrate_clients || return 1
673
674         fail mds2
675
676         clients_up || return 3
677         sleep 2 # give it a little time for fully recovered before next test
678 }
679 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
680 ###################################################
681
682 test_12() {
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"
686
687         #MDS Portion
688         fail mds1,mds2
689         clients_up
690
691         #OSS Portion
692         fail ost1,ost2
693         clients_up
694
695         #CLIENT Portion
696         echo "Failing 2 CLIENTS"
697         fail_clients 2
698
699         #Check FS
700         echo "Test Lustre stability after CLIENT failure"
701         clients_up
702
703         #Reintegration
704         echo "Reintegrating CLIENTS"
705         reintegrate_clients || return 1
706
707         clients_up || return 3
708         sleep 2 # give it a little time for fully recovered before next test
709 }
710 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
711 ###################################################
712
713 test_13() {
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"
717
718         #MDS Portion
719         fail mds1,mds2
720         clients_up
721
722         #CLIENT Portion
723         echo "Failing 2 CLIENTS"
724         fail_clients 2
725
726         #Check FS
727         echo "Test Lustre stability after CLIENT failure"
728         clients_up
729
730         #Reintegration
731         echo "Reintegrating CLIENTS"
732         reintegrate_clients || return 1
733
734         clients_up || return 3
735         sleep 2 # give it a little time for fully recovered before next test
736
737         #OSS Portion
738         fail ost1,ost2
739         clients_up || return 4
740 }
741 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
742 ###################################################
743
744 test_14() {
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"
748
749         #OST Portion
750         fail ost1,ost2
751         clients_up
752
753         #CLIENT Portion
754         echo "Failing 2 CLIENTS"
755         fail_clients 2
756
757         #Check FS
758         echo "Test Lustre stability after CLIENT failure"
759         clients_up
760
761         #Reintegration
762         echo "Reintegrating CLIENTS"
763         reintegrate_clients || return 1
764
765         clients_up || return 3
766         sleep 2 # give it a little time for fully recovered before next test
767
768         #OSS Portion
769         fail mds1,mds2
770         clients_up || return 4
771 }
772 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
773 ###################################################
774
775 test_15() {
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
780 }
781 run_test 15 "Running Availability for 6 hours..."
782
783 complete $SECONDS
784 check_and_cleanup_lustre
785 exit_status