cthon.zsh: Rewrite test

The runcthon script isn't the most straightforward for passing arbitrary
options or running with a specific NFS version. Deal with this by
writing our own version that does what we need it to do.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Anna Schumaker 2022-04-26 16:35:09 -04:00
parent 600fd846dc
commit 5e1664d88a
4 changed files with 89 additions and 8 deletions

View File

@ -24,11 +24,11 @@ while c := sys.stdin.read(1):
status=1
elif match := re.match("^./server -([bgsl]) .*?\n$", text):
print_text(colors[match.group(1)], None)
elif match := re.match("^Waiting for '([bgsl])' to finish...", text):
elif match := re.match("^Waiting for '\-([bgsl])' to finish ... ", text):
last = colors[match.group(1)]
newline = True
print_text(last, "bold")
elif match := re.match("^ Done: .*?\n$", text):
elif match := re.match("^Done: .*?\n$", text):
print_text(last, "bold")
newline = False
elif c == "\n":

View File

@ -2,10 +2,14 @@
function _cthon.zsh() {
_arguments \
{-a,--all}'[run all tests]' \
{-b,--basic}'[run basic tests]' \
{-c,--client}'[the client to test]: : _alternative
"hosts\:hosts\: _ssh_hosts"
"domains\:domains\:($(virsh list --all --name))"' \
--dmesg'[print client dmesg log after running tests]' \
{-g,--general}'[run general tests]' \
{-l,--locking}'[run locking tests]' \
--nconnect'[number of connections]: :($(seq 1 32))' \
--krb5'[run tests with sec=krb5]' \
--srvdmesg'[print server dmesg log after running tests]' \
@ -14,5 +18,7 @@ function _cthon.zsh() {
{-s,--server}'[the server to test against]: : _alternative
"hosts\:hosts\: _ssh_hosts"
"domains\:domains\:($(virsh list --all --name))"' \
{-S,--special}'[run special tests]' \
\*{-v,--version}+'[the nfs version to test (default=all)]: :(3 4 4.0 4.1 4.2)' \
{-x,--export}'[the exported directory on the server]: : _files -/'
}

View File

@ -1,29 +1,54 @@
#!/bin/zsh -e
source common.zsh
TESTS=(-a)
zparseopts -F -K \
a+=TESTS -all+=TESTS \
b+=TESTS -basic+=TESTS \
c:=CLIENT -client:=CLIENT \
-dmesg=DMESG -srvdmesg=SRVDMESG \
g+=TESTS -general+=TESTS \
l+=TESTS -locking+=TESTS \
p:=MOUNTPOINT -mountpoint:=MOUNTPOINT \
-nconnect:=NCONNECT \
-krb5=KRB5 \
r:=RDMA -rdma:=RDMA \
S+=TESTS -special+=TESTS \
s:=SERVER -server:=SERVER \
x:=EXPORT -export:=EXPORT
x:=EXPORT -export:=EXPORT \
v+:=VERSION -version+:=VERSION
COLOR=$BIN/colors/cthon.py
RUN_CTHON="cd cthon04 && sudo ./runcthon"
SEC=(sys)
ARGS=()
prepare_to_test
if [[ ${TESTS[(ie)-a]} -le ${#TESTS} ]]; then
TESTS=(-b -g -s -l)
fi
if [ ${#RDMA} -gt 0 ]; then
RUN_CTHON="$RUN_CTHON --rdma"
ARGS+=("--rdma")
fi
if [ ${#NCONNECT} -gt 0 ]; then
RUN_CTHON="$RUN_CTHON --nconnect ${NCONNECT[-1]}"
ARGS+=("--mntopt nconnect=${NCONNECT[-1]}")
fi
if [ ${#KRB5} -gt 0 ]; then
RUN_CTHON="$RUN_CTHON --dokrb5"
SEC+=(krb5 krb5i krb5p)
fi
for vers in $VERSION; do
ARGS+=("--version $vers")
done
ssh ${CLIENT[-1]} "$RUN_CTHON --server ${SERVER[-1]} --serverdir ${EXPORT[-1]}/$USER 2>&1" | python -u $COLOR
set +e
date | python -u $COLOR
for test in $TESTS; do
for sec in $SEC; do
client_run cthon.zsh --server ${SERVER[-1]} \
--export ${EXPORT[-1]} \
--mountpoint ${MOUNTPOINT[-1]} \
--user $USER --mntopt sec=$sec \
$test $ARGS | python -u $COLOR
done
done

50
run/cthon.zsh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/zsh
PROTO=(tcp)
zparseopts -D -K -server:=SERVER -export:=EXPORT -mountpoint:=MOUNTPOINT \
-user:=USER -rdma=RDMA -version+:=VERSION -mntopt+:=MOUNTOPTS \
b=TEST g=TEST s=TEST l=TEST
if [ ${#RDMA} -gt 0 ]; then
PROTO+=(rdma)
fi
exclude=(--mntopt)
MOUNTOPTS=(${(ou)MOUNTOPTS:|exclude})
function runtest
{
./server ${TEST[-1]} -o $1 -m $2 -p $3 ${SERVER[-1]} > $4 2>&1
if [ $? -ne 0 ]; then
echo ""
echo "The '${TEST[-1]}' test using '$1' options to ${SERVER[-1]}: Failed!!"
mv $4 $4-`date +"%H:%M:%S"`.error
fi
if [ $(grep -c $2 /proc/mounts) -gt 0 ]; then
sudo umount $2
fi
}
cd cthon04
for proto in $PROTO; do
for vers in $VERSION; do
[[ "$vers" == "--version" ]] && continue
dir=$(echo "nfsv${vers}${proto}" | sed 's/\.//' | sed 's/v40/v4/')
mnt=${MOUNTPOINT[-1]}/$dir
xprt=${EXPORT[-1]}/${USER[-1]}/$dir
opts="v$vers,proto=$proto"
for o in $MOUNTOPTS; do
opts="$opts,$o"
done
echo "./server ${TEST[-1]} -o $opts -m $mnt -p $xprt ${SERVER[-1]}"
runtest $opts $mnt $xprt /tmp/nfsv${vers}${proto} &
done
done
echo -n "Waiting for '${TEST[-1]}' to finish ... "
wait
echo -n "Done: "
date +"%X"