. $EXCEPT_LIST_FILE
fi
+[ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
+[ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
+
assert_DIR () {
local failed=""
[[ $DIR/ = $MOUNT/* ]] || \
/sbin/lsmod | grep -q $1
}
+# Load a module on the system where this is running.
+#
+# Synopsis: load_module module_name [module arguments for insmod/modprobe]
+#
+# If module arguments are not given but MODOPTS_<MODULE> is set, then its value
+# will be used as the arguments. Otherwise arguments will be obtained from
+# /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
+#
load_module() {
+ local optvar
EXT=".ko"
module=$1
shift
BASE=`basename $module $EXT`
+ # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
+ # modprobe.conf
+ if [ $# -eq 0 ]; then
+ # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
+ # Bash until 4.x, so we resort to eval.
+ optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
+ eval set -- \$$optvar
+ if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
+ # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
+ set -- $(grep "^options\\s*\<${module}\>" $MODPROBECONF)
+ # Get rid of "options $module"
+ (($# > 0)) && shift 2
+
+ # Ensure we have accept=all for lnet
+ if [ $module = lnet ]; then
+ # OK, this is a bit wordy...
+ local arg accept_all_present=false
+ for arg in "$@"; do
+ [ "$arg" = accept=all ] && accept_all_present=true
+ done
+ $accept_all_present || set -- "$@" accept=all
+ fi
+ fi
+ fi
+
+ [ $# -gt 0 ] && echo "${module} options: '$*'"
+
module_loaded ${BASE} && return
+ # Note that insmod will ignore anything in modprobe.conf, which is why we're
+ # passing options on the command-line.
if [ "$BASE" == "lnet_selftest" ] && \
[ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
-
elif [ -f ${LUSTRE}/${module}${EXT} ]; then
- insmod ${LUSTRE}/${module}${EXT} $@
+ insmod ${LUSTRE}/${module}${EXT} "$@"
else
# must be testing a "make install" or "rpm" installation
# note failed to load ptlrpc_gss is considered not fatal
if [ "$BASE" == "ptlrpc_gss" ]; then
- modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
+ modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
else
- modprobe $BASE $@
+ modprobe $BASE "$@"
fi
fi
}
load_modules_local() {
if [ -n "$MODPROBE" ]; then
# use modprobe
- return 0
+ echo "Using modprobe to load modules"
+ return 0
fi
if [ "$HAVE_MODULES" = true ]; then
- # we already loaded
+ # we already loaded
+ echo "Modules already loaded"
return 0
fi
HAVE_MODULES=true
load_module ../libcfs/libcfs/libcfs
[ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
[ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
- local MODPROBECONF=
- [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
- [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
- [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
- LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
- echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
- echo "lnet options: '$LNETOPTS'"
- # note that insmod will ignore anything in modprobe.conf
- load_module ../lnet/lnet/lnet $LNETOPTS
+ load_module ../lnet/lnet/lnet
LNETLND=${LNETLND:-"socklnd/ksocklnd"}
load_module ../lnet/klnds/$LNETLND
load_module lvfs/lvfs
local command_status="$TMP/cs"
rsh $HOST ":> $command_status"
rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
- cd $RPWD; sh -c \"$@\") ||
+ cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
echo command failed >$command_status"
[ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
return 0
if $verbose ; then
# print HOSTNAME for myPDSH="no_dsh"
if [[ $myPDSH = no_dsh ]]; then
- $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
+ $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
else
- $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
+ $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
fi
else
- $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
+ $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
fi
return ${PIPESTATUS[0]}
}
[ "$1" = "$HOSTNAME" ]
}
+# Outputs environment variable assignments that should be passed to remote nodes
+get_env_vars() {
+ local var
+ local value
+
+ for var in ${!MODOPTS_*}; do
+ value=${!var}
+ echo "${var}=\"$value\""
+ done
+}
+
do_nodes() {
local verbose=false
# do not stripe off hostname if verbose, bug 19215
if single_local_node $rnodes; then
if $verbose; then
- do_node --verbose $rnodes $@
+ do_node --verbose $rnodes "$@"
else
- do_node $rnodes $@
+ do_node $rnodes "$@"
fi
return $?
fi
fi
if $verbose ; then
- $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
+ $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
else
- $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
+ $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/\w+:\s//g"
fi
return ${PIPESTATUS[0]}
}
rm -f $TMP/ost${num}active
done
+ if ! combined_mgs_mds ; then
+ stop mgs
+ fi
+
return 0
}
test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
}
+combined_mgs_mds () {
+ [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
+}
+
formatall() {
if [ "$IAMDIR" == "yes" ]; then
MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
load_modules
[ "$CLIENTONLY" ] && return
echo Formatting mgs, mds, osts
- if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
+ if ! combined_mgs_mds ; then
add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
fi
echo Setup mgs, mdt, osts
echo $WRITECONF | grep -q "writeconf" && \
writeconf_all
- if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
+ if ! combined_mgs_mds ; then
start mgs $MGSDEV $mgs_MOUNT_OPTS
fi
[ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
}
-som_check() {
- SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
- echo $SOM_ENABLED
-}
-
init_param_vars () {
if ! remote_ost_nodsh && ! remote_mds_nodsh; then
export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
osc_ensure_active $SINGLEMDS M $TIMEOUT
osc_ensure_active client c $TIMEOUT
- if [ x"$(som_check)" = x"enabled" ]; then
- ENABLE_QUOTA=""
- echo "disable quota temporary when SOM enabled"
- fi
if [ $QUOTA_AUTO -ne 0 ]; then
if [ "$ENABLE_QUOTA" ]; then
echo "enable quota as required"
return 1
fi
done
- if [[ $MDSDEV1 != $MGSDEV ]]; then
- stop mgs
- fi
-
return 0
}
error() {
error_noexit "$@"
- if $FAIL_ON_ERROR; then
- reset_fail_loc
- exit 1
- fi
+ exit 1
}
error_exit() {
- error_noexit "$@"
- exit 1
+ error "$@"
}
# use only if we are ignoring failures for this test, bugno required.
# print a newline if the last test was skipped
export LAST_SKIPPED=
+#
+# Main entry into test-framework. This is called with the name and
+# description of a test. The name is used to find the function to run
+# the test using "test_$name".
+#
+# This supports a variety of methods of specifying specific test to
+# run or not run. These need to be documented...
+#
run_test() {
assert_DIR
echo done.
}
+
+#
+# Log a message (on all nodes) padded with "=" before and after.
+# Also appends a timestamp and prepends the testsuite name.
+#
+banner() {
+ msg="== ${TESTSUITE} $*"
+ # pad the message out to 70 with "="
+ last=${msg: -1:1}
+ [[ $last != "=" && $last != " " ]] && msg+=" "
+ for i in $(seq $((68 - ${#msg})) ); do
+ msg+="="
+ done
+ # always include at least == after the message
+ msg+="=="
+
+ log "$msg $(date +"%H:%M:%S (%s)")"
+}
+
+#
+# Run a single test function and cleanup after it.
+#
+# This function should be run in a subshell so the test func can
+# exit() without stopping the whole script.
+#
run_one() {
- testnum=$1
- message=$2
+ local testnum=$1
+ local message=$2
tfile=f${testnum}
export tdir=d0.${TESTSUITE}/d${base}
export TESTNAME=test_$testnum
local SAVE_UMASK=`umask`
umask 0022
- echo
- log "== test $testnum: $message == `date +%H:%M:%S`"
+ banner "test $testnum: $message"
test_${testnum} || error "test_$testnum failed with $?"
cd $SAVE_PWD
reset_fail_loc
return 0
}
+#
+# Wrapper around run_one to ensure:
+# - test runs in subshell
+# - output of test is saved to separate log file for error reporting
+# - test result is saved to data file
+#
run_one_logged() {
local BEFORE=`date +%s`
local TEST_ERROR
local test_log=$LOGDIR/$name
rm -rf $LOGDIR/err
+ echo
run_one $1 "$2" 2>&1 | tee $test_log
local RC=${PIPESTATUS[0]}
rm -f $file
}
+setstripe_nfsserver () {
+ local dir=$1
+
+ local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
+ { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
+
+ [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
+
+ do_node --verbose $nfsserver lfs setstripe "$@"
+}
+
check_runas_id_ret() {
local myRC=0
local myRUNAS_UID=$1
echo $IFree
}
+mdsrate_inodes_available () {
+ echo $(($(inodes_available) - 1))
+}
+
# reset llite stat counters
clear_llite_stats(){
lctl set_param -n llite.*.stats 0
shift
# Add paths to lustre tests for 32 and 64 bit systems.
- local RPATH="$LUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
- do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
+ local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
+ do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
}
wait_clients_import_state () {