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