Whamcloud - gitweb
LU-11161 tests: stop running sanity test 160g
[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         clients_up
213
214         for i in $(seq $MDSCOUNT) ; do
215                 shutdown_facet mds$i
216                 reboot_facet mds$i
217
218                 # prepare for MDS failover
219                 change_active mds$i
220                 reboot_facet mds$i
221         done
222
223     clients_up &
224     DFPID=$!
225     sleep 5
226
227     shutdown_facet ost1
228
229     echo "Reintegrating OST"
230     reboot_facet ost1
231     wait_for_facet ost1
232     start_ost 1 || return 2
233
234         for i in $(seq $MDSCOUNT) ; do
235                 wait_for_facet mds$i
236                 start_mdt $i || return $?
237         done
238
239     #Check FS
240     wait $DFPID
241     clients_recover_osts ost1
242     echo "Verify reintegration"
243     clients_up || return 1
244
245 }
246 run_test 2 "Second Failure Mode: MDS/OST `date`"
247 ###################################################
248
249 ############### Third Failure Mode ###############
250 test_3() {
251     #Create files
252     echo "Verify Lustre filesystem is up and running"
253     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
254
255     #MDS Portion
256         for i in $(seq $MDSCOUNT) ; do
257                 fail mds$i
258         done
259     #Check FS
260
261     echo "Test Lustre stability after MDS failover"
262     clients_up
263
264     #CLIENT Portion
265     echo "Failing 2 CLIENTS"
266     fail_clients 2
267     
268     #Check FS
269     echo "Test Lustre stability after CLIENT failure"
270     clients_up
271     
272     #Reintegration
273     echo "Reintegrating CLIENTS"
274     reintegrate_clients || return 1
275
276     clients_up || return 3
277     sleep 2 # give it a little time for fully recovered before next test
278 }
279 run_test 3  "Thirdb Failure Mode: MDS/CLIENT `date`"
280 ###################################################
281
282 ############### Fourth Failure Mode ###############
283 test_4() {
284         echo "Fourth Failure Mode: OST/MDS `date`"
285
286     #OST Portion
287     shutdown_facet ost1
288
289     #Check FS
290     echo "Test Lustre stability after OST failure"
291     clients_up &
292     DFPIDA=$!
293     sleep 5
294
295         for i in $(seq $MDSCOUNT) ; do
296                 shutdown_facet mds$i
297                 reboot_facet mds$i
298
299                 # prepare for MDS failover
300                 change_active mds$i
301                 reboot_facet mds$i
302         done
303
304     clients_up &
305     DFPIDB=$!
306     sleep 5
307
308     #Reintegration
309     echo "Reintegrating OST"
310     reboot_facet ost1
311     wait_for_facet ost1
312     start_ost 1
313
314         for i in $(seq $MDSCOUNT) ; do
315                 wait_for_facet mds$i
316                 start_mdt $i || return $?
317         done
318     #Check FS
319
320     wait $DFPIDA
321     wait $DFPIDB
322     clients_recover_osts ost1
323     echo "Test Lustre stability after MDS failover"
324     clients_up || return 1
325 }
326 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
327 ###################################################
328
329 ############### Fifth Failure Mode ###############
330 test_5() {
331         [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return 0
332
333         echo "Fifth Failure Mode: OST/OST `date`"
334
335         #Create files
336         echo "Verify Lustre filesystem is up and running"
337         [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
338
339         clients_up
340         #OST Portion
341         shutdown_facet ost1
342         reboot_facet ost1
343
344     #Check FS
345     echo "Test Lustre stability after OST failure"
346     clients_up &
347     DFPIDA=$!
348     sleep 5
349
350     #OST Portion
351     shutdown_facet ost2
352     reboot_facet ost2
353
354     #Check FS
355     echo "Test Lustre stability after OST failure"
356     clients_up &
357     DFPIDB=$!
358     sleep 5
359
360     #Reintegration
361     echo "Reintegrating OSTs"
362     wait_for_facet ost1
363     start_ost 1
364     wait_for_facet ost2
365     start_ost 2
366
367     clients_recover_osts ost1
368     clients_recover_osts ost2
369     sleep $TIMEOUT
370
371     wait $DFPIDA
372     wait $DFPIDB
373     clients_up || return 2
374 }
375 run_test 5 "Fifth Failure Mode: OST/OST `date`"
376 ###################################################
377
378 ############### Sixth Failure Mode ###############
379 test_6() {
380     echo "Sixth Failure Mode: OST/CLIENT `date`"
381
382     #Create files
383     echo "Verify Lustre filesystem is up and running"
384     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
385
386     clients_up
387     client_touch testfile || return 2
388         
389     #OST Portion
390     shutdown_facet ost1
391     reboot_facet ost1
392
393     #Check FS
394     echo "Test Lustre stability after OST failure"
395     clients_up &
396     DFPIDA=$!
397     echo DFPIDA=$DFPIDA
398     sleep 5
399
400     #CLIENT Portion
401     echo "Failing CLIENTs"
402     fail_clients
403     
404     #Check FS
405     echo "Test Lustre stability after CLIENTs failure"
406     clients_up &
407     DFPIDB=$!
408     echo DFPIDB=$DFPIDB
409     sleep 5
410     
411     #Reintegration
412     echo "Reintegrating OST/CLIENTs"
413     wait_for_facet ost1
414     start_ost 1
415     reintegrate_clients || return 1
416     sleep 5 
417
418     wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20)) 
419     wait $DFPIDA
420     wait $DFPIDB
421
422     echo "Verifying mount"
423     [ -z "$(mounted_lustre_filesystems)" ] && return 3
424     clients_up
425 }
426 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
427 ###################################################
428
429
430 ############### Seventh Failure Mode ###############
431 test_7() {
432     echo "Seventh Failure Mode: CLIENT/MDS `date`"
433
434     #Create files
435     echo "Verify Lustre filesystem is up and running"
436     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
437
438     clients_up
439     client_touch testfile  || return 1
440
441     #CLIENT Portion
442     echo "Part 1: Failing CLIENT"
443     fail_clients 2
444     
445     #Check FS
446     echo "Test Lustre stability after CLIENTs failure"
447     clients_up
448     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
449     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
450     
451     #Sleep
452     echo "Wait 1 minutes"
453     sleep 60
454
455     #Create files
456     echo "Verify Lustre filesystem is up and running"
457     [ -z "$(mounted_lustre_filesystems)" ] && return 2
458
459     clients_up
460     client_rm testfile
461
462     #MDS Portion
463         for i in $(seq $MDSCOUNT) ; do
464                 fail mds$i
465         done
466
467     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
468     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
469
470     #Reintegration
471     echo "Reintegrating CLIENTs"
472     reintegrate_clients || return 2
473     clients_up
474     
475     #Sleep
476     echo "wait 1 minutes"
477     sleep 60
478 }
479 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
480 ###################################################
481
482
483 ############### Eighth Failure Mode ###############
484 test_8() {
485     echo "Eighth Failure Mode: CLIENT/OST `date`"
486
487     #Create files
488     echo "Verify Lustre filesystem is up and running"
489     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
490
491     clients_up
492     client_touch testfile
493         
494     #CLIENT Portion
495     echo "Failing CLIENTs"
496     fail_clients 2
497
498     #Check FS
499     echo "Test Lustre stability after CLIENTs failure"
500     clients_up
501     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
502     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
503
504     #Sleep
505     echo "Wait 1 minutes"
506     sleep 60
507
508     #Create files
509     echo "Verify Lustre filesystem is up and running"
510     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
511
512     clients_up
513     client_touch testfile
514
515
516     #OST Portion
517     shutdown_facet ost1
518     reboot_facet ost1
519
520     #Check FS
521     echo "Test Lustre stability after OST failure"
522     clients_up &
523     DFPID=$!
524     sleep 5
525     #non-failout hangs forever here
526     #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
527     #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
528     
529     #Reintegration
530     echo "Reintegrating CLIENTs/OST"
531     reintegrate_clients || return 3
532     wait_for_facet ost1
533     start_ost 1
534     wait $DFPID
535     clients_up || return 1
536     client_touch testfile2 || return 2
537
538     #Sleep
539     echo "Wait 1 minutes"
540     sleep 60
541 }
542 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
543 ###################################################
544
545
546 ############### Ninth Failure Mode ###############
547 test_9() {
548     echo 
549
550     #Create files
551     echo "Verify Lustre filesystem is up and running"
552     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
553
554     clients_up
555     client_touch testfile || return 1
556         
557     #CLIENT Portion
558     echo "Failing CLIENTs"
559     fail_clients 2
560
561     #Check FS
562     echo "Test Lustre stability after CLIENTs failure"
563     clients_up
564     $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
565     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
566
567     #Sleep
568     echo "Wait 1 minutes"
569     sleep 60
570
571     #Create files
572     echo "Verify Lustre filesystem is up and running"
573     client_up $LIVE_CLIENT || return 3
574     client_touch testfile || return 4
575
576     #CLIENT Portion
577     echo "Failing CLIENTs"
578     fail_clients 2
579     
580     #Check FS
581     echo "Test Lustre stability after CLIENTs failure"
582     clients_up
583     $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
584     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
585
586     #Reintegration
587     echo "Reintegrating  CLIENTs/CLIENTs"
588     reintegrate_clients || return 7
589     clients_up
590     
591     #Sleep
592     echo "Wait 1 minutes"
593     sleep 60
594 }
595 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
596 ###################################################
597
598 ############### Tenth Failure Mode ###############
599 test_10() {
600         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
601
602         shutdown_facet mds1
603         reboot_facet mds1
604
605         # prepare for MDS failover
606         change_active mds1
607         reboot_facet mds1
608
609         clients_up &
610         DFPID=$!
611         sleep 5
612
613         shutdown_facet ost1
614
615         echo "Reintegrating OST"
616         reboot_facet ost1
617         wait_for_facet ost1
618         start_ost 1 || return 2
619
620         shutdown_facet mds2
621         reboot_facet mds2
622
623         # prepare for MDS failover
624         change_active mds2
625         reboot_facet mds2
626
627         wait_for_facet mds1
628         start_mdt 1 || return $?
629
630         wait_for_facet mds2
631         start_mdt 2 || return $?
632
633         #Check FS
634         wait $DFPID
635         clients_recover_osts ost1
636         echo "Verify reintegration"
637         clients_up || return 1
638 }
639 run_test 10 "Tenth Failure Mode: MDT0/OST/MDT1 `date`"
640 ###################################################
641
642 ############### Seventh Failure Mode ###############
643 test_11() {
644         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
645         echo "Verify Lustre filesystem is up and running"
646         [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
647
648         #MDS Portion
649         fail mds1
650         #Check FS
651
652         echo "Test Lustre stability after MDS failover"
653         clients_up
654
655         #CLIENT Portion
656         echo "Failing 2 CLIENTS"
657         fail_clients 2
658
659         #Check FS
660         echo "Test Lustre stability after CLIENT failure"
661         clients_up
662
663         #Reintegration
664         echo "Reintegrating CLIENTS"
665         reintegrate_clients || return 1
666
667         fail mds2
668
669         clients_up || return 3
670         sleep 2 # give it a little time for fully recovered before next test
671 }
672 run_test 11 "Eleventh Failure Mode: MDS0/CLIENT/MDS1 `date`"
673 ###################################################
674
675 test_12() {
676         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
677         echo "Verify Lustre filesystem is up and running"
678         [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
679
680         #MDS Portion
681         fail mds1,mds2
682         clients_up
683
684         #OSS Portion
685         fail ost1,ost2
686         clients_up
687
688         #CLIENT Portion
689         echo "Failing 2 CLIENTS"
690         fail_clients 2
691
692         #Check FS
693         echo "Test Lustre stability after CLIENT failure"
694         clients_up
695
696         #Reintegration
697         echo "Reintegrating CLIENTS"
698         reintegrate_clients || return 1
699
700         clients_up || return 3
701         sleep 2 # give it a little time for fully recovered before next test
702 }
703 run_test 12 "Twelve Failure Mode: MDS0,MDS1/OST0, OST1/CLIENTS `date`"
704 ###################################################
705
706 test_13() {
707         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
708         echo "Verify Lustre filesystem is up and running"
709         [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
710
711         #MDS Portion
712         fail mds1,mds2
713         clients_up
714
715         #CLIENT Portion
716         echo "Failing 2 CLIENTS"
717         fail_clients 2
718
719         #Check FS
720         echo "Test Lustre stability after CLIENT failure"
721         clients_up
722
723         #Reintegration
724         echo "Reintegrating CLIENTS"
725         reintegrate_clients || return 1
726
727         clients_up || return 3
728         sleep 2 # give it a little time for fully recovered before next test
729
730         #OSS Portion
731         fail ost1,ost2
732         clients_up || return 4
733 }
734 run_test 13 "Thirteen Failure Mode: MDS0,MDS1/CLIENTS/OST0,OST1 `date`"
735 ###################################################
736
737 test_14() {
738         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
739         echo "Verify Lustre filesystem is up and running"
740         [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
741
742         #OST Portion
743         fail ost1,ost2
744         clients_up
745
746         #CLIENT Portion
747         echo "Failing 2 CLIENTS"
748         fail_clients 2
749
750         #Check FS
751         echo "Test Lustre stability after CLIENT failure"
752         clients_up
753
754         #Reintegration
755         echo "Reintegrating CLIENTS"
756         reintegrate_clients || return 1
757
758         clients_up || return 3
759         sleep 2 # give it a little time for fully recovered before next test
760
761         #OSS Portion
762         fail mds1,mds2
763         clients_up || return 4
764 }
765 run_test 14 "Fourteen Failure Mode: OST0,OST1/CLIENTS/MDS0,MDS1 `date`"
766 ###################################################
767
768 test_15() {
769     #Run availability after all failures
770     DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
771     LOADTEST=${LOADTEST:-metadata-load.py}
772     $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
773 }
774 run_test 15 "Running Availability for 6 hours..."
775
776 complete $SECONDS
777 check_and_cleanup_lustre
778 exit_status