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