Whamcloud - gitweb
land lustre part of b_hd_sec on HEAD.
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
1 #!/bin/bash
2 # requirement:
3 #       add uml1 uml2 uml3 in your /etc/hosts
4
5 # FIXME - there is no reason to use all of these different
6 #   return codes, espcially when most of them are mapped to something
7 #   else anyway.  The combination of test number and return code
8 #   figure out what failed.
9
10 set -e
11
12 SRCDIR=`dirname $0`
13 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
14
15 LUSTRE=${LUSTRE:-`dirname $0`/..}
16 RLUSTRE=${RLUSTRE:-$LUSTRE}
17 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
18
19 . $LUSTRE/tests/test-framework.sh
20
21 init_test_env $@
22
23 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
24
25 gen_config() {
26         rm -f $XMLCONFIG
27
28         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
29         add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES\
30             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
31         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
32         add_client client mds1 --lov lov1 --path $MOUNT
33 }
34
35 gen_second_config() {
36         rm -f $XMLCONFIG
37
38         add_mds mds2 --dev $MDSDEV --size $MDSSIZE
39         add_lov lov2 mds2 --stripe_sz $STRIPE_BYTES\
40             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
41         add_ost ost2 --lov lov2 --dev $OSTDEV --size $OSTSIZE
42         add_client client --mds mds2 --lov lov2 --path $MOUNT2
43 }
44
45 start_mds() {
46         echo "start mds1 service on `facet_active_host mds1`"
47         start mds1 --reformat $MDSLCONFARGS  || return 94
48         start_lsvcgssd || return 501
49 }
50 stop_mds() {
51         echo "stop mds1 service on `facet_active_host mds1`"
52         stop mds1 $@  || return 97
53         stop_lsvcgssd
54 }
55
56 start_ost() {
57         echo "start ost service on `facet_active_host ost`"
58         start ost --reformat $OSTLCONFARGS  || return 95
59 }
60
61 stop_ost() {
62         echo "stop ost service on `facet_active_host ost`"
63         stop ost $@  || return 98
64 }
65
66 mount_client() {
67         local MOUNTPATH=$1
68         start_lgssd || return 502
69         echo "mount lustre on ${MOUNTPATH}....."
70         zconf_mount `hostname`  $MOUNTPATH  || return 96
71 }
72
73 umount_client() {
74         local MOUNTPATH=$1
75         echo "umount lustre on ${MOUNTPATH}....."
76         zconf_umount `hostname`  $MOUNTPATH || return 97
77         stop_lgssd
78 }
79
80 manual_umount_client(){
81         echo "manual umount lustre on ${MOUNTPATH}...."
82         do_facet  client "umount $MOUNT"
83         stop_lgssd
84 }
85
86 setup() {
87         start_ost
88         start_mds
89         mount_client $MOUNT
90 }
91
92 cleanup() {
93         umount_client $MOUNT || return 200
94         stop_mds || return 201
95         stop_ost || return 202
96         # catch case where these return just fine, but modules are still not unloaded
97         /sbin/lsmod | grep -q portals
98         if [ 1 -ne $? ]; then
99                 echo "modules still loaded..."
100                 return 203
101         fi
102 }
103
104 check_mount() {
105         do_facet client "touch $DIR/a" || return 71     
106         do_facet client "rm $DIR/a" || return 72        
107         echo "setup single mount lustre success"
108 }
109
110 check_mount2() {
111         do_facet client "touch $DIR/a" || return 71     
112         do_facet client "rm $DIR/a" || return 72        
113         do_facet client "touch $DIR2/a" || return 73    
114         do_facet client "rm $DIR2/a" || return 74       
115         echo "setup double mount lustre success"
116 }
117
118 build_test_filter
119
120 #create single point mountpoint
121
122 gen_config
123 start_krb5_kdc || exit 1
124
125
126 test_0() {
127         start_ost
128         start_mds       
129         mount_client $MOUNT
130         check_mount || return 41
131         cleanup || return $?
132 }
133 run_test 0 "single mount setup"
134
135 test_1() {
136         start_ost
137         echo "start ost second time..."
138         start ost --reformat $OSTLCONFARGS
139         start_mds       
140         mount_client $MOUNT
141         check_mount || return 42
142         cleanup || return $?
143 }
144 run_test 1 "start up ost twice"
145
146 test_2() {
147         start_ost
148         start_mds       
149         echo "start mds second time.."
150         start mds1 --reformat $MDSLCONFARGS
151         
152         mount_client $MOUNT
153         check_mount || return 43
154         cleanup || return $?
155 }
156 run_test 2 "start up mds twice"
157
158 test_3() {
159         setup
160         mount_client $MOUNT
161
162         check_mount || return 44
163         
164         umount_client $MOUNT    
165         cleanup  || return $?
166 }
167 run_test 3 "mount client twice"
168
169 test_4() {
170         setup
171         touch $DIR/$tfile || return 85
172         stop_ost --force
173         cleanup
174         eno=$?
175         # ok for ost to fail shutdown
176         if [ 202 -ne $eno ]; then
177                 return $eno;
178         fi
179         return 0
180 }
181 run_test 4 "force cleanup ost, then cleanup"
182
183 test_5() {
184         setup
185         touch $DIR/$tfile || return 1
186         stop_mds --force || return 2
187
188         # cleanup may return an error from the failed
189         # disconnects; for now I'll consider this successful
190         # if all the modules have unloaded.
191         umount $MOUNT &
192         UMOUNT_PID=$!
193         sleep 2
194         echo "killing umount"
195         kill -TERM $UMOUNT_PID
196         echo "waiting for umount to finish"
197         wait $UMOUNT_PID
198         stop_lgssd
199
200         # cleanup client modules
201         $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
202         
203         # stop_mds is a no-op here, and should not fail
204         stop_mds  || return 4
205         stop_ost || return 5
206
207         lsmod | grep -q portals && return 6
208         return 0
209 }
210 run_test 5 "force cleanup mds, then cleanup"
211
212 test_5b() {
213         start_ost
214         start_mds
215         stop_mds
216
217         [ -d $MOUNT ] || mkdir -p $MOUNT
218         $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
219         start_lgssd || return 1
220         llmount $mds_HOST://mds1_svc/client_facet $MOUNT  && exit 1
221
222         # cleanup client modules
223         $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
224         stop_lgssd
225         
226         # stop_mds is a no-op here, and should not fail
227         stop_mds || return 2
228         stop_ost || return 3
229
230         lsmod | grep -q portals && return 4 
231         return 0
232
233 }
234 run_test 5b "mds down, cleanup after failed mount (bug 2712)"
235
236 test_5c() {
237         start_ost
238         start_mds
239
240         [ -d $MOUNT ] || mkdir -p $MOUNT
241         $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
242         start_lgssd || return 1
243         llmount $mds_HOST://wrong_mds1_svc/client_facet $MOUNT  && return 2
244
245         # cleanup client modules
246         $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
247         stop_lgssd
248         
249         stop_mds || return 3
250         stop_ost || return 4
251
252         lsmod | grep -q portals && return 5
253         return 0
254
255 }
256 run_test 5c "cleanup after failed mount (bug 2712)"
257
258 test_5d() {
259        start_ost
260        start_mds
261        stop_ost --force
262
263        [ -d $MOUNT ] || mkdir -p $MOUNT
264        $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
265        start_lgssd || return 1
266        llmount $mds_HOST://mds1_svc/client_facet $MOUNT  || return 1
267
268        umount $MOUNT || return 2
269        # cleanup client modules
270        $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
271        stop_lgssd
272
273        stop_mds || return 3
274
275        lsmod | grep -q portals && return 4
276        return 0
277
278 }
279 run_test 5d "ost down, don't crash during mount attempt"
280
281 test_6() {
282         setup
283         manual_umount_client
284         mount_client ${MOUNT} || return 87
285         touch $DIR/a || return 86
286         cleanup  || return $?
287 }
288 run_test 6 "manual umount, then mount again"
289
290 test_7() {
291         setup
292         manual_umount_client
293         cleanup || return $?
294 }
295 run_test 7 "manual umount, then cleanup"
296
297 test_8() {
298         start_ost
299         start_mds
300
301         mount_client $MOUNT
302         mount_client $MOUNT2
303
304         check_mount2 || return 45
305         umount $MOUNT
306         umount_client $MOUNT2
307         
308         stop_mds
309         stop_ost
310 }
311 run_test 8 "double mount setup"
312
313 test_9() {
314         # backup the old values of PTLDEBUG and SUBSYSTEM
315         OLDPTLDEBUG=$PTLDEBUG
316         OLDSUBSYSTEM=$SUBSYSTEM
317
318         # generate new configuration file with lmc --ptldebug and --subsystem
319         PTLDEBUG="trace"
320         SUBSYSTEM="mdc"
321         gen_config
322
323         # check the result of lmc --ptldebug/subsystem
324         start_ost
325         start_mds
326         mount_client $MOUNT
327         CHECK_PTLDEBUG="`cat /proc/sys/portals/debug`"
328         if [ $CHECK_PTLDEBUG = "1" ]; then
329            echo "lmc --debug success"
330         else
331            echo "lmc --debug: want 1, have $CHECK_PTLDEBUG"
332            return 1
333         fi
334         CHECK_SUBSYSTEM="`cat /proc/sys/portals/subsystem_debug`"
335         if [ $CHECK_SUBSYSTEM = "2" ]; then
336            echo "lmc --subsystem success"
337         else
338            echo "lmc --subsystem: want 2, have $CHECK_SUBSYSTEM"
339            return 1
340         fi
341         check_mount || return 41
342         cleanup || return $?
343
344         # the new PTLDEBUG/SUBSYSTEM used for lconf --ptldebug/subsystem
345         PTLDEBUG="inode+trace"
346         SUBSYSTEM="mds+ost"
347
348         # check lconf --ptldebug/subsystem overriding lmc --ptldebug/subsystem
349         start_ost
350         start_mds
351         CHECK_PTLDEBUG="`do_facet mds1 cat /proc/sys/portals/debug`"
352         if [ $CHECK_PTLDEBUG = "3" ]; then
353            echo "lconf --debug success"
354         else
355            echo "lconf --debug: want 3, have $CHECK_PTLDEBUG"
356            return 1
357         fi
358         CHECK_SUBSYSTEM="`do_facet mds1 cat /proc/sys/portals/subsystem_debug`"
359         if [ $CHECK_SUBSYSTEM = "20" ]; then
360            echo "lconf --subsystem success"
361         else
362            echo "lconf --subsystem: want 20, have $CHECK_SUBSYSTEM"
363            return 1
364         fi
365         mount_client $MOUNT
366         check_mount || return 41
367         cleanup || return $?
368
369         # resume the old configuration
370         PTLDEBUG=$OLDPTLDEBUG
371         SUBSYSTEM=$OLDSUBSYSTEM
372         gen_config
373 }
374
375 run_test 9 "test --ptldebug and --subsystem for lmc and lconf"
376
377 test_10() {
378         echo "generate configuration with the same name for node and mds"
379         OLDXMLCONFIG=$XMLCONFIG
380         XMLCONFIG="broken.xml"
381         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
382         facet="mds1"
383         rm -f ${facet}active
384         add_facet $facet
385         echo "the name for node and mds is the same"
386         do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \
387             --dev $MDSDEV --size $MDSSIZE || return $?
388         do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \
389             $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \
390             --stripe_pattern 0 || return $?
391         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
392         facet="client"
393         add_facet $facet --lustre_upcall $UPCALL
394         do_lmc --add mtpt --node ${facet}_facet --mds mds1_facet \
395             --lov lov1 --path $MOUNT
396
397         echo "mount lustre"
398         start_ost
399         start_mds
400         mount_client $MOUNT
401         check_mount || return 41
402         cleanup || return $?
403
404         echo "Success!"
405         XMLCONFIG=$OLDXMLCONFIG
406 }
407 run_test 10 "mount lustre with the same name for node and mds"
408
409 test_11() {
410         OLDXMLCONFIG=$XMLCONFIG
411         XMLCONFIG="conf11.xml"
412
413         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
414         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
415         add_ost ost --dev $OSTDEV --size $OSTSIZE
416         add_client client mds1 --path $MOUNT --ost ost_svc || return $?
417         echo "Default lov config success!"
418
419         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
420         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
421         add_ost ost --dev $OSTDEV --size $OSTSIZE
422         add_client client mds1 --path $MOUNT && return $?
423         echo "--add mtpt with neither --lov nor --ost will return error"
424
425         echo ""
426         echo "Success!"
427         XMLCONFIG=$OLDXMLCONFIG
428 }
429 run_test 11 "use default lov configuration (should return error)"
430
431 test_12() {
432         OLDXMLCONFIG=$XMLCONFIG
433         XMLCONFIG="batch.xml"
434         BATCHFILE="batchfile"
435
436         # test double quote
437         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
438         [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
439         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
440         echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE
441         # --mkfsoptions "-I 128"
442         do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
443         if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
444                 echo "matched double quote success"
445         else
446                 echo "matched double quote fail"
447                 return 1
448         fi
449         rm -f $XMLCONFIG
450         rm -f $BATCHFILE
451         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
452         echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
453         # --mkfsoptions "-I 128
454         do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
455         echo "unmatched double quote should return error"
456
457         # test single quote
458         rm -f $BATCHFILE
459         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
460         echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE
461         # --mkfsoptions '-I 128'
462         do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
463         if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
464                 echo "matched single quote success"
465         else
466                 echo "matched single quote fail"
467                 return 1
468         fi
469         rm -f $XMLCONFIG
470         rm -f $BATCHFILE
471         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
472         echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
473         # --mkfsoptions '-I 128
474         do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
475         echo "unmatched single quote should return error"
476
477         # test backslash
478         rm -f $BATCHFILE
479         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
480         echo "--add mds --node localhost --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE
481         # --mkfsoptions \-\I\ \128
482         do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
483         if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
484                 echo "backslash followed by a whitespace/letter success"
485         else
486                 echo "backslash followed by a whitespace/letter fail"
487                 return 1
488         fi
489         rm -f $XMLCONFIG
490         rm -f $BATCHFILE
491         echo "--add net --node  localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
492         echo "--add mds --node localhost --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
493         # --mkfsoptions -I\ 128\
494         do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
495         echo "backslash followed by nothing should return error"
496
497         rm -f $BATCHFILE
498         XMLCONFIG=$OLDXMLCONFIG
499 }
500 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
501
502 test_13() {
503         OLDXMLCONFIG=$XMLCONFIG
504         XMLCONFIG="conf13-1.xml"
505         SECONDXMLCONFIG="conf13-2.xml"
506
507         # check long uuid will be truncated properly and uniquely
508         echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
509         [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
510         do_lmc --add net --node localhost --nid localhost.localdomain --nettype tcp
511         do_lmc --add mds --node localhost --mds mds1_name_longer_than_31characters
512         do_lmc --add mds --node localhost --mds mds2_name_longer_than_31characters
513         if [ ! -f "$XMLCONFIG" ]; then
514                 echo "Error:no file $XMLCONFIG created!"
515                 return 1
516         fi
517         EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
518         EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
519         FOUNDMDS1UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '1p' \
520                        | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
521         FOUNDMDS2UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '2p' \
522                        | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
523         if ([ $EXPECTEDMDS1UUID = $FOUNDMDS1UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS2UUID ]) || \
524            ([ $EXPECTEDMDS1UUID = $FOUNDMDS2UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS1UUID ]); then
525                 echo "Success:long uuid truncated successfully and being unique."
526         else
527                 echo "Error:expected uuid for mds1 and mds2: $EXPECTEDMDS1UUID; $EXPECTEDMDS2UUID"
528                 echo "but:     found uuid for mds1 and mds2: $FOUNDMDS1UUID; $FOUNDMDS2UUID"
529                 return 1
530         fi
531
532         # check multiple invocations for lmc generate same XML configuration file
533         rm -f $XMLCONFIG
534         echo "Generate the first XML configuration file"
535         gen_config
536         echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
537         mv $XMLCONFIG $SECONDXMLCONFIG || return $?
538         echo "Generate the second XML configuration file"
539         gen_config
540         if [ `diff $XMLCONFIG $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
541                 echo "Success:multiple invocations for lmc generate same XML file"
542         else
543                 echo "Error: multiple invocations for lmc generate different XML file"
544                 return 1
545         fi
546
547         rm -f $XMLCONFIG
548         rm -f $SECONDXMLCONFIG
549         XMLCONFIG=$OLDXMLCONFIG
550 }
551 run_test 13 "check new_uuid of lmc operating correctly"
552
553 test_14() {
554         rm -f $XMLCONFIG
555
556         # create xml file with --mkfsoptions for ost
557         echo "create xml file with --mkfsoptions for ost"
558         add_mds mds1 --dev $MDSDEV --size $MDSSIZE
559         add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES\
560             --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
561         add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
562             --mkfsoptions "-Llabel_conf_14"
563         add_client client mds1 --lov lov1 --path $MOUNT
564
565         FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
566         EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
567         if [ $EXPECTEDSTRING != $FOUNDSTRING ]; then
568                 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
569                 return 1
570         fi
571         echo "Success:mkfsoptions for ost written to xml file correctly."
572
573         # mount lustre to test lconf mkfsoptions-parsing
574         echo "mount lustre"
575         start_ost
576         start_mds
577         mount_client $MOUNT || return $?
578         if [ -z "`dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
579                 echo "Error: the mkoptions not applied to mke2fs of ost."
580                 return 1
581         fi
582         cleanup
583         echo "lconf mkfsoptions for ost success"
584
585         gen_config
586 }
587 run_test 14 "test mkfsoptions of ost for lmc and lconf"
588
589 cleanup_15() {
590         trap 0
591         [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
592         if [ -f $MOUNTLUSTRE.sav ]; then
593                 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
594                 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
595         fi
596 }
597
598 test_15() {
599         start_ost
600         start_mds
601         echo "mount lustre on ${MOUNT} with $MOUNTLUSTRE....."
602         if [ -f "$MOUNTLUSTRE" ]; then
603                 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
604                 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav
605         fi
606         [ -f "$MOUNTLUSTRE" ] && echo "can't move $MOUNTLUSTRE" && return 40
607         trap cleanup_15 EXIT INT
608         [ ! `cp $LUSTRE/utils/llmount $MOUNTLUSTRE` ] || return $?
609         do_node `hostname` mkdir -p $MOUNT 2> /dev/null
610         # load llite module on the client if it isn't in /lib/modules
611         do_node `hostname` lconf --nosetup --node client_facet $XMLCONFIG
612         do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
613                 `facet_active_host mds1`:/mds1_svc/client_facet $MOUNT ||return $?
614         echo "mount lustre on $MOUNT with $MOUNTLUSTRE: success"
615         [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
616         check_mount || return 41
617         do_node `hostname` umount $MOUNT
618
619         [ -f "$MOUNTLUSTRE" ] && rm -f $MOUNTLUSTRE
620         echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
621         do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
622                 `facet_active_host mds1`:/mds1_svc/client_facet $MOUNT &&return $?
623         echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
624         cleanup || return $?
625         cleanup_15
626 }
627 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
628
629 is_digit() {
630     local value=$1
631     echo $value | grep -q "^[[:digit:]]*$"
632     return $?
633 }
634
635 test_16() {
636         TMPMTPT="/mnt/conf16"
637                                                                                                                              
638         if [ ! -f "$MDSDEV" ]; then
639             echo "no $MDSDEV existing, so mount Lustre to create one"
640             start_ost
641             start_mds
642             mount_client $MOUNT
643             check_mount || return 41
644             cleanup || return $?
645          fi
646                                                                                                                              
647         echo "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
648         [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
649         mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
650         chmod 555 $TMPMTPT/OBJECTS || return $?
651         chmod 555 $TMPMTPT/LOGS || return $?
652         chmod 555 $TMPMTPT/PENDING || return $?
653         umount $TMPMTPT || return $?
654                                                                                                                              
655         echo "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
656         start_ost
657         start_mds
658         mount_client $MOUNT
659         check_mount || return 41
660         cleanup || return $?
661                                                                                                                              
662         echo "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
663         EXPECTEDOBJECTSMODE=`debugfs -R "stat OBJECTS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
664         EXPECTEDLOGSMODE=`debugfs -R "stat LOGS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
665         EXPECTEDPENDINGMODE=`debugfs -R "stat PENDING" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
666
667         # check if values are empty
668         test "x$EXPECTEDOBJECTSMODE" = "x" && EXPECTEDOBJECTSMODE="<empty>"
669         test "x$EXPECTEDLOGSMODE" = "x" && EXPECTEDLOGSMODE="<empty>"
670         test "x$EXPECTEDPENDINGMODE" = "x" && EXPECTEDPENDINGMODE="<empty>"
671
672         # check if values are valid digits
673         is_digit $EXPECTEDOBJECTSMODE || {
674             echo "Invalid OBJECTS mode obtained from debugfs: $EXPECTEDOBJECTSMODE"
675             return 42
676         }
677
678         is_digit $EXPECTEDLOGSMODE || {
679             echo "Invalid LOGS mode obtained from debugfs: $EXPECTEDLOGSMODE"
680             return 42
681         }
682
683         is_digit $EXPECTEDPENDINGMODE || {
684             echo "Invalid PINDING mode obtained from debugfs: $EXPECTEDPENDINGMODE"
685             return 42
686         }
687
688         # check if values are those we expected
689         if [ "x$EXPECTEDOBJECTSMODE" = "x0777" ]; then
690                 echo "Success: Lustre change the mode of OBJECTS correctly"
691         else
692                 echo "Error: Lustre does not change the mode of OBJECTS properly"
693                 echo "Expected value: 0777, actual one: $EXPECTEDOBJECTSMODE"
694                 return 1
695         fi
696                                                                                                                              
697         if [ "x$EXPECTEDLOGSMODE" = "x0777" ]; then
698                 echo "Success: Lustre change the mode of LOGS correctly"
699         else
700                 echo "Error: Lustre does not change the mode of LOGS properly"
701                 echo "Expected value: 0777, actual one: $EXPECTEDLOGSMODE"
702                 return 1
703         fi
704                                                                                                                              
705         if [ "x$EXPECTEDPENDINGMODE" = "x0777" ]; then
706                 echo "Success: Lustre change the mode of PENDING correctly"
707         else
708                 echo "Error: Lustre does not change the mode of PENDING properly"
709                 echo "Expected value: 0777, actual one: $EXPECTEDPENDINGMODE"
710                 return 1
711         fi
712 }
713 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
714
715 test_17() {
716         TMPMTPT="/mnt/conf17"
717
718         if [ ! -f "$MDSDEV" ]; then
719             echo "no $MDSDEV existing, so mount Lustre to create one"
720             start_ost
721             start_mds
722             mount_client $MOUNT
723             check_mount || return 41
724             cleanup || return $?
725         fi
726
727         echo "Remove mds config log"
728         [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
729         mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
730         rm -f $TMPMTPT/LOGS/mds1_svc || return $?
731         umount $TMPMTPT || return $?
732
733         start_ost
734         start mds1 $MDSLCONFARGS && return 42
735         cleanup || return $?
736 }
737 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936)"
738
739 test_18() {
740         [ -f $MDSDEV ] && echo "remove $MDSDEV" && rm -f $MDSDEV
741         echo "mount mds with large journal..."
742         OLDMDSSIZE=$MDSSIZE
743         MDSSIZE=2000000
744         gen_config
745                                                                                                                              
746         echo "mount lustre system..."
747         start_ost
748         start_mds
749         mount_client $MOUNT
750         check_mount || return 41
751                                                                                                                              
752         echo "check journal size..."
753         FOUNDJOURNALSIZE=`debugfs -R "stat <8>" $MDSDEV | awk '/Size: / { print $6; exit;}'`
754         if [ $FOUNDJOURNALSIZE = "79691776" ]; then
755                 echo "Success:lconf creates large journals"
756         else
757                 echo "Error:lconf not create large journals correctly"
758                 echo "expected journal size: 79691776(76M), found journal size: $FOUNDJOURNALSIZE"
759                 return 1
760         fi
761                                                                                                                              
762         cleanup || return $?
763                                                                                                                              
764         MDSSIZE=$OLDMDSSIZE
765         gen_config
766 }
767 run_test 18 "check lconf creates large journals"
768
769 equals_msg "Done"