3 # add uml1 uml2 uml3 in your /etc/hosts
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.
13 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
15 LUSTRE=${LUSTRE:-`dirname $0`/..}
16 RLUSTRE=${RLUSTRE:-$LUSTRE}
17 MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre}
19 . $LUSTRE/tests/test-framework.sh
23 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
28 add_mds mds --dev $MDSDEV --size $MDSSIZE
29 add_lov lov1 mds --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 mds --lov lov1 --path $MOUNT
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 mds2 --lov lov2 --path $MOUNT2
46 echo "start mds service on `facet_active_host mds`"
47 start mds --reformat $MDSLCONFARGS || return 94
50 echo "stop mds service on `facet_active_host mds`"
51 stop mds $@ || return 97
55 echo "start ost service on `facet_active_host ost`"
56 start ost --reformat $OSTLCONFARGS || return 95
60 echo "stop ost service on `facet_active_host ost`"
61 stop ost $@ || return 98
66 echo "mount lustre on ${MOUNTPATH}....."
67 zconf_mount `hostname` $MOUNTPATH || return 96
72 echo "umount lustre on ${MOUNTPATH}....."
73 zconf_umount `hostname` $MOUNTPATH || return 97
76 manual_umount_client(){
77 echo "manual umount lustre on ${MOUNTPATH}...."
78 do_facet client "umount $MOUNT"
88 umount_client $MOUNT || return 200
89 stop_mds || return 201
90 stop_ost || return 202
91 # catch case where these return just fine, but modules are still not unloaded
92 /sbin/lsmod | grep -q portals
94 echo "modules still loaded..."
100 do_facet client "touch $DIR/a" || return 71
101 do_facet client "rm $DIR/a" || return 72
102 echo "setup single mount lustre success"
106 do_facet client "touch $DIR/a" || return 71
107 do_facet client "rm $DIR/a" || return 72
108 do_facet client "touch $DIR2/a" || return 73
109 do_facet client "rm $DIR2/a" || return 74
110 echo "setup double mount lustre success"
115 #create single point mountpoint
124 check_mount || return 41
127 run_test 0 "single mount setup"
131 echo "start ost second time..."
132 start ost --reformat $OSTLCONFARGS
135 check_mount || return 42
138 run_test 1 "start up ost twice"
143 echo "start mds second time.."
144 start mds --reformat $MDSLCONFARGS
147 check_mount || return 43
150 run_test 2 "start up mds twice"
156 check_mount || return 44
161 run_test 3 "mount client twice"
165 touch $DIR/$tfile || return 85
169 # ok for ost to fail shutdown
170 if [ 202 -ne $eno ]; then
175 run_test 4 "force cleanup ost, then cleanup"
179 touch $DIR/$tfile || return 1
180 stop_mds --force || return 2
182 # cleanup may return an error from the failed
183 # disconnects; for now I'll consider this successful
184 # if all the modules have unloaded.
188 echo "killing umount"
189 kill -TERM $UMOUNT_PID
190 echo "waiting for umount to finish"
193 # cleanup client modules
194 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
196 # stop_mds is a no-op here, and should not fail
200 lsmod | grep -q portals && return 6
203 run_test 5 "force cleanup mds, then cleanup"
210 [ -d $MOUNT ] || mkdir -p $MOUNT
211 $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
212 llmount $mds_HOST://mds_svc/client_facet $MOUNT && exit 1
214 # cleanup client modules
215 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
217 # stop_mds is a no-op here, and should not fail
221 lsmod | grep -q portals && return 3
225 run_test 5b "mds down, cleanup after failed mount (bug 2712)"
231 [ -d $MOUNT ] || mkdir -p $MOUNT
232 $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
233 llmount $mds_HOST://wrong_mds_svc/client_facet $MOUNT && exit 1
235 # cleanup client modules
236 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
241 lsmod | grep -q portals && return 3
245 run_test 5c "cleanup after failed mount (bug 2712)"
250 mount_client ${MOUNT} || return 87
251 touch $DIR/a || return 86
254 run_test 6 "manual umount, then mount again"
261 run_test 7 "manual umount, then cleanup"
270 check_mount2 || return 45
272 umount_client $MOUNT2
277 run_test 8 "double mount setup"
280 # backup the old values of PTLDEBUG and SUBSYSTEM
281 OLDPTLDEBUG=$PTLDEBUG
282 OLDSUBSYSTEM=$SUBSYSTEM
284 # generate new configuration file with lmc --ptldebug and --subsystem
289 # check the result of lmc --ptldebug/subsystem
293 CHECK_PTLDEBUG="`cat /proc/sys/portals/debug`"
294 if [ $CHECK_PTLDEBUG = "1" ]; then
295 echo "lmc --debug success"
297 echo "lmc --debug: want 1, have $CHECK_PTLDEBUG"
300 CHECK_SUBSYSTEM="`cat /proc/sys/portals/subsystem_debug`"
301 if [ $CHECK_SUBSYSTEM = "2" ]; then
302 echo "lmc --subsystem success"
304 echo "lmc --subsystem: want 2, have $CHECK_SUBSYSTEM"
307 check_mount || return 41
310 # the new PTLDEBUG/SUBSYSTEM used for lconf --ptldebug/subsystem
311 PTLDEBUG="inode+trace"
314 # check lconf --ptldebug/subsystem overriding lmc --ptldebug/subsystem
317 CHECK_PTLDEBUG="`do_facet mds cat /proc/sys/portals/debug`"
318 if [ $CHECK_PTLDEBUG = "3" ]; then
319 echo "lconf --debug success"
321 echo "lconf --debug: want 3, have $CHECK_PTLDEBUG"
324 CHECK_SUBSYSTEM="`do_facet mds cat /proc/sys/portals/subsystem_debug`"
325 if [ $CHECK_SUBSYSTEM = "20" ]; then
326 echo "lconf --subsystem success"
328 echo "lconf --subsystem: want 20, have $CHECK_SUBSYSTEM"
332 check_mount || return 41
335 # resume the old configuration
336 PTLDEBUG=$OLDPTLDEBUG
337 SUBSYSTEM=$OLDSUBSYSTEM
341 run_test 9 "test --ptldebug and --subsystem for lmc and lconf"
344 OLDXMLCONFIG=$XMLCONFIG
345 XMLCONFIG="broken.xml"
346 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
348 do_lmc --add node --node $SAMENAME
349 do_lmc --add net --node $SAMENAME --nid $SAMENAME --nettype tcp
350 do_lmc --add mds --node $SAMENAME --mds $SAMENAME --nid $SAMENAME \
351 --fstype ext3 --dev /dev/mds1 || return $?
352 do_lmc --add lov --lov lov1 --mds $SAMENAME --stripe_sz 65536 \
353 --stripe_cnt 1 --stripe_pattern 0 || return $?
355 XMLCONFIG=$OLDXMLCONFIG
357 run_test 10 "use lmc with the same name for node and mds"
360 OLDXMLCONFIG=$XMLCONFIG
361 XMLCONFIG="conf11.xml"
363 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
364 add_mds mds --dev $MDSDEV --size $MDSSIZE
365 add_ost ost --dev $OSTDEV --size $OSTSIZE
366 add_client client mds --path $MOUNT --ost ost_svc || return $?
367 echo "Default lov config success!"
369 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
370 add_mds mds --dev $MDSDEV --size $MDSSIZE
371 add_ost ost --dev $OSTDEV --size $OSTSIZE
372 add_client client mds --path $MOUNT && return $?
373 echo "--add mtpt with neither --lov nor --ost will return error"
377 XMLCONFIG=$OLDXMLCONFIG
379 run_test 11 "use default lov configuration (should return error)"
382 OLDXMLCONFIG=$XMLCONFIG
383 XMLCONFIG="batch.xml"
384 BATCHFILE="batchfile"
387 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
388 [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
389 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
390 echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE
391 # --mkfsoptions "-I 128"
392 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
393 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
394 echo "matched double quote success"
396 echo "matched double quote fail"
401 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
402 echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
403 # --mkfsoptions "-I 128
404 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
405 echo "unmatched double quote should return error"
409 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
410 echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE
411 # --mkfsoptions '-I 128'
412 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
413 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
414 echo "matched single quote success"
416 echo "matched single quote fail"
421 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
422 echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
423 # --mkfsoptions '-I 128
424 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
425 echo "unmatched single quote should return error"
429 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
430 echo "--add mds --node localhost --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE
431 # --mkfsoptions \-\I\ \128
432 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
433 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
434 echo "backslash followed by a whitespace/letter success"
436 echo "backslash followed by a whitespace/letter fail"
441 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
442 echo "--add mds --node localhost --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
443 # --mkfsoptions -I\ 128\
444 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
445 echo "backslash followed by nothing should return error"
448 XMLCONFIG=$OLDXMLCONFIG
450 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
453 OLDXMLCONFIG=$XMLCONFIG
454 XMLCONFIG="conf13-1.xml"
455 SECONDXMLCONFIG="conf13-2.xml"
457 # check long uuid will be truncated properly and uniquely
458 echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
459 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
460 do_lmc --add net --node localhost --nid localhost.localdomain --nettype tcp
461 do_lmc --add mds --node localhost --mds mds1_name_longer_than_31characters
462 do_lmc --add mds --node localhost --mds mds2_name_longer_than_31characters
463 if [ ! -f "$XMLCONFIG" ]; then
464 echo "Error:no file $XMLCONFIG created!"
467 EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
468 EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
469 FOUNDMDS1UUID=`awk -F"'" '/<mds uuid=/{print $2}' $XMLCONFIG | sed -n '1p'`
470 FOUNDMDS2UUID=`awk -F"'" '/<mds uuid=/{print $2}' $XMLCONFIG | sed -n '2p'`
471 if [ $EXPECTEDMDS1UUID != $FOUNDMDS1UUID ]; then
472 echo "Error:expected uuid for mds1: $EXPECTEDMDS1UUID; found: $FOUNDMDS1UUID"
475 if [ $EXPECTEDMDS2UUID != $FOUNDMDS2UUID ]; then
476 echo "Error:expected uuid for mds2: $EXPECTEDMDS2UUID; found: $FOUNDMDS2UUID"
479 echo "Success:long uuid truncated successfully and being unique."
481 # check multiple invocations for lmc generate same XML configuration file
483 echo "Generate the first XML configuration file"
485 echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
486 mv $XMLCONFIG $SECONDXMLCONFIG || return $?
487 echo "Generate the second XML configuration file"
489 if [ `diff $XMLCONFIG $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
490 echo "Success:multiple invocations for lmc generate same XML file"
492 echo "Error: multiple invocations for lmc generate different XML file"
497 rm -f $SECONDXMLCONFIG
498 XMLCONFIG=$OLDXMLCONFIG
500 run_test 13 "check new_uuid of lmc operating correctly"
505 # create xml file with --mkfsoptions for ost
506 echo "create xml file with --mkfsoptions for ost"
507 add_mds mds --dev $MDSDEV --size $MDSSIZE
508 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
509 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
510 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
511 --mkfsoptions "-Llabel_conf_14"
512 add_client client mds --lov lov1 --path $MOUNT
514 FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
515 EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
516 if [ $EXPECTEDSTRING != $FOUNDSTRING ]; then
517 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
520 echo "Success:mkfsoptions for ost written to xml file correctly."
522 # mount lustre to test lconf mkfsoptions-parsing
526 mount_client $MOUNT || return $?
527 if [ -z "`dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
528 echo "Error: the mkoptions not applied to mke2fs of ost."
532 echo "lconf mkfsoptions for ost success"
536 run_test 14 "test mkfsoptions of ost for lmc and lconf"
540 [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
541 if [ -f $MOUNTLUSTRE.sav ]; then
542 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
543 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
550 echo "mount lustre on ${MOUNT} with $MOUNTLUSTRE....."
551 if [ -f "$MOUNTLUSTRE" ]; then
552 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
553 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav
555 [ -f "$MOUNTLUSTRE" ] && echo "can't move $MOUNTLUSTRE" && return 40
556 trap cleanup_15 EXIT INT
557 [ ! `cp $LUSTRE/utils/llmount $MOUNTLUSTRE` ] || return $?
558 do_node `hostname` mkdir -p $MOUNT 2> /dev/null
559 # load llite module on the client if it isn't in /lib/modules
560 do_node `hostname` lconf --nosetup --node client_facet $XMLCONFIG
561 do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
562 `facet_active_host mds`:/mds_svc/client_facet $MOUNT ||return $?
563 echo "mount lustre on $MOUNT with $MOUNTLUSTRE: success"
564 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
565 check_mount || return 41
566 do_node `hostname` umount $MOUNT
568 [ -f "$MOUNTLUSTRE" ] && rm -f $MOUNTLUSTRE
569 echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
570 do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
571 `facet_active_host mds`:/mds_svc/client_facet $MOUNT &&return $?
572 echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
576 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
579 TMPMTPT="/mnt/conf16"
581 if [ ! -f "$MDSDEV" ]; then
582 echo "no $MDSDEV existing, so mount Lustre to create one"
586 check_mount || return 41
590 echo "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
591 [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
592 mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
593 chmod 555 $TMPMTPT/OBJECTS || return $?
594 chmod 555 $TMPMTPT/LOGS || return $?
595 chmod 555 $TMPMTPT/PENDING || return $?
596 umount $TMPMTPT || return $?
598 echo "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
602 check_mount || return 41
605 echo "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
606 EXPECTEDOBJECTSMODE=`debugfs -R "stat OBJECTS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
607 EXPECTEDLOGSMODE=`debugfs -R "stat LOGS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
608 EXPECTEDPENDINGMODE=`debugfs -R "stat PENDING" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
610 if [ $EXPECTEDOBJECTSMODE = "0777" ]; then
611 echo "Success:Lustre change the mode of OBJECTS correctly"
613 echo "Error: Lustre does not change the mode of OBJECTS properly"
617 if [ $EXPECTEDLOGSMODE = "0777" ]; then
618 echo "Success:Lustre change the mode of LOGS correctly"
620 echo "Error: Lustre does not change the mode of LOGS properly"
624 if [ $EXPECTEDPENDINGMODE = "0777" ]; then
625 echo "Success:Lustre change the mode of PENDING correctly"
627 echo "Error: Lustre does not change the mode of PENDING properly"
631 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"