Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[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=""
14
15 build_test_filter
16
17 assert_env mds_HOST ost1_HOST ost2_HOST client_HOST LIVE_CLIENT 
18
19 # This can be a regexp, to allow more clients
20 CLIENTS=${CLIENTS:-"`comma_list $LIVE_CLIENT $FAIL_CLIENTS`"}
21
22 CLIENTLIST="$LIVE_CLIENT $FAIL_CLIENTS"
23
24 DIR=${DIR:-$MOUNT}
25
26 #####
27 # fail clients round robin
28
29 # list of failable clients
30 FAIL_LIST=($FAIL_CLIENTS)
31 FAIL_NUM=${#FAIL_LIST[*]}
32 FAIL_NEXT=0
33 DOWN_NUM=0   # number of nodes currently down
34
35 # return next client to fail
36 fail_client() {
37     ret=${FAIL_LIST[$FAIL_NEXT]}
38     FAIL_NEXT=$(( (FAIL_NEXT+1) % FAIL_NUM ))
39     echo $ret
40 }
41
42 shutdown_client() {
43     client=$1
44     if [ "$FAILURE_MODE" = HARD ]; then
45        $POWER_DOWN $client
46     elif [ "$FAILURE_MODE" = SOFT ]; then
47        $PDSH $client $LCONF --clenaup --force --nomod $XMLCONFIG
48     fi
49 }
50
51 reboot_node() {
52     NODE=$1
53     if [ "$FAILURE_MODE" = HARD ]; then
54        $POWER_UP $NODE
55     fi
56 }
57
58 fail_clients() {
59     num=$1
60     if [ -z "$num" -o $num -gt $((FAIL_NUM - DOWN_NUM)) ]; then
61         num=$((FAIL_NUM - DOWN_NUM)) 
62     fi
63     
64     if [ -z "$num"  -o $num -le 0 ]; then
65         return
66     fi
67
68     for i in `seq $num`; do
69        client=`fail_client`
70        DOWN_CLIENTS="$DOWN_CLIENTS $client"
71        client_mkdirs
72        shutdown_client $client
73     done
74
75     for client in $DOWN_CLIENTS; do
76         reboot_node $client
77     done
78     DOWN_NUM=`echo $DOWN_CLIENTS | wc -w`
79     $PDSH $LIVE_CLIENT "cd $MOUNT && rmdir $CLIENTLIST"
80 }
81
82 reintegrate_clients() {
83     for client in $DOWN_CLIENTS; do
84         wait_for_host $client
85         $PDSH $client "$LCONF --node client --select mds_svc=`facet_active mds` $CLIENTOPTS $XMLCONFIG"
86     done
87     DOWN_CLIENTS=""
88     DOWN_NUM=0
89 }
90
91 gen_config() {
92     rm -f $XMLCONFIG
93     add_mds mds --dev $MDSDEV --size $MDSSIZE
94
95     if [ ! -z "$mdsfailover_HOST" ]; then
96          add_mdsfailover mds --dev $MDSDEV --size $MDSSIZE
97     fi
98
99     add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
100         --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
101     add_ost ost1 --lov lov1 --dev $OSTDEV --size $OSTSIZE
102     add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
103     add_client client mds --lov lov1 --path $MOUNT
104 }
105
106 setup() {
107     wait_for ost1
108     start ost1 ${REFORMAT} $OSTLCONFARGS 
109     wait_for ost2
110     start ost2 ${REFORMAT} $OSTLCONFARGS 
111     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
112     wait_for mds
113     start mds $MDSLCONFARGS ${REFORMAT}
114     while ! $PDSH $HOST "ls -ld $LUSTRE"; do sleep 5; done
115     do_node $CLIENTS lconf --node client_facet \
116         --select mds_service=$ACTIVEMDS $XMLCONFIG
117 }
118
119 cleanup() {
120     # make sure we are using the primary MDS, so the config log will
121     # be able to clean up properly.
122     activemds=`facet_active mds`
123 #    if [ $activemds != "mds" ]; then
124 #        fail mds
125 #    fi
126     for node in $CLIENTS; do
127         do_node $node lconf ${FORCE} --select mds_svc=${activemds}_facet --cleanup --node client_facet $XMLCONFIG || true
128     done
129
130     stop mds ${FORCE} $MDSLCONFARGS
131     stop ost1 ${FORCE}
132     stop ost2 ${FORCE} --dump cleanup.log
133 }
134
135 trap exit INT
136
137 client_mkdirs() {
138    $PDSH $CLIENTS "mkdir $MOUNT/\`hostname\`; ls $MOUNT/\`hostname\` > /dev/null"
139 }
140
141 clients_recover_osts() {
142     facet=$1
143     $PDSH $CLIENTS "$LCTL "'--device %OSC_`hostname`_OST_'"${facet}_svc_MNT_client recover"
144 }
145
146 if [ "$ONLY" == "cleanup" ]; then
147     cleanup
148     exit
149 fi
150
151 gen_config
152 setup
153
154 if [ "$ONLY" == "setup" ]; then
155     exit 0
156 fi
157
158 # 9 Different Failure Modes Combinations
159 echo "Starting Test 17 at `date`"
160
161 test_0() {
162     echo "Failover MDS"
163     facet_failover mds
164     wait $DFPID || return 1
165
166     echo "Failing OST1"
167     facet_failover ost1
168     wait $DFPID || return 2
169
170     echo "Failing OST2"
171     facet_failover ost2
172     wait $DFPID || return 3
173     return 0
174 }
175 run_test 0 "Fail all nodes, independently"
176
177 ############### First Failure Mode ###############
178 test_1() {
179 echo "Don't do a MDS - MDS Failure Case"
180 echo "This makes no sense"
181 # FIXME every test makes sense
182 }
183 run_test 1 "MDS/MDS failure"
184 ###################################################
185
186 ############### Second Failure Mode ###############
187 test_2() {
188     echo "Verify Lustre filesystem is up and running"
189     client_df
190
191     echo "Failing MDS"
192     shutdown_facet mds
193     reboot_facet mds
194
195     # prepare for MDS failover
196     change_active mds
197     reboot_facet mds
198
199     client_df &
200     DFPID=$!
201     sleep 5
202
203     echo "Failing OST"
204     shutdown_facet ost1
205
206     echo "Reintegrating OST"
207     reboot_facet ost1
208     wait_for ost1
209     start ost1
210
211     echo "Failover MDS"
212     wait_for mds
213     start mds
214
215     #Check FS
216     wait $DFPID
217     clients_recover_osts ost1
218     echo "Verify reintegration"
219     client_df
220
221 }
222 run_test 2 "Second Failure Mode: MDS/OST `date`"
223 ###################################################
224
225
226 ############### Third Failure Mode ###############
227 test_3() {
228     #Create files
229     echo "Verify Lustre filesystem is up and running"
230     
231     #MDS Portion
232     facet_failover mds
233     wait $DFPID || echo df failed: $?
234     #Check FS
235
236     echo "Test Lustre stability after MDS failover"
237     client_df
238
239     #CLIENT Portion
240     echo "Failing 2 CLIENTS"
241     fail_clients 2
242     
243     #Check FS
244     echo "Test Lustre stability after CLIENT failure"
245     client_df
246     
247     #Reintegration
248     echo "Reintegrating CLIENTS"
249     reintegrate_clients
250
251     client_df
252 }
253 run_test 3  "Thirdb Failure Mode: MDS/CLIENT `date`"
254 ###################################################
255
256 ############### Fourth Failure Mode ###############
257 test_4() {
258     echo "Fourth Failure Mode: OST/MDS `date`"
259
260     #OST Portion
261     echo "Failing OST ost1"
262     shutdown_facet ost1
263  
264     #Check FS
265     echo "Test Lustre stability after OST failure"
266     client_df
267
268     #MDS Portion
269     echo "Failing MDS"
270     shutdown_facet mds
271     reboot_facet mds
272
273     # prepare for MDS failover
274     change_active mds
275     reboot_facet mds
276
277     client_df &
278     DFPID=$!
279     sleep 5
280
281     #Reintegration
282     echo "Reintegrating OST"
283     reboot_facet ost1
284     wait_for ost1
285     start ost1
286     
287     echo "Failover MDS"
288     wait_for mds
289     start mds
290     #Check FS
291     
292     wait $DFPID
293     clients_recover_osts ost1
294     echo "Test Lustre stability after MDS failover"
295     client_df
296 }
297 run_test 4 "Fourth Failure Mode: OST/MDS `date`"
298 ###################################################
299
300 ############### Fifth Failure Mode ###############
301 test_5() {
302     echo "Fifth Failure Mode: OST/OST `date`"
303
304     #Create files
305     echo "Verify Lustre filesystem is up and running"
306     client_df
307     
308     #OST Portion
309     echo "Failing OST"
310     shutdown_facet ost1
311     reboot_facet ost1
312     
313     #Check FS
314     echo "Test Lustre stability after OST failure"
315     client_df
316     
317     #OST Portion
318     echo "Failing OST"
319     shutdown_node ost2
320     reboot_facet ost2
321
322     #Check FS
323     echo "Test Lustre stability after OST failure"
324     client_df
325
326     #Reintegration
327     echo "Reintegrating OSTs"
328     wait_for ost1
329     wait_for ost1
330     start ost1
331     start ost2
332     
333     clients_recover_osts ost1
334     clients_recover_osts ost2
335     client_df
336 }
337 run_test 5 "Fifth Failure Mode: OST/OST `date`"
338 ###################################################
339
340 ############### Sixth Failure Mode ###############
341 test_6() {
342     echo "Sixth Failure Mode: OST/CLIENT `date`"
343
344     #Create files
345     echo "Verify Lustre filesystem is up and running"
346     client_df
347     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
348         
349     #OST Portion
350     echo "Failing OST"
351     shutdown_node ost1
352     reboot_facet ost1
353
354     #Check FS
355     echo "Test Lustre stability after OST failure"
356     client_df
357
358     #CLIENT Portion
359     echo "Failing CLIENTs"
360     fail_clients
361     
362     #Check FS
363     echo "Test Lustre stability after CLIENTs failure"
364     client_df
365     
366     #Reintegration
367     echo "Reintegrating OST/CLIENTs"
368     wait_for ost1
369     start ost1
370     reintegrate_clients
371     
372     echo "Verifying mount"
373     client_df
374 }
375 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
376 ###################################################
377
378
379 ############### Seventh Failure Mode ###############
380 test_7() {
381     echo "Seventh Failure Mode: CLIENT/MDS `date`"
382
383     #Create files
384     echo "Verify Lustre filesystem is up and running"
385     client_df
386     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
387
388     #CLIENT Portion
389     echo "Part 1: Failing CLIENT"
390     fail_clients 2
391     
392     #Check FS
393     echo "Test Lustre stability after CLIENTs failure"
394     client_df
395     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
396     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
397     
398     #Sleep
399     echo "Wait 1 minutes"
400     sleep 60
401
402     #Create files
403     echo "Verify Lustre filesystem is up and running"
404     client_df
405     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
406
407     #MDS Portion
408     echo "Failing MDS"
409     facet_failover mds
410
411     #Check FS
412     echo "Test Lustre stability after MDS failover"
413     client_df
414     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
415     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
416
417     #Reintegration
418     echo "Reintegrating CLIENTs"
419     reintegrate_clients
420     client_df
421     
422     #Sleep
423     echo "wait 1 minutes"
424     sleep 60
425 }
426 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
427 ###################################################
428
429
430 ############### Eighth Failure Mode ###############
431 test_8() {
432     echo "Eighth Failure Mode: CLIENT/OST `date`"
433
434     #Create files
435     echo "Verify Lustre filesystem is up and running"
436     client_df
437     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
438         
439     #CLIENT Portion
440     echo "Failing CLIENTs"
441     fail_clients 2
442
443     #Check FS
444     echo "Test Lustre stability after CLIENTs failure"
445     client_df
446     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
447     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
448
449     #Sleep
450     echo "Wait 1 minutes"
451     sleep 60
452
453     #Create files
454     echo "Verify Lustre filesystem is up and running"
455     client_df
456     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
457
458     #OST Portion
459     echo "Failing OST"
460     shutdown_node ost1
461     reboot_facet ost1
462
463     #Check FS
464     echo "Test Lustre stability after OST failure"
465     client_df
466     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
467     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
468     
469     #Reintegration
470     echo "Reintegrating CLIENTs/OST"
471     reintegrate_clients
472     start ost1
473     client_df
474     $PDSH $CLIENTS "/bin/touch $MOUNT/CLIENT_OST_2\`hostname\`_testfile"
475
476     #Sleep
477     echo "Wait 1 minutes"
478     sleep 60
479 }
480 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
481 ###################################################
482
483
484 ############### Ninth Failure Mode ###############
485 test_9() {
486     echo 
487
488     #Create files
489     echo "Verify Lustre filesystem is up and running"
490     client_df
491     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
492         
493     #CLIENT Portion
494     echo "Failing CLIENTs"
495     fail_clients 2
496
497     #Check FS
498     echo "Test Lustre stability after CLIENTs failure"
499     client_df
500     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
501     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
502
503     #Sleep
504     echo "Wait 1 minutes"
505     sleep 60
506
507     #Create files
508     echo "Verify Lustre filesystem is up and running"
509     client_df
510     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
511
512     #CLIENT Portion
513     echo "Failing CLIENTs"
514     fail_clients 2
515     
516     #Check FS
517     echo "Test Lustre stability after CLIENTs failure"
518     client_df
519     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
520     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
521
522     #Reintegration
523     echo "Reintegrating  CLIENTs/CLIENTs"
524     reintegrate_clients
525     client_df
526     
527     #Sleep
528     echo "Wait 1 minutes"
529     sleep 60
530 }
531 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
532 ###################################################
533
534 test_10() {
535     #Run availability after all failures
536     ./availability.sh  21600
537 }
538 run_test 10 "Running Availability for 6 hours..."
539
540 equals_msg "Done, cleaning up"
541 cleanup