Whamcloud - gitweb
b=1719
[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"
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"  ] || [ "$num" -gt $((FAIL_NUM - DOWN_NUM)) ]; then
61         num=$((FAIL_NUM - DOWN_NUM)) 
62     fi
63     
64     if [ -z "$num" ] || [ "$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 ! do_node $HOST "$CHECKSTAT -t dir $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`_'"${facet}_svc_MNT_client_facet 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 || return 1
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 || return 1
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 || return 1
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_facet 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     sleep 5
336     client_df || return 1
337 }
338 run_test 5 "Fifth Failure Mode: OST/OST `date`"
339 ###################################################
340
341 ############### Sixth Failure Mode ###############
342 test_6() {
343     echo "Sixth Failure Mode: OST/CLIENT `date`"
344
345     #Create files
346     echo "Verify Lustre filesystem is up and running"
347     client_df || return 1
348     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile" || return 2
349         
350     #OST Portion
351     echo "Failing OST"
352     shutdown_facet ost1
353     reboot_facet ost1
354
355     #Check FS
356     echo "Test Lustre stability after OST failure"
357     client_df
358
359     #CLIENT Portion
360     echo "Failing CLIENTs"
361     fail_clients
362     
363     #Check FS
364     echo "Test Lustre stability after CLIENTs failure"
365     client_df
366     
367     #Reintegration
368     echo "Reintegrating OST/CLIENTs"
369     wait_for ost1
370     start ost1
371     reintegrate_clients
372     sleep 5 
373
374     echo "Verifying mount"
375     client_df || return 3
376 }
377 run_test 6 "Sixth Failure Mode: OST/CLIENT `date`"
378 ###################################################
379
380
381 ############### Seventh Failure Mode ###############
382 test_7() {
383     echo "Seventh Failure Mode: CLIENT/MDS `date`"
384
385     #Create files
386     echo "Verify Lustre filesystem is up and running"
387     client_df
388     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
389
390     #CLIENT Portion
391     echo "Part 1: Failing CLIENT"
392     fail_clients 2
393     
394     #Check FS
395     echo "Test Lustre stability after CLIENTs failure"
396     client_df
397     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
398     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
399     
400     #Sleep
401     echo "Wait 1 minutes"
402     sleep 60
403
404     #Create files
405     echo "Verify Lustre filesystem is up and running"
406     client_df
407     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
408
409     #MDS Portion
410     echo "Failing MDS"
411     facet_failover mds
412
413     #Check FS
414     echo "Test Lustre stability after MDS failover"
415     client_df
416     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
417     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
418
419     #Reintegration
420     echo "Reintegrating CLIENTs"
421     reintegrate_clients
422     client_df || return 1
423     
424     #Sleep
425     echo "wait 1 minutes"
426     sleep 60
427 }
428 run_test 7 "Seventh Failure Mode: CLIENT/MDS `date`"
429 ###################################################
430
431
432 ############### Eighth Failure Mode ###############
433 test_8() {
434     echo "Eighth Failure Mode: CLIENT/OST `date`"
435
436     #Create files
437     echo "Verify Lustre filesystem is up and running"
438     client_df
439     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
440         
441     #CLIENT Portion
442     echo "Failing CLIENTs"
443     fail_clients 2
444
445     #Check FS
446     echo "Test Lustre stability after CLIENTs failure"
447     client_df
448     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
449     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_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     client_df
458     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
459
460     #OST Portion
461     echo "Failing OST"
462     shutdown_facet ost1
463     reboot_facet ost1
464
465     #Check FS
466     echo "Test Lustre stability after OST failure"
467     client_df
468     $PDSH $LIVE_CLIENT "ls -l $MOUNT"
469     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile"
470     
471     #Reintegration
472     echo "Reintegrating CLIENTs/OST"
473     reintegrate_clients
474     start ost1
475     client_df || return 1
476     $PDSH $CLIENTS "/bin/touch $MOUNT/CLIENT_OST_2\`hostname\`_testfile" || return 2
477
478     #Sleep
479     echo "Wait 1 minutes"
480     sleep 60
481 }
482 run_test 8 "Eighth Failure Mode: CLIENT/OST `date`"
483 ###################################################
484
485
486 ############### Ninth Failure Mode ###############
487 test_9() {
488     echo 
489
490     #Create files
491     echo "Verify Lustre filesystem is up and running"
492     client_df
493     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile"
494         
495     #CLIENT Portion
496     echo "Failing CLIENTs"
497     fail_clients 2
498
499     #Check FS
500     echo "Test Lustre stability after CLIENTs failure"
501     client_df
502     $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 1
503     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 2
504
505     #Sleep
506     echo "Wait 1 minutes"
507     sleep 60
508
509     #Create files
510     echo "Verify Lustre filesystem is up and running"
511     client_df || return 3
512     $PDSH $CLIENTS "/bin/touch $MOUNT/\`hostname\`_testfile" || return 4
513
514     #CLIENT Portion
515     echo "Failing CLIENTs"
516     fail_clients 2
517     
518     #Check FS
519     echo "Test Lustre stability after CLIENTs failure"
520     client_df
521     $PDSH $LIVE_CLIENT "ls -l $MOUNT" || return 5
522     $PDSH $LIVE_CLIENT "rm -f $MOUNT/*_testfile" || return 6
523
524     #Reintegration
525     echo "Reintegrating  CLIENTs/CLIENTs"
526     reintegrate_clients
527     client_df || return 7
528     
529     #Sleep
530     echo "Wait 1 minutes"
531     sleep 60
532 }
533 run_test 9 "Ninth Failure Mode: CLIENT/CLIENT `date`"
534 ###################################################
535
536 test_10() {
537     #Run availability after all failures
538     ./availability.sh  21600
539 }
540 run_test 10 "Running Availability for 6 hours..."
541
542 equals_msg "Done, cleaning up"
543 cleanup