Whamcloud - gitweb
LU-613 clio: Client dead-lock during binary exec
[fs/lustre-release.git] / lustre / tests / insanity.sh
1 #!/bin/sh
2 # Test multiple failures, AKA Test 17
3
4 set -e
5
6 LUSTRE=${LUSTRE:-`dirname $0`/..}
7 . $LUSTRE/tests/test-framework.sh
8
9 init_test_env $@
10
11 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
12 init_logging
13 #              
14 ALWAYS_EXCEPT="10  $INSANITY_EXCEPT"
15
16 if [ "$FAILURE_MODE" = "HARD" ]; then
17         skip_env "$0: is not functional with FAILURE_MODE = HARD, please use recovery-double-scale, bz20407"
18         exit 0
19 fi
20
21 #
22 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
23
24 SETUP=${SETUP:-""}
25 CLEANUP=${CLEANUP:-""}
26
27 build_test_filter
28
29 SINGLECLIENT=${SINGLECLIENT:-$HOSTNAME}
30 LIVE_CLIENT=${LIVE_CLIENT:-$SINGLECLIENT}
31 FAIL_CLIENTS=${FAIL_CLIENTS:-$RCLIENTS}
32
33 assert_env mds_HOST MDS_MKFS_OPTS
34 assert_env ost_HOST OST_MKFS_OPTS OSTCOUNT
35 assert_env LIVE_CLIENT FSNAME
36
37 require_dsh_mds || exit 0
38 require_dsh_ost || exit 0
39
40 # FAIL_CLIENTS list should not contain the LIVE_CLIENT
41 FAIL_CLIENTS=$(echo " $FAIL_CLIENTS " | sed -re "s/\s+$LIVE_CLIENT\s+/ /g")
42
43 DIR=${DIR:-$MOUNT}
44 TESTDIR=$DIR/d0.$(basename $0 .sh)
45
46 #####
47 # fail clients round robin
48
49 # list of failable clients
50 FAIL_LIST=($FAIL_CLIENTS)
51 FAIL_NUM=${#FAIL_LIST[*]}
52 FAIL_NEXT=0
53 typeset -i  FAIL_NEXT
54 DOWN_NUM=0   # number of nodes currently down
55
56 # set next client to fail
57 set_fail_client() {
58     FAIL_CLIENT=${FAIL_LIST[$FAIL_NEXT]}
59     FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
60     echo "fail $FAIL_CLIENT, next is $FAIL_NEXT"
61 }
62
63 fail_clients() {
64     num=$1
65
66     log "Request clients to fail: ${num}. Num of clients to fail: ${FAIL_NUM}, already failed: $DOWN_NUM"
67     if [ -z "$num"  ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
68         num=$((FAIL_NUM - DOWN_NUM)) 
69     fi
70     
71     if [ -z "$num" ] || [ "$num" -le 0 ]; then
72         log "No clients failed!"
73         return
74     fi
75
76     client_mkdirs
77
78     for i in `seq $num`; do
79        set_fail_client
80        client=$FAIL_CLIENT
81        DOWN_CLIENTS="$DOWN_CLIENTS $client"
82        shutdown_client $client
83     done
84
85     echo "down clients: $DOWN_CLIENTS"
86
87     for client in $DOWN_CLIENTS; do
88         boot_node $client
89     done
90     DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
91     client_rmdirs
92 }
93
94 reintegrate_clients() {
95     for client in $DOWN_CLIENTS; do
96         wait_for_host $client
97         echo "Restarting $client"
98         zconf_mount $client $MOUNT || return 1
99     done
100     DOWN_CLIENTS=""
101     DOWN_NUM=0
102 }
103
104 start_ost() {
105     start ost$1 `ostdevname $1` $OST_MOUNT_OPTS
106 }
107
108 trap exit INT
109
110 client_touch() {
111     file=$1
112     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
113         if echo $DOWN_CLIENTS | grep -q $c; then continue; fi
114         $PDSH $c touch $TESTDIR/${c}_$file || return 1
115     done
116 }
117
118 client_rm() {
119     file=$1
120     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
121         $PDSH $c rm $TESTDIR/${c}_$file
122     done
123 }
124
125 client_mkdirs() {
126     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
127         echo "$c mkdir $TESTDIR/$c"
128         $PDSH $c "mkdir $TESTDIR/$c && ls -l $TESTDIR/$c"
129     done
130 }
131
132 client_rmdirs() {
133     for c in $LIVE_CLIENT $FAIL_CLIENTS;  do
134         echo "rmdir $TESTDIR/$c"
135         $PDSH $LIVE_CLIENT "rmdir $TESTDIR/$c"
136     done
137 }
138
139 clients_recover_osts() {
140     facet=$1
141 #    do_node $CLIENTS "$LCTL "'--device %OSC_`hostname`_'"${facet}_svc_MNT_client_facet recover"
142 }
143
144 check_and_setup_lustre
145
146 rm -rf $TESTDIR
147 mkdir -p $TESTDIR
148
149 # 9 Different Failure Modes Combinations
150 echo "Starting Test 17 at `date`"
151
152 test_0() {
153     fail $SINGLEMDS
154
155     for i in $(seq $OSTCOUNT) ; do
156         fail ost$i
157     done
158     return 0
159 }
160 run_test 0 "Fail all nodes, independently"
161
162 ############### First Failure Mode ###############
163 test_1() {
164 echo "Don't do a MDS - MDS Failure Case"
165 echo "This makes no sense"
166 }
167 run_test 1 "MDS/MDS failure"
168 ###################################################
169
170 ############### Second Failure Mode ###############
171 test_2() {
172     echo "Verify Lustre filesystem is up and running"
173     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
174
175     clients_up
176
177     shutdown_facet $SINGLEMDS
178     reboot_facet $SINGLEMDS
179
180     # prepare for MDS failover
181     change_active $SINGLEMDS
182     reboot_facet $SINGLEMDS
183
184     clients_up &
185     DFPID=$!
186     sleep 5
187
188     shutdown_facet ost1
189
190     echo "Reintegrating OST"
191     reboot_facet ost1
192     wait_for_facet ost1
193     start_ost 1 || return 2
194
195     wait_for_facet $SINGLEMDS
196     start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || return $?
197
198     #Check FS
199     wait $DFPID
200     clients_recover_osts ost1
201     echo "Verify reintegration"
202     clients_up || return 1
203
204 }
205 run_test 2 "Second Failure Mode: MDS/OST `date`"
206 ###################################################
207
208
209 ############### Third Failure Mode ###############
210 test_3() {
211     #Create files
212     echo "Verify Lustre filesystem is up and running"
213     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
214     
215     #MDS Portion
216     fail $SINGLEMDS
217     #Check FS
218
219     echo "Test Lustre stability after MDS failover"
220     clients_up
221
222     #CLIENT Portion
223     echo "Failing 2 CLIENTS"
224     fail_clients 2
225     
226     #Check FS
227     echo "Test Lustre stability after CLIENT failure"
228     clients_up
229     
230     #Reintegration
231     echo "Reintegrating CLIENTS"
232     reintegrate_clients || return 1
233
234     clients_up || return 3
235     sleep 2 # give it a little time for fully recovered before next test
236 }
237 run_test 3  "Thirdb Failure Mode: MDS/CLIENT `date`"
238 ###################################################
239
240 ############### Fourth Failure Mode ###############
241 test_4() {
242     echo "Fourth Failure Mode: OST/MDS `date`"
243
244     #OST Portion
245     shutdown_facet ost1
246  
247     #Check FS
248     echo "Test Lustre stability after OST failure"
249     clients_up &
250     DFPIDA=$!
251     sleep 5
252
253     #MDS Portion
254     shutdown_facet $SINGLEMDS
255     reboot_facet $SINGLEMDS
256
257     # prepare for MDS failover
258     change_active $SINGLEMDS
259     reboot_facet $SINGLEMDS
260
261     clients_up &
262     DFPIDB=$!
263     sleep 5
264
265     #Reintegration
266     echo "Reintegrating OST"
267     reboot_facet ost1
268     wait_for_facet ost1
269     start_ost 1
270
271     wait_for_facet $SINGLEMDS
272     start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS
273     #Check FS
274     
275     wait $DFPIDA
276     wait $DFPIDB
277     clients_recover_osts ost1
278     echo "Test Lustre stability after MDS failover"
279     clients_up || return 1
280 }
281 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
282 ###################################################
283
284 ############### Fifth Failure Mode ###############
285 test_5() {
286     [ $OSTCOUNT -lt 2 ] && skip_env "$OSTCOUNT < 2, not enough OSTs" && return 0
287
288     echo "Fifth Failure Mode: OST/OST `date`"
289
290     #Create files
291     echo "Verify Lustre filesystem is up and running"
292     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
293
294     clients_up
295     
296     #OST Portion
297     shutdown_facet ost1
298     reboot_facet ost1
299     
300     #Check FS
301     echo "Test Lustre stability after OST failure"
302     clients_up &
303     DFPIDA=$!
304     sleep 5
305     
306     #OST Portion
307     shutdown_facet ost2
308     reboot_facet ost2
309
310     #Check FS
311     echo "Test Lustre stability after OST failure"
312     clients_up &
313     DFPIDB=$!
314     sleep 5
315
316     #Reintegration
317     echo "Reintegrating OSTs"
318     wait_for_facet ost1
319     start_ost 1
320     wait_for_facet ost2
321     start_ost 2
322     
323     clients_recover_osts ost1
324     clients_recover_osts ost2
325     sleep $TIMEOUT
326
327     wait $DFPIDA
328     wait $DFPIDB
329     clients_up || return 2
330 }
331 run_test 5 "Fifth Failure Mode: OST/OST `date`"
332 ###################################################
333
334 ############### Sixth Failure Mode ###############
335 test_6() {
336     echo "Sixth Failure Mode: OST/CLIENT `date`"
337
338     #Create files
339     echo "Verify Lustre filesystem is up and running"
340     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
341
342     clients_up
343     client_touch testfile || return 2
344         
345     #OST Portion
346     shutdown_facet ost1
347     reboot_facet ost1
348
349     #Check FS
350     echo "Test Lustre stability after OST failure"
351     clients_up &
352     DFPIDA=$!
353     echo DFPIDA=$DFPIDA
354     sleep 5
355
356     #CLIENT Portion
357     echo "Failing CLIENTs"
358     fail_clients
359     
360     #Check FS
361     echo "Test Lustre stability after CLIENTs failure"
362     clients_up &
363     DFPIDB=$!
364     echo DFPIDB=$DFPIDB
365     sleep 5
366     
367     #Reintegration
368     echo "Reintegrating OST/CLIENTs"
369     wait_for_facet ost1
370     start_ost 1
371     reintegrate_clients || return 1
372     sleep 5 
373
374     wait_remote_prog "stat -f" $((TIMEOUT * 3 + 20)) 
375     wait $DFPIDA
376     wait $DFPIDB
377
378     echo "Verifying mount"
379     [ -z "$(mounted_lustre_filesystems)" ] && return 3
380     clients_up
381 }
382 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
383 ###################################################
384
385
386 ############### Seventh Failure Mode ###############
387 test_7() {
388     echo "Seventh Failure Mode: CLIENT/MDS `date`"
389
390     #Create files
391     echo "Verify Lustre filesystem is up and running"
392     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
393
394     clients_up
395     client_touch testfile  || return 1
396
397     #CLIENT Portion
398     echo "Part 1: Failing CLIENT"
399     fail_clients 2
400     
401     #Check FS
402     echo "Test Lustre stability after CLIENTs failure"
403     clients_up
404     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
405     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
406     
407     #Sleep
408     echo "Wait 1 minutes"
409     sleep 60
410
411     #Create files
412     echo "Verify Lustre filesystem is up and running"
413     [ -z "$(mounted_lustre_filesystems)" ] && return 2
414
415     clients_up
416     client_rm testfile
417
418     #MDS Portion
419     fail $SINGLEMDS
420
421     $PDSH $LIVE_CLIENT "ls -l $TESTDIR"
422     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
423
424     #Reintegration
425     echo "Reintegrating CLIENTs"
426     reintegrate_clients || return 2
427     clients_up
428     
429     #Sleep
430     echo "wait 1 minutes"
431     sleep 60
432 }
433 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
434 ###################################################
435
436
437 ############### Eighth Failure Mode ###############
438 test_8() {
439     echo "Eighth Failure Mode: CLIENT/OST `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
447         
448     #CLIENT Portion
449     echo "Failing CLIENTs"
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)" ] && error "Lustre is not running"
465
466     clients_up
467     client_touch testfile
468
469
470     #OST Portion
471     shutdown_facet ost1
472     reboot_facet ost1
473
474     #Check FS
475     echo "Test Lustre stability after OST failure"
476     clients_up &
477     DFPID=$!
478     sleep 5
479     #non-failout hangs forever here
480     #$PDSH $LIVE_CLIENT "ls -l $TESTDIR"
481     #$PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile"
482     
483     #Reintegration
484     echo "Reintegrating CLIENTs/OST"
485     reintegrate_clients || return 3
486     wait_for_facet ost1
487     start_ost 1
488     wait $DFPID
489     clients_up || return 1
490     client_touch testfile2 || return 2
491
492     #Sleep
493     echo "Wait 1 minutes"
494     sleep 60
495 }
496 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
497 ###################################################
498
499
500 ############### Ninth Failure Mode ###############
501 test_9() {
502     echo 
503
504     #Create files
505     echo "Verify Lustre filesystem is up and running"
506     [ -z "$(mounted_lustre_filesystems)" ] && error "Lustre is not running"
507
508     clients_up
509     client_touch testfile || return 1
510         
511     #CLIENT Portion
512     echo "Failing CLIENTs"
513     fail_clients 2
514
515     #Check FS
516     echo "Test Lustre stability after CLIENTs failure"
517     clients_up
518     $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 1
519     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 2
520
521     #Sleep
522     echo "Wait 1 minutes"
523     sleep 60
524
525     #Create files
526     echo "Verify Lustre filesystem is up and running"
527     client_up $LIVE_CLIENT || return 3
528     client_touch testfile || return 4
529
530     #CLIENT Portion
531     echo "Failing CLIENTs"
532     fail_clients 2
533     
534     #Check FS
535     echo "Test Lustre stability after CLIENTs failure"
536     clients_up
537     $PDSH $LIVE_CLIENT "ls -l $TESTDIR" || return 5
538     $PDSH $LIVE_CLIENT "rm -f $TESTDIR/*_testfile" || return 6
539
540     #Reintegration
541     echo "Reintegrating  CLIENTs/CLIENTs"
542     reintegrate_clients || return 7
543     clients_up
544     
545     #Sleep
546     echo "Wait 1 minutes"
547     sleep 60
548 }
549 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
550 ###################################################
551
552 test_10() {
553     #Run availability after all failures
554     DURATION=${DURATION:-$((2 * 60 * 60))} # 6 hours default
555     LOADTEST=${LOADTEST:-metadata-load.py}
556     $PWD/availability.sh $CONFIG $DURATION $CLIENTS || return 1
557 }
558 run_test 10 "Running Availability for 6 hours..."
559
560 complete $(basename $0) $SECONDS
561 check_and_cleanup_lustre
562 exit_status