X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fconf-sanity.sh;h=546a0d89ddc6f07e3861dcc9974b1f368eb9493a;hb=2358e27bc14683129a4c9f69f880c20d2e65db34;hp=69979fe9f8dbae9156bc1132af0db36f9c866a1b;hpb=ff17cc7e0282d9b1522810e0c5d12171c4d46a2d;p=fs%2Flustre-release.git diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 69979fe..546a0d8 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -9,73 +9,108 @@ set -e +ONLY=${ONLY:-"$*"} + +# These tests don't apply to mountconf +# xml xml xml xml xml xml dumb FIXME +MOUNTCONFSKIP="10 11 12 13 13b 14 15 18" + +# bug number for skipped test: +ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $MOUNTCONFSKIP" +# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! + SRCDIR=`dirname $0` PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH LUSTRE=${LUSTRE:-`dirname $0`/..} RLUSTRE=${RLUSTRE:-$LUSTRE} -MOUNTLUSTRE=${MOUNTLUSTRE:-/sbin/mount.lustre} +HOSTNAME=`hostname` . $LUSTRE/tests/test-framework.sh - init_test_env $@ +. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} -. ${CONFIG:=$LUSTRE/tests/cfg/local.sh} - -gen_config() { - rm -f $XMLCONFIG - - add_mds mds --dev $MDSDEV --size $MDSSIZE - add_lov lov1 mds --stripe_sz $STRIPE_BYTES\ - --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0 - add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE - add_client client mds --lov lov1 --path $MOUNT +reformat() { + formatall } -gen_second_config() { - rm -f $XMLCONFIG +writeconf() { + local facet=mds + shift + stop ${facet} -f + rm -f ${facet}active + # who knows if/where $TUNEFS is installed? Better reformat if it fails... + do_facet ${facet} "$TUNEFS --writeconf $MDSDEV" || echo "tunefs failed, reformatting instead" && reformat +} - add_mds mds2 --dev $MDSDEV --size $MDSSIZE - add_lov lov2 mds2 --stripe_sz $STRIPE_BYTES\ - --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0 - add_ost ost2 --lov lov2 --dev $OSTDEV --size $OSTSIZE - add_client client mds2 --lov lov2 --path $MOUNT2 +gen_config() { + reformat + # The MGS must be started before the OSTs for a new fs, so start + # and stop to generate the startup logs. + start_mds + start_ost + sleep 5 + stop_ost + stop_mds } start_mds() { echo "start mds service on `facet_active_host mds`" - start mds --reformat $MDSLCONFARGS || return 94 + start mds $MDSDEV $MDS_MOUNT_OPTS || return 94 } + stop_mds() { echo "stop mds service on `facet_active_host mds`" - stop mds $@ || return 97 + # These tests all use non-failover stop + stop mds -f || return 97 } start_ost() { - echo "start ost service on `facet_active_host ost`" - start ost --reformat $OSTLCONFARGS || return 95 + echo "start ost1 service on `facet_active_host ost1`" + start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95 } stop_ost() { - echo "stop ost service on `facet_active_host ost`" - stop ost $@ || return 98 + echo "stop ost1 service on `facet_active_host ost1`" + # These tests all use non-failover stop + stop ost1 -f || return 98 +} + +start_ost2() { + echo "start ost2 service on `facet_active_host ost2`" + start ost2 `ostdevname 2` $OST_MOUNT_OPTS || return 92 +} + +stop_ost2() { + echo "stop ost2 service on `facet_active_host ost2`" + # These tests all use non-failover stop + stop ost2 -f || return 93 } mount_client() { local MOUNTPATH=$1 - echo "mount lustre on ${MOUNTPATH}....." + echo "mount $FSNAME on ${MOUNTPATH}....." + zconf_mount `hostname` $MOUNTPATH || return 96 +} + +remount_client() { + local SAVEMOUNTOPT=$MOUNTOPT + MOUNTOPT="remount,$1" + local MOUNTPATH=$2 + echo "remount '$1' lustre on ${MOUNTPATH}....." zconf_mount `hostname` $MOUNTPATH || return 96 + MOUNTOPT=$SAVEMOUNTOPT } umount_client() { local MOUNTPATH=$1 echo "umount lustre on ${MOUNTPATH}....." - zconf_umount `hostname` $MOUNTPATH || return 97 + zconf_umount `hostname` $MOUNTPATH || return 97 } manual_umount_client(){ - echo "manual umount lustre on ${MOUNTPATH}...." - do_facet client "umount $MOUNT" + echo "manual umount lustre on ${MOUNT}...." + do_facet client "umount -d $MOUNT" } setup() { @@ -84,21 +119,23 @@ setup() { mount_client $MOUNT } +cleanup_nocli() { + stop_mds || return 201 + stop_ost || return 202 + unload_modules || return 203 +} + cleanup() { umount_client $MOUNT || return 200 - stop_mds || return 201 - stop_ost || return 202 - # catch case where these return just fine, but modules are still not unloaded - /sbin/lsmod | grep -q portals - if [ 1 -ne $? ]; then - echo "modules still loaded..." - return 203 - fi + cleanup_nocli || return $? } check_mount() { - do_facet client "touch $DIR/a" || return 71 - do_facet client "rm $DIR/a" || return 72 + do_facet client "cp /etc/passwd $DIR/a" || return 71 + do_facet client "rm $DIR/a" || return 72 + # make sure lustre is actually mounted (touch will block, + # but grep won't, so do it after) + do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73 echo "setup single mount lustre success" } @@ -112,15 +149,23 @@ check_mount2() { build_test_filter +if [ "$ONLY" == "setup" ]; then + setup + exit +fi + +if [ "$ONLY" == "cleanup" ]; then + cleanup + exit +fi + #create single point mountpoint gen_config test_0() { - start_ost - start_mds - mount_client $MOUNT + setup check_mount || return 41 cleanup || return $? } @@ -129,41 +174,36 @@ run_test 0 "single mount setup" test_1() { start_ost echo "start ost second time..." - start ost --reformat $OSTLCONFARGS - start_mds - mount_client $MOUNT + setup check_mount || return 42 cleanup || return $? } -run_test 1 "start up ost twice" +run_test 1 "start up ost twice (should return errors)" test_2() { start_ost start_mds echo "start mds second time.." - start mds --reformat $MDSLCONFARGS - + start_mds mount_client $MOUNT check_mount || return 43 cleanup || return $? } -run_test 2 "start up mds twice" +run_test 2 "start up mds twice (should return err)" test_3() { setup - mount_client $MOUNT - + #mount.lustre returns an error if already in mtab + mount_client $MOUNT && return $? check_mount || return 44 - - umount_client $MOUNT - cleanup || return $? + cleanup || return $? } -run_test 3 "mount client twice" +run_test 3 "mount client twice (should return err)" test_4() { setup touch $DIR/$tfile || return 85 - stop_ost --force + stop_ost -f cleanup eno=$? # ok for ost to fail shutdown @@ -177,72 +217,93 @@ run_test 4 "force cleanup ost, then cleanup" test_5() { setup touch $DIR/$tfile || return 1 - stop_mds --force || return 2 + stop_mds -f || return 2 # cleanup may return an error from the failed # disconnects; for now I'll consider this successful # if all the modules have unloaded. - umount $MOUNT & + umount -d $MOUNT & UMOUNT_PID=$! - sleep 2 + sleep 6 echo "killing umount" kill -TERM $UMOUNT_PID echo "waiting for umount to finish" wait $UMOUNT_PID + if grep " $MOUNT " /etc/mtab; then + echo "test 5: mtab after failed umount" + umount $MOUNT & + UMOUNT_PID=$! + sleep 2 + echo "killing umount" + kill -TERM $UMOUNT_PID + echo "waiting for umount to finish" + wait $UMOUNT_PID + grep " $MOUNT " /etc/mtab && echo "test 5: mtab after second umount" && return 11 + fi - # cleanup client modules - $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null - + manual_umount_client # stop_mds is a no-op here, and should not fail - stop_mds || return 4 - stop_ost || return 5 - - lsmod | grep -q portals && return 6 - return 0 + cleanup_nocli || return $? + # df may have lingering entry + manual_umount_client + # mtab may have lingering entry + grep -v $MOUNT" " /etc/mtab > $TMP/mtabtemp + mv $TMP/mtabtemp /etc/mtab } run_test 5 "force cleanup mds, then cleanup" test_5b() { start_ost - start_mds - stop_mds - [ -d $MOUNT ] || mkdir -p $MOUNT - $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null - llmount $mds_HOST://mds_svc/client_facet $MOUNT && exit 1 - - # cleanup client modules - $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null - + grep " $MOUNT " /etc/mtab && echo "test 5b: mtab before mount" && return 10 + mount_client $MOUNT && return 1 + grep " $MOUNT " /etc/mtab && echo "test 5b: mtab after failed mount" && return 11 + umount_client $MOUNT # stop_mds is a no-op here, and should not fail - stop_mds || return 2 - stop_ost || return 3 - - lsmod | grep -q portals && return 3 + cleanup_nocli || return $? return 0 - } -run_test 5b "mds down, cleanup after failed mount (bug 2712)" +run_test 5b "mds down, cleanup after failed mount (bug 2712) (should return errs)" test_5c() { start_ost start_mds - [ -d $MOUNT ] || mkdir -p $MOUNT - $LCONF --nosetup --node client_facet $XMLCONFIG > /dev/null - llmount $mds_HOST://wrong_mds_svc/client_facet $MOUNT && exit 1 - - # cleanup client modules - $LCONF --cleanup --nosetup --node client_facet $XMLCONFIG > /dev/null - - stop_mds || return 2 - stop_ost || return 3 + grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10 + mount -t lustre $MGSNID:/wrong.$FSNAME $MOUNT || : + grep " $MOUNT " /etc/mtab && echo "test 5c: mtab after failed mount" && return 11 + umount_client $MOUNT + cleanup_nocli || return $? +} +run_test 5c "cleanup after failed mount (bug 2712) (should return errs)" - lsmod | grep -q portals && return 3 +test_5d() { + start_ost + start_mds + stop_ost -f + grep " $MOUNT " /etc/mtab && echo "test 5d: mtab before mount" && return 10 + mount_client $MOUNT || return 1 + cleanup || return $? + grep " $MOUNT " /etc/mtab && echo "test 5d: mtab after unmount" && return 11 return 0 +} +run_test 5d "mount with ost down" + +test_5e() { + start_ost + start_mds + # give MDS a chance to connect to OSTs (bz 10476) + sleep 5 +#define OBD_FAIL_PTLRPC_DELAY_SEND 0x506 + do_facet client "sysctl -w lustre.fail_loc=0x80000506" + grep " $MOUNT " /etc/mtab && echo "test 5e: mtab before mount" && return 10 + mount_client $MOUNT || echo "mount failed (not fatal)" + cleanup || return $? + grep " $MOUNT " /etc/mtab && echo "test 5e: mtab after unmount" && return 11 + return 0 } -run_test 5c "cleanup after failed mount (bug 2712)" +run_test 5e "delayed connect, don't crash (bug 10268)" test_6() { setup @@ -256,105 +317,75 @@ run_test 6 "manual umount, then mount again" test_7() { setup manual_umount_client - cleanup || return $? + cleanup_nocli || return $? } run_test 7 "manual umount, then cleanup" test_8() { - start_ost - start_mds - - mount_client $MOUNT + setup mount_client $MOUNT2 - check_mount2 || return 45 - umount $MOUNT umount_client $MOUNT2 - - stop_mds - stop_ost + cleanup || return $? } run_test 8 "double mount setup" test_9() { - # backup the old values of PTLDEBUG and SUBSYSTEM - OLDPTLDEBUG=$PTLDEBUG - OLDSUBSYSTEM=$SUBSYSTEM - - # generate new configuration file with lmc --ptldebug and --subsystem - PTLDEBUG="trace" - SUBSYSTEM="mdc" - gen_config - - # check the result of lmc --ptldebug/subsystem start_ost - start_mds - mount_client $MOUNT - CHECK_PTLDEBUG="`cat /proc/sys/portals/debug`" - if [ $CHECK_PTLDEBUG = "1" ]; then - echo "lmc --debug success" - else - echo "lmc --debug: want 1, have $CHECK_PTLDEBUG" - return 1 - fi - CHECK_SUBSYSTEM="`cat /proc/sys/portals/subsystem_debug`" - if [ $CHECK_SUBSYSTEM = "2" ]; then - echo "lmc --subsystem success" - else - echo "lmc --subsystem: want 2, have $CHECK_SUBSYSTEM" - return 1 - fi - check_mount || return 41 - cleanup || return $? - # the new PTLDEBUG/SUBSYSTEM used for lconf --ptldebug/subsystem - PTLDEBUG="inode+trace" - SUBSYSTEM="mds+ost" + do_facet ost1 sysctl lnet.debug=\'inode trace\' || return 1 + do_facet ost1 sysctl lnet.subsystem_debug=\'mds ost\' || return 1 - # check lconf --ptldebug/subsystem overriding lmc --ptldebug/subsystem - start_ost - start_mds - CHECK_PTLDEBUG="`do_facet mds cat /proc/sys/portals/debug`" - if [ $CHECK_PTLDEBUG = "3" ]; then - echo "lconf --debug success" + CHECK_PTLDEBUG="`do_facet ost1 sysctl -n lnet.debug`" + if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then + echo "lnet.debug success" else - echo "lconf --debug: want 3, have $CHECK_PTLDEBUG" + echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'" return 1 fi - CHECK_SUBSYSTEM="`do_facet mds cat /proc/sys/portals/subsystem_debug`" - if [ $CHECK_SUBSYSTEM = "20" ]; then - echo "lconf --subsystem success" + CHECK_SUBSYS="`do_facet ost1 sysctl -n lnet.subsystem_debug`" + if [ "$CHECK_SUBSYS" ] && [ "$CHECK_SUBSYS" = "mds ost" ]; then + echo "lnet.subsystem_debug success" else - echo "lconf --subsystem: want 20, have $CHECK_SUBSYSTEM" + echo "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'" return 1 fi - mount_client $MOUNT - check_mount || return 41 - cleanup || return $? - - # resume the old configuration - PTLDEBUG=$OLDPTLDEBUG - SUBSYSTEM=$OLDSUBSYSTEM - gen_config + stop_ost || return $? } -run_test 9 "test --ptldebug and --subsystem for lmc and lconf" +run_test 9 "test ptldebug and subsystem for mkfs" test_10() { + echo "generate configuration with the same name for node and mds" OLDXMLCONFIG=$XMLCONFIG XMLCONFIG="broken.xml" [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG - SAMENAME="mds1" - do_lmc --add node --node $SAMENAME - do_lmc --add net --node $SAMENAME --nid $SAMENAME --nettype tcp - do_lmc --add mds --node $SAMENAME --mds $SAMENAME --nid $SAMENAME \ - --fstype ext3 --dev /dev/mds1 || return $? - do_lmc --add lov --lov lov1 --mds $SAMENAME --stripe_sz 65536 \ - --stripe_cnt 1 --stripe_pattern 0 || return $? + facet="mds" + rm -f ${facet}active + add_facet $facet + echo "the name for node and mds is the same" + do_lmc --add mds --node ${facet}_facet --mds ${facet}_facet \ + --dev $MDSDEV --size $MDSSIZE || return $? + do_lmc --add lov --mds ${facet}_facet --lov lov1 --stripe_sz \ + $STRIPE_BYTES --stripe_cnt $STRIPES_PER_OBJ \ + --stripe_pattern 0 || return $? + add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE + facet="client" + add_facet $facet --lustre_upcall $UPCALL + do_lmc --add mtpt --node ${facet}_facet --mds mds_facet \ + --lov lov1 --path $MOUNT + + echo "mount lustre" + start_ost + start_mds + mount_client $MOUNT + check_mount || return 41 + cleanup || return $? + echo "Success!" XMLCONFIG=$OLDXMLCONFIG } -run_test 10 "use lmc with the same name for node and mds" +run_test 10 "mount lustre with the same name for node and mds" test_11() { OLDXMLCONFIG=$XMLCONFIG @@ -386,8 +417,8 @@ test_12() { # test double quote [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG [ -f "$BATCHFILE" ] && rm -f $BATCHFILE - echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE - echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE + echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE + echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128\"" >> $BATCHFILE # --mkfsoptions "-I 128" do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $? if [ `sed -n '/>-I 128
$BATCHFILE - echo "--add mds --node localhost --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE + echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE + echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \"-I 128" >> $BATCHFILE # --mkfsoptions "-I 128 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $? echo "unmatched double quote should return error" # test single quote rm -f $BATCHFILE - echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE - echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE + echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE + echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128'" >> $BATCHFILE # --mkfsoptions '-I 128' do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $? if [ `sed -n '/>-I 128 $BATCHFILE - echo "--add mds --node localhost --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE + echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE + echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions '-I 128" >> $BATCHFILE # --mkfsoptions '-I 128 do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $? echo "unmatched single quote should return error" # test backslash rm -f $BATCHFILE - echo "--add net --node localhost --nid localhost.localdomain --nettype tcp" > $BATCHFILE - echo "--add mds --node localhost --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE + echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE + echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions \-\I\ \128" >> $BATCHFILE # --mkfsoptions \-\I\ \128 do_lmc -m $XMLCONFIG --batch $BATCHFILE || return $? if [ `sed -n '/>-I 128 $BATCHFILE - echo "--add mds --node localhost --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE + echo "--add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp" > $BATCHFILE + echo "--add mds --node $HOSTNAME --mds mds1 --mkfsoptions -I\ 128\\" >> $BATCHFILE # --mkfsoptions -I\ 128\ do_lmc -m $XMLCONFIG --batch $BATCHFILE && return $? echo "backslash followed by nothing should return error" @@ -452,52 +483,62 @@ run_test 12 "lmc --batch, with single/double quote, backslash in batchfile" test_13() { OLDXMLCONFIG=$XMLCONFIG XMLCONFIG="conf13-1.xml" - SECONDXMLCONFIG="conf13-2.xml" # check long uuid will be truncated properly and uniquely echo "To generate XML configuration file(with long ost name): $XMLCONFIG" [ -f "$XMLCONFIG" ] && rm -f $XMLCONFIG - do_lmc --add net --node localhost --nid localhost.localdomain --nettype tcp - do_lmc --add mds --node localhost --mds mds1_name_longer_than_31characters - do_lmc --add mds --node localhost --mds mds2_name_longer_than_31characters + do_lmc --add net --node $HOSTNAME --nid $HOSTNAME --nettype tcp + do_lmc --add mds --node $HOSTNAME --mds mds1_name_longer_than_31characters + do_lmc --add mds --node $HOSTNAME --mds mds2_name_longer_than_31characters if [ ! -f "$XMLCONFIG" ]; then echo "Error:no file $XMLCONFIG created!" return 1 fi EXPECTEDMDS1UUID="e_longer_than_31characters_UUID" EXPECTEDMDS2UUID="longer_than_31characters_UUID_2" - FOUNDMDS1UUID=`awk -F"'" '/