From d4004252555b2f4c3c0fea4787cc369b8f518441 Mon Sep 17 00:00:00 2001 From: mfrey Date: Thu, 9 Oct 2003 13:59:38 +0000 Subject: [PATCH] driver scripts for upcoming QOS unit tests --- lustre/tests/qos-config.sh | 52 +++++++++++++ lustre/tests/qos.sh | 188 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 240 insertions(+) create mode 100755 lustre/tests/qos-config.sh create mode 100644 lustre/tests/qos.sh diff --git a/lustre/tests/qos-config.sh b/lustre/tests/qos-config.sh new file mode 100755 index 0000000..563ef15 --- /dev/null +++ b/lustre/tests/qos-config.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# usually run out of qos.sh +# the following variables are set in qos.sh too and +# get exported +SERVER=${SERVER:-`hostname`} +MOUNT=${MOUNT:-/mnt/lustre} +# override server_nid and network type if not running +# tcp on interface same as hostname +NETWORKTYPE=${NETWORKTYPE:-tcp} +SERVER_NID=${SERVER_NID:-${SERVER}} + +# generic settings +SRCDIR=`dirname $0` +PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH +LMC=${LMC:-lmc} +CONFIG=${1:-qos-config.xml} +TMP=${TMP:-/tmp} +FSTYPE=${FSTYPE:-ext3} +MDSDEV=${MDSDEV:-${TMP}/mds1-`hostname`} +MDSSIZE=${MDSSIZE:-50000} +OSTDEVS=${OSTDEVS:-"${TMP}/ost0-`hostname` ${TMP}/ost1-`hostname` ${TMP}/ost2-`hostname`"} +OSTSIZE=${OSTSIZES:-100000} +STRIPE_BYTES=65536 +STRIPES_PER_OBJ=0 # 0 means stripe over all OSTs + + +# create server node +${LMC} -o ${CONFIG} --add node --node ${SERVER} || exit 10 +${LMC} -m ${CONFIG} --add net --node ${SERVER} --nid ${SERVER_NID} --nettype ${NETWORKTYPE} || exit 11 + +# configure MDS +${LMC} -m ${CONFIG} --add mds --nspath /mnt/mds_ns --node ${SERVER} --mds qos_mds --fstype ${FSTYPE} \ + --dev ${MDSDEV} --size ${MDSSIZE} || exit 20 + +# configure LOV +${LMC} -m ${CONFIG} --add lov --lov qos_lov --mds qos_mds --stripe_sz ${STRIPE_BYTES} \ + --stripe_cnt ${STRIPES_PER_OBJ} || exit 30 + +# configure OSTS +i=0 +for obd in $OSTDEVS; do + ${LMC} -m ${CONFIG} --add ost --node ${SERVER} --nid ${SERVER_NID} \ + --ost obd$i --lov qos_lov --dev ${obd} --fstype ${FSTYPE} --size ${OSTSIZE} || exit $((i+40)) + i=$((i+1)) +done + +# create local mount point +${LMC} -m ${CONFIG} --add mtpt --node ${SERVER} --path ${MOUNT} --mds qos_mds --lov qos_lov || exit 50 + +# create generic client node +${LMC} -m ${CONFIG} --add net --node client --nid '*' --nettype $NETWORKTYPE || exit 60 +${LMC} -m ${CONFIG} --add mtpt --node client --path ${MOUNT} --mds qos_mds --lov qos_lov || exit 70 diff --git a/lustre/tests/qos.sh b/lustre/tests/qos.sh new file mode 100644 index 0000000..f96fdad --- /dev/null +++ b/lustre/tests/qos.sh @@ -0,0 +1,188 @@ +#!/bin/bash +# +# Run select tests by setting ONLY, or as arguments to the script. +# Skip specific tests by setting EXCEPT. +# +# e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31" +set -e + +ONLY=${ONLY:-"$*"} +# bug number for skipped test: +ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""} +# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! + +# The QOS tests need two nodes. The first acts as server (variable SERVER), +# the second as client only. +# The principle behind the QOS unit test is: +# 1) create an unbalanced situation on SERVER +# 2) perform opertion on CLIENT to trigger QOS information update +# 3) verify usage of new QOS information on CLIENT +SERVER=${SERVER:-`hostname`} +# must change client to a valid hostname +CLIENT=${CLIENT:-""} + +SRCDIR=`dirname $0` +PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH + +LFIND=${LFIND:-lfind} +LSTRIPE=${LSTRIPE:-lstripe} +LCTL=${LCTL:-lctl} +RSH=${RSH:-rsh} +CHECKSTAT=${CHECKSTAT:-"checkstat -v"} + +QOSPROC="/proc/sys/lustre" + +export NAME=${NAME:-qos-config} + +SAVE_PWD=$PWD +FULL_SRCDIR=${SAVE_PWD}/${SRCDIR} + +clean() { + echo -n "cln.." + ${RSH} ${CLIENT} "cd ${FULL_SRCDIR}; NAME=${NAME} NODE=client sh ./llmountcleanup.sh" || exit 20 + sh llmountcleanup.sh > /dev/null || exit 21 + I_MOUNTED=no +} +CLEAN=${CLEAN:-clean} + +start() { + echo -n "mnt.." + sh llrmount.sh > /dev/null || exit 10 + ${RSH} ${CLIENT} "cd ${FULL_SRCDIR}; NAME=${NAME} NODE=client sh ./llrmount.sh" || exit 11 + I_MOUNTED=yes + echo "done" +} +START=${START:-start} + +log() { + echo "$*" + lctl mark "$*" 2> /dev/null || true +} + +run_one() { + if ! mount | grep -q $DIR; then + $START + fi + log "== test $1: $2" + test_$1 || error "test_$1: $?" + pass + cd $SAVE_PWD + $CLEAN +} + +build_test_filter() { + for O in $ONLY; do + eval ONLY_${O}=true + done + for E in $EXCEPT $ALWAYS_EXCEPT; do + eval EXCEPT_${E}=true + done +} + +_basetest() { + echo $* +} + +basetest() { + IFS=abcdefghijklmnopqrstuvwxyz _basetest $1 +} + +run_test() { + base=`basetest $1` + if [ "$ONLY" ]; then + testname=ONLY_$1 + if [ ${!testname}x != x ]; then + run_one $1 "$2" + return $? + fi + testname=ONLY_$base + if [ ${!testname}x != x ]; then + run_one $1 "$2" + return $? + fi + echo -n "." + return 0 + fi + testname=EXCEPT_$1 + if [ ${!testname}x != x ]; then + echo "skipping excluded test $1" + return 0 + fi + testname=EXCEPT_$base + if [ ${!testname}x != x ]; then + echo "skipping excluded test $1 (base $base)" + return 0 + fi + run_one $1 "$2" + return $? +} + +error() { + log "FAIL: $@" + exit 1 +} + +pass() { + echo PASS +} + +[ -z "${CLIENT}" ] && echo "CLIENT must not be empty" && exit 96 + +MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" +if [ -z "$MOUNT" ]; then + sh llmount.sh + MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" + [ -z "$MOUNT" ] && error "NAME=$NAME not mounted" + I_MOUNTED=yes + ${RSH} ${CLIENT} "cd ${FULL_SRCDIR}; NAME=${NAME} NODE=client sh ./llrmount.sh" || exit 97 + CLIENT_MOUNT="`${RSH} ${CLIENT} mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" + [ -z "${CLIENT_MOUNT}" ] && echo "NAME=${NAME} not mounted on remote client ${CLIENT}" && exit 98 +fi + +[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once" + +DIR=${DIR:-$MOUNT} +[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99 + +LOVNAME=`cat /proc/fs/lustre/llite/fs0/lov/common_name` +STRIPECOUNT=`cat /proc/fs/lustre/lov/$LOVNAME/numobd` + +rm -rf $DIR/[Rdfs][1-9]* + +build_test_filter + +test_0() { + cat ${QOSPROC}/QoS_statfs_interval || error + cat ${QOSPROC}/QoS_rescan_interval || error + cat ${QOSPROC}/QoS_update_interval || error + cat ${QOSPROC}/QoS_freeblock_imbalance || error + cat ${QOSPROC}/QoS_freeblock_percent || error + cat ${QOSPROC}/QoS_nobjects_imbalance || error +} +run_test 0 "cat ${QOSPROC}/QoS_*" + +test_1() { + ${RSH} ${CLIENT} cat ${QOSPROC}/QoS_statfs_interval || error + ${RSH} ${CLIENT} cat ${QOSPROC}/QoS_rescan_interval || error + ${RSH} ${CLIENT} cat ${QOSPROC}/QoS_update_interval || error + ${RSH} ${CLIENT} cat ${QOSPROC}/QoS_freeblock_imbalance || error + ${RSH} ${CLIENT} cat ${QOSPROC}/QoS_freeblock_percent || error + ${RSH} ${CLIENT} cat ${QOSPROC}/QoS_nobjects_imbalance || error +} +run_test 1 "${RSH} ${CLIENT} cat ${QOSPROC}/QoS_*" + +TMPDIR=$OLDTMPDIR +TMP=$OLDTMP +HOME=$OLDHOME + +log "cleanup: ======================================================" +CLIENT_MOUNT="`${RSH} ${CLIENT} mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" +if [ "${CLIENT_MOUNT}" ]; then + ${RSH} ${CLIENT} "cd ${FULL_SRCDIR}; NAME=${NAME} NODE=client sh ./llmountcleanup.sh" || error +fi +if [ "$I_MOUNTED" = "yes" -a "`mount | grep ^$NAME`" ]; then + rm -rf $DIR/[Rdfs][1-9]* + sh llmountcleanup.sh || error +fi + +echo '=========================== finished ===============================' -- 1.8.3.1