📄 conf-sanity.sh
字号:
#!/bin/bash# requirement:# add uml1 uml2 uml3 in your /etc/hosts# FIXME - there is no reason to use all of these different# return codes, espcially when most of them are mapped to something# else anyway. The combination of test number and return code# figure out what failed.set -eONLY=${ONLY:-"$*"}# These tests don't apply to mountconf# xml xml xml xml xml xml dumbMOUNTCONFSKIP="10 11 12 13 13b 14 15 "# bug number for skipped test: 13369ALWAYS_EXCEPT=" $CONF_SANITY_EXCEPT $MOUNTCONFSKIP 34a"# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!SRCDIR=`dirname $0`PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATHSAVE_PWD=$PWDLUSTRE=${LUSTRE:-`dirname $0`/..}RLUSTRE=${RLUSTRE:-$LUSTRE}HOSTNAME=`hostname`. $LUSTRE/tests/test-framework.shinit_test_env $@# use small MDS + OST size to speed formatting timeMDSSIZE=40000OSTSIZE=40000. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}#[ "$SLOW" = "no" ] && EXCEPT_SLOW="0 1 2 3 6 7 15 18 24b 25 30 31 32 33 34a "reformat() { formatall}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}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 $MDSDEV $MDS_MOUNT_OPTS || return 94}stop_mds() { echo "stop mds service on `facet_active_host mds`" # These tests all use non-failover stop stop mds -f || return 97}start_ost() { echo "start ost1 service on `facet_active_host ost1`" start ost1 `ostdevname 1` $OST_MOUNT_OPTS || return 95}stop_ost() { 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}start_client() { echo "start client on `facet_active_host client`" start client || return 99 }stop_client() { echo "stop client on `facet_active_host client`" stop client || return 100 }mount_client() { local MOUNTPATH=$1 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}manual_umount_client(){ local rc local FORCE=$1 echo "manual umount lustre on ${MOUNT}...." do_facet client "umount -d ${FORCE} $MOUNT" rc=$? return $rc}setup() { start_ost start_mds mount_client $MOUNT}cleanup_nocli() { stop_mds || return 201 stop_ost || return 202 unload_modules || return 203}cleanup() { umount_client $MOUNT || return 200 cleanup_nocli || return $?}check_mount() { 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"}check_mount2() { do_facet client "touch $DIR/a" || return 71 do_facet client "rm $DIR/a" || return 72 do_facet client "touch $DIR2/a" || return 73 do_facet client "rm $DIR2/a" || return 74 echo "setup double mount lustre success"}build_test_filterif [ "$ONLY" == "setup" ]; then setup exitfiif [ "$ONLY" == "cleanup" ]; then cleanup exitfi#create single point mountpointgen_configtest_0() { setup check_mount || return 41 cleanup || return $?}run_test 0 "single mount setup"test_1() { start_ost echo "start ost second time..." setup check_mount || return 42 cleanup || return $?}run_test 1 "start up ost twice (should return errors)"test_2() { start_ost start_mds echo "start mds second time.." start_mds mount_client $MOUNT check_mount || return 43 cleanup || return $?}run_test 2 "start up mds twice (should return err)"test_3() { setup #mount.lustre returns an error if already in mtab mount_client $MOUNT && return $? check_mount || return 44 cleanup || return $?}run_test 3 "mount client twice (should return err)"test_4() { setup touch $DIR/$tfile || return 85 stop_ost -f cleanup eno=$? # ok for ost to fail shutdown if [ 202 -ne $eno ]; then return $eno; fi return 0}run_test 4 "force cleanup ost, then cleanup"test_5a() { # was test_5 setup touch $DIR/$tfile || return 1 fuser -m -v $MOUNT && echo "$MOUNT is in use by user space process." 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 -d $MOUNT & UMOUNT_PID=$! sleep 6 echo "killing umount" kill -TERM $UMOUNT_PID echo "waiting for umount to finish" wait $UMOUNT_PID if grep " $MOUNT " /proc/mounts; then echo "test 5: /proc/mounts 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 " /proc/mounts && echo "test 5: /proc/mounts after second umount" && return 11 fi manual_umount_client # stop_mds is a no-op here, and should not fail cleanup_nocli || return $? # df may have lingering entry manual_umount_client # mtab may have lingering entry local WAIT=0 local MAX_WAIT=20 local sleep=1 while [ "$WAIT" -ne "$MAX_WAIT" ]; do sleep $sleep grep -q $MOUNT" " /etc/mtab || break echo "Waiting /etc/mtab updated ... " WAIT=$(( WAIT + sleep)) done [ "$WAIT" -eq "$MAX_WAIT" ] && error "/etc/mtab is not updated in $WAIT secs" echo "/etc/mtab updated in $WAIT secs"}run_test 5a "force cleanup mds, then cleanup"test_5b() { start_ost [ -d $MOUNT ] || mkdir -p $MOUNT 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 cleanup_nocli || return $? return 0}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 grep " $MOUNT " /etc/mtab && echo "test 5c: mtab before mount" && return 10 local oldfs="${FSNAME}" FSNAME="wrong.${FSNAME}" mount_client $MOUNT || : FSNAME=${oldfs} 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)"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#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 5e "delayed connect, don't crash (bug 10268)"test_6() { setup manual_umount_client mount_client ${MOUNT} || return 87 touch $DIR/a || return 86 cleanup || return $?}run_test 6 "manual umount, then mount again"test_7() { setup manual_umount_client cleanup_nocli || return $?}run_test 7 "manual umount, then cleanup"test_8() { setup mount_client $MOUNT2 check_mount2 || return 45 umount_client $MOUNT2 cleanup || return $?}run_test 8 "double mount setup"test_9() { start_ost do_facet ost1 sysctl lnet.debug=\'inode trace\' || return 1 do_facet ost1 sysctl lnet.subsystem_debug=\'mds ost\' || return 1 CHECK_PTLDEBUG="`do_facet ost1 sysctl -n lnet.debug`" if [ "$CHECK_PTLDEBUG" ] && [ "$CHECK_PTLDEBUG" = "trace inode" ];then echo "lnet.debug success" else echo "lnet.debug: want 'trace inode', have '$CHECK_PTLDEBUG'" return 1 fi 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 "lnet.subsystem_debug: want 'mds ost', have '$CHECK_SUBSYS'" return 1 fi stop_ost || return $?}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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -