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