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 $FORCE || return 201
90 stop_ost $FORCE || return 202
91 # catch case where these return just fine, but modules are still not unloaded
92 /sbin/lsmod | egrep -q "portals|libcfs"
94 echo "modules still loaded..."
101 do_facet client "touch $DIR/a" || return 71
102 do_facet client "rm $DIR/a" || return 72
103 echo "setup single mount lustre success"
107 do_facet client "touch $DIR/a" || return 71
108 do_facet client "rm $DIR/a" || return 72
109 do_facet client "touch $DIR2/a" || return 73
110 do_facet client "rm $DIR2/a" || return 74
111 echo "setup double mount lustre success"
116 if [ "$ONLY" == "cleanup" ]; then
121 #create single point mountpoint
130 check_mount || return 41
133 run_test 0 "single mount setup"
137 echo "start ost second time..."
138 start ost --reformat $OSTLCONFARGS
141 check_mount || return 42
144 run_test 1 "start up ost twice"
149 echo "start mds second time.."
150 start mds --reformat $MDSLCONFARGS
153 check_mount || return 43
156 run_test 2 "start up mds twice"
162 check_mount || return 44
167 run_test 3 "mount client twice"
171 touch $DIR/$tfile || return 85
175 # ok for ost to fail shutdown
176 if [ 202 -ne $eno ]; then
181 run_test 4 "force cleanup ost, then cleanup"
185 touch $DIR/$tfile || return 1
186 stop_mds --force || return 2
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.
194 echo "killing umount"
195 kill -TERM $UMOUNT_PID
196 echo "waiting for umount to finish"
199 # cleanup client modules
200 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
202 # stop_mds is a no-op here, and should not fail
206 lsmod | grep -q portals && return 6
209 run_test 5 "force cleanup mds, then cleanup"
216 [ -d $MOUNT ] || mkdir -p $MOUNT
217 $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
218 llmount -o nettype=$NETTYPE $mds_HOST://mds_svc/client_facet $MOUNT && exit 1
220 # cleanup client modules
221 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
223 # stop_mds is a no-op here, and should not fail
227 lsmod | grep -q portals && return 4
231 run_test 5b "mds down, cleanup after failed mount (bug 2712)"
237 [ -d $MOUNT ] || mkdir -p $MOUNT
238 $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
239 llmount -o nettype=$NETTYPE $mds_HOST://wrong_mds_svc/client_facet $MOUNT && return 1
241 # cleanup client modules
242 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
247 lsmod | grep -q portals && return 4
251 run_test 5c "cleanup after failed mount (bug 2712)"
258 [ -d $MOUNT ] || mkdir -p $MOUNT
259 $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null
260 llmount -o nettype=$NETTYPE $mds_HOST://mds_svc/client_facet $MOUNT || return 1
262 umount $MOUNT || return 2
263 # cleanup client modules
264 $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null
268 lsmod | grep -q portals && return 4
272 run_test 5d "ost down, don't crash during mount attempt"
277 mount_client ${MOUNT} || return 87
278 touch $DIR/a || return 86
281 run_test 6 "manual umount, then mount again"
288 run_test 7 "manual umount, then cleanup"
297 check_mount2 || return 45
299 umount_client $MOUNT2
304 run_test 8 "double mount setup"
307 # backup the old values of PTLDEBUG and SUBSYSTEM
308 OLDPTLDEBUG=$PTLDEBUG
309 OLDSUBSYSTEM=$SUBSYSTEM
311 # generate new configuration file with lmc --ptldebug and --subsystem
316 # check the result of lmc --ptldebug/subsystem
320 CHECK_PTLDEBUG="`cat /proc/sys/portals/debug`"
321 if [ $CHECK_PTLDEBUG = "1" ]; then
322 echo "lmc --debug success"
324 echo "lmc --debug: want 1, have $CHECK_PTLDEBUG"
327 CHECK_SUBSYSTEM="`cat /proc/sys/portals/subsystem_debug`"
328 if [ $CHECK_SUBSYSTEM = "2" ]; then
329 echo "lmc --subsystem success"
331 echo "lmc --subsystem: want 2, have $CHECK_SUBSYSTEM"
334 check_mount || return 41
337 # the new PTLDEBUG/SUBSYSTEM used for lconf --ptldebug/subsystem
338 PTLDEBUG="inode+trace"
341 # check lconf --ptldebug/subsystem overriding lmc --ptldebug/subsystem
344 CHECK_PTLDEBUG="`do_facet mds cat /proc/sys/portals/debug`"
345 if [ $CHECK_PTLDEBUG = "3" ]; then
346 echo "lconf --debug success"
348 echo "lconf --debug: want 3, have $CHECK_PTLDEBUG"
351 CHECK_SUBSYSTEM="`do_facet mds cat /proc/sys/portals/subsystem_debug`"
352 if [ $CHECK_SUBSYSTEM = "20" ]; then
353 echo "lconf --subsystem success"
355 echo "lconf --subsystem: want 20, have $CHECK_SUBSYSTEM"
359 check_mount || return 41
362 # resume the old configuration
363 PTLDEBUG=$OLDPTLDEBUG
364 SUBSYSTEM=$OLDSUBSYSTEM
368 run_test 9 "test --ptldebug and --subsystem for lmc and lconf"
371 echo "generate configuration with the same name for node and mds"
372 OLDXMLCONFIG=$XMLCONFIG
373 XMLCONFIG="broken.xml"
374 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
378 echo "the name for node and mds is the same"
379 do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \
380 --dev $MDSDEV --size $MDSSIZE || return $?
381 do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \
382 $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \
383 --stripe_pattern 0 || return $?
384 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
386 add_facet $facet --lustre_upcall $UPCALL
387 do_lmc --add mtpt --node ${facet}_facet --mds mds_facet \
388 --lov lov1 --path $MOUNT
394 check_mount || return 41
398 XMLCONFIG=$OLDXMLCONFIG
400 run_test 10 "mount lustre with the same name for node and mds"
403 OLDXMLCONFIG=$XMLCONFIG
404 XMLCONFIG="conf11.xml"
406 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
407 add_mds mds --dev $MDSDEV --size $MDSSIZE
408 add_ost ost --dev $OSTDEV --size $OSTSIZE
409 add_client client mds --path $MOUNT --ost ost_svc || return $?
410 echo "Default lov config success!"
412 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
413 add_mds mds --dev $MDSDEV --size $MDSSIZE
414 add_ost ost --dev $OSTDEV --size $OSTSIZE
415 add_client client mds --path $MOUNT && return $?
416 echo "--add mtpt with neither --lov nor --ost will return error"
420 XMLCONFIG=$OLDXMLCONFIG
422 run_test 11 "use default lov configuration (should return error)"
425 OLDXMLCONFIG=$XMLCONFIG
426 XMLCONFIG="batch.xml"
427 BATCHFILE="batchfile"
430 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
431 [ -f "$BATCHFILE" ] && rm -f $BATCHFILE
432 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
433 echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE
434 # --mkfsoptions "-I 128"
435 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
436 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
437 echo "matched double quote success"
439 echo "matched double quote fail"
444 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
445 echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE
446 # --mkfsoptions "-I 128
447 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
448 echo "unmatched double quote should return error"
452 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
453 echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE
454 # --mkfsoptions '-I 128'
455 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
456 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
457 echo "matched single quote success"
459 echo "matched single quote fail"
464 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
465 echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE
466 # --mkfsoptions '-I 128
467 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
468 echo "unmatched single quote should return error"
472 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
473 echo "--add mds --node localhost --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE
474 # --mkfsoptions \-\I\ \128
475 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $?
476 if [ `sed -n '/>-I 128</p' $XMLCONFIG | wc -l` -eq 1 ]; then
477 echo "backslash followed by a whitespace/letter success"
479 echo "backslash followed by a whitespace/letter fail"
484 echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE
485 echo "--add mds --node localhost --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE
486 # --mkfsoptions -I\ 128\
487 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $?
488 echo "backslash followed by nothing should return error"
491 XMLCONFIG=$OLDXMLCONFIG
493 run_test 12 "lmc --batch, with single/double quote, backslash in batchfile"
496 OLDXMLCONFIG=$XMLCONFIG
497 XMLCONFIG="conf13-1.xml"
498 SECONDXMLCONFIG="conf13-2.xml"
500 # check long uuid will be truncated properly and uniquely
501 echo "To generate XML configuration file(with long ost name): $XMLCONFIG"
502 [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG
503 do_lmc --add net --node localhost --nid localhost.localdomain --nettype tcp
504 do_lmc --add mds --node localhost --mds mds1_name_longer_than_31characters
505 do_lmc --add mds --node localhost --mds mds2_name_longer_than_31characters
506 if [ ! -f "$XMLCONFIG" ]; then
507 echo "Error:no file $XMLCONFIG created!"
510 EXPECTEDMDS1UUID="e_longer_than_31characters_UUID"
511 EXPECTEDMDS2UUID="longer_than_31characters_UUID_2"
512 FOUNDMDS1UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '1p' \
513 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
514 FOUNDMDS2UUID=`awk -F"'" '/<mds .*uuid=/' $XMLCONFIG | sed -n '2p' \
515 | sed "s/ /\n\r/g" | awk -F"'" '/uuid=/{print $2}'`
516 if ([ $EXPECTEDMDS1UUID = $FOUNDMDS1UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS2UUID ]) || \
517 ([ $EXPECTEDMDS1UUID = $FOUNDMDS2UUID ] && [ $EXPECTEDMDS2UUID = $FOUNDMDS1UUID ]); then
518 echo "Success:long uuid truncated successfully and being unique."
520 echo "Error:expected uuid for mds1 and mds2: $EXPECTEDMDS1UUID; $EXPECTEDMDS2UUID"
521 echo "but: found uuid for mds1 and mds2: $FOUNDMDS1UUID; $FOUNDMDS2UUID"
525 # check multiple invocations for lmc generate same XML configuration file
527 echo "Generate the first XML configuration file"
529 echo "mv $XMLCONFIG to $SECONDXMLCONFIG"
530 mv $XMLCONFIG $SECONDXMLCONFIG || return $?
531 echo "Generate the second XML configuration file"
533 if [ `diff $XMLCONFIG $SECONDXMLCONFIG | wc -l` -eq 0 ]; then
534 echo "Success:multiple invocations for lmc generate same XML file"
536 echo "Error: multiple invocations for lmc generate different XML file"
541 rm -f $SECONDXMLCONFIG
542 XMLCONFIG=$OLDXMLCONFIG
544 run_test 13 "check new_uuid of lmc operating correctly"
549 # create xml file with --mkfsoptions for ost
550 echo "create xml file with --mkfsoptions for ost"
551 add_mds mds --dev $MDSDEV --size $MDSSIZE
552 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
553 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
554 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE \
555 --mkfsoptions "-Llabel_conf_14"
556 add_client client mds --lov lov1 --path $MOUNT
558 FOUNDSTRING=`awk -F"<" '/<mkfsoptions>/{print $2}' $XMLCONFIG`
559 EXPECTEDSTRING="mkfsoptions>-Llabel_conf_14"
560 if [ $EXPECTEDSTRING != $FOUNDSTRING ]; then
561 echo "Error: expected: $EXPECTEDSTRING; found: $FOUNDSTRING"
564 echo "Success:mkfsoptions for ost written to xml file correctly."
566 # mount lustre to test lconf mkfsoptions-parsing
570 mount_client $MOUNT || return $?
571 if [ -z "`dumpe2fs -h $OSTDEV | grep label_conf_14`" ]; then
572 echo "Error: the mkoptions not applied to mke2fs of ost."
576 echo "lconf mkfsoptions for ost success"
580 run_test 14 "test mkfsoptions of ost for lmc and lconf"
584 [ -f $MOUNTLUSTRE ] && echo "remove $MOUNTLUSTRE" && rm -f $MOUNTLUSTRE
585 if [ -f $MOUNTLUSTRE.sav ]; then
586 echo "return original $MOUNTLUSTRE.sav to $MOUNTLUSTRE"
587 mv $MOUNTLUSTRE.sav $MOUNTLUSTRE
594 echo "mount lustre on ${MOUNT} with $MOUNTLUSTRE....."
595 if [ -f "$MOUNTLUSTRE" ]; then
596 echo "save $MOUNTLUSTRE to $MOUNTLUSTRE.sav"
597 mv $MOUNTLUSTRE $MOUNTLUSTRE.sav
599 [ -f "$MOUNTLUSTRE" ] && echo "can't move $MOUNTLUSTRE" && return 40
600 trap cleanup_15 EXIT INT
601 [ ! `cp $(which llmount) $MOUNTLUSTRE` ] || return $?
602 do_node `hostname` mkdir -p $MOUNT 2> /dev/null
603 # load llite module on the client if it isn't in /lib/modules
604 do_node `hostname` lconf --nosetup --node client_facet $XMLCONFIG
605 do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
606 `facet_active_host mds`:/mds_svc/client_facet $MOUNT ||return $?
607 echo "mount lustre on $MOUNT with $MOUNTLUSTRE: success"
608 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
609 check_mount || return 41
610 do_node `hostname` umount $MOUNT
612 [ -f "$MOUNTLUSTRE" ] && rm -f $MOUNTLUSTRE
613 echo "mount lustre on ${MOUNT} without $MOUNTLUSTRE....."
614 do_node `hostname` mount -t lustre -o nettype=$NETTYPE \
615 `facet_active_host mds`:/mds_svc/client_facet $MOUNT &&return $?
616 echo "mount lustre on $MOUNT without $MOUNTLUSTRE failed as expected"
620 run_test 15 "zconf-mount without /sbin/mount.lustre (should return error)"
623 TMPMTPT="/mnt/conf16"
625 if [ ! -f "$MDSDEV" ]; then
626 echo "no $MDSDEV existing, so mount Lustre to create one"
630 check_mount || return 41
634 echo "change the mode of $MDSDEV/OBJECTS,LOGS,PENDING to 555"
635 [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
636 mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
637 chmod 555 $TMPMTPT/OBJECTS || return $?
638 chmod 555 $TMPMTPT/LOGS || return $?
639 chmod 555 $TMPMTPT/PENDING || return $?
640 umount $TMPMTPT || return $?
642 echo "mount Lustre to change the mode of OBJECTS/LOGS/PENDING, then umount Lustre"
646 check_mount || return 41
649 echo "read the mode of OBJECTS/LOGS/PENDING and check if they has been changed properly"
650 EXPECTEDOBJECTSMODE=`debugfs -R "stat OBJECTS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
651 EXPECTEDLOGSMODE=`debugfs -R "stat LOGS" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
652 EXPECTEDPENDINGMODE=`debugfs -R "stat PENDING" $MDSDEV 2> /dev/null | awk '/Mode: /{print $6}'`
654 if [ "$EXPECTEDOBJECTSMODE" = "0777" ]; then
655 echo "Success:Lustre change the mode of OBJECTS correctly"
657 echo "Error: Lustre does not change the mode of OBJECTS properly"
661 if [ "$EXPECTEDLOGSMODE" = "0777" ]; then
662 echo "Success:Lustre change the mode of LOGS correctly"
664 echo "Error: Lustre does not change the mode of LOGS properly"
668 if [ "$EXPECTEDPENDINGMODE" = "0777" ]; then
669 echo "Success:Lustre change the mode of PENDING correctly"
671 echo "Error: Lustre does not change the mode of PENDING properly"
675 run_test 16 "verify that lustre will correct the mode of OBJECTS/LOGS/PENDING"
678 TMPMTPT="/mnt/conf17"
680 if [ ! -f "$MDSDEV" ]; then
681 echo "no $MDSDEV existing, so mount Lustre to create one"
685 check_mount || return 41
689 echo "Remove mds config log"
690 [ -d $TMPMTPT ] || mkdir -p $TMPMTPT
691 mount -o loop -t ext3 $MDSDEV $TMPMTPT || return $?
692 rm -f $TMPMTPT/LOGS/mds_svc || return $?
693 umount $TMPMTPT || return $?
696 start mds $MDSLCONFARGS && return 42
699 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936)"
702 [ -f $MDSDEV ] && echo "remove $MDSDEV" && rm -f $MDSDEV
703 echo "mount mds with large journal..."
708 echo "mount lustre system..."
712 check_mount || return 41
714 echo "check journal size..."
715 FOUNDJOURNALSIZE=`debugfs -R "stat <8>" $MDSDEV | awk '/Size: / { print $6; exit;}'`
716 if [ "$FOUNDJOURNALSIZE" = "79691776" ]; then
717 echo "Success:lconf creates large journals"
719 echo "Error:lconf not create large journals correctly"
720 echo "expected journal size: 79691776(76M), found journal size: $FOUNDJOURNALSIZE"
729 run_test 18 "check lconf creates large journals"