pynfs server-side unlink test
Subsystems (2)
These are a couple patches to help me test some delegation changes; I'm committing them to my pynfs repo for now.
--b.
PATCH 1/2 Generalize reboot helper script
We allow the user to pass a script on the testserver commandline that reboots the server.
There will be more cases like this where we want to do something special on the server that can't be done through the protocol and may depend on local configuration details.
So instead of adding a new helper script for each one, use a single "serverhelper" script that can be passed different commands. Fall back on requesting manual intervention in the absence of the script.
--- lib/nfs4/servertests/environment.py | 16 ++++++++++++ lib/nfs4/servertests/st_reboot.py | 46 +++++++++++++--------------------- sample_files/send_reboot.py | 17 ------------- sample_files/server_helper.sh | 17 +++++++++++++ testserver.py | 13 +++++---- 5 files changed, 58 insertions(+), 51 deletions(-) delete mode 100755 sample_files/send_reboot.py create mode 100644 sample_files/server_helper.sh
lib/nfs4/servertests/environment.py +16 -0
@@ -15,6 +15,7 @@ from nfs4.nfs4_const import * from nfs4.nfs4_type import fsid4, nfsace4, fs_locations4, fs_location4, \ specdata4, nfstime4, settime4, stateid4 import rpc +import sys import os class AttrInfo(object):
@@ -210,6 +211,21 @@ class Environment(testmod.Environment): time.sleep(sec) print "Woke up" + def serverhelper(self, args): + """Perform a special operation on the server side (such as + rebooting the server)""" + if self.opts.serverhelper is None: + print "Manual operation required on server:" + print args + " and hit ENTER when done" + sys.stdin.readline() + print "Continuing with test" + else: + cmd = self.opts.serverhelper + if self.opts.serverhelperarg: + cmd += ' ' + self.opts.serverhelperarg + cmd += ' ' + args + os.system(cmd); + ######################################### debug_fail = False
lib/nfs4/servertests/st_reboot.py +18 -28
131 lines not on this page · raw message
sample_files/send_reboot.py deleted +0 -17
@@ -1,17 +0,0 @@ -#!/usr/bin/python - -import sys -import os - -""" -A simple reboot script for the reboot tests that reboots a virtual guest. -It would be used by adding ---rebootscript=sample/send_reboot.py --rebootargs=SERVERNAME -to testserver.py's commandline arguments. -""" - -def reboot(servername): - os.system('virsh destroy ' + servername) - os.system('virsh start ' + servername) - -reboot(sys.argv[1])
sample_files/server_helper.sh new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/bash + +# A simple script for the reboot tests that reboots a virtual guest. +# It would be used by adding +# --serverhelper=sample/send_reboot.py --serverhelperarg=SERVERNAME +# to testserver.py's commandline arguments. + +server=$1 +command=$2 +shift; shift + +case $command in +reboot ) + virsh destroy $server + virsh start $server + ;; +esac
testserver.py +7 -6
@@ -122,8 +122,9 @@ def scan_options(p): .usedir = (None) .usespecial= (None) - .rebootscript = (None) - .rebootargs = (None) + .serverhelper = (None) + .serverhelperarg = (None) + """ p.add_option("--showflags", action="store_true", default=False, help="Print a list of all possible flags and exit")
@@ -225,11 +226,11 @@ def scan_options(p): "the scripts and arguments used to control how the " "server is restarted.") - g.add_option("--rebootscript", default=None, metavar="FILE", - help="Use FILE as the script to reboot SERVER.") + g.add_option("--serverhelper", default=None, metavar="FILE", + help="Use script to perform special actions on server") - g.add_option("--rebootargs", default=None, metavar="ARGS", - help="Pass ARGS as a string to the reboot script.") + g.add_option("--serverhelperarg", default=None, metavar="ARG", + help="Pass ARG as first argument to serverhelper"); p.add_option_group(g)
Signature · 1 line
1.7.4.1
PATCH 2/2 TESTS: add server-side unlink test
In reply to J. Bruce FieldsAdd a test that checks whether a delegreturn is sent when a file is unlinked on the server using some other means than NFS.
--- lib/nfs4/servertests/st_delegation.py | 19 ++++++++++++++++++- sample_files/server_helper.sh | 13 +++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-)
lib/nfs4/servertests/st_delegation.py +18 -1
@@ -561,4 +561,21 @@ def testRemove(t, env): sleeptime = 20 _verify_cb_occurred(t, c, count) - +def _listToPath(components): + return '/'+reduce((lambda x,y:x+'/'+y), components) + +def testServerRemove(t, env): + """DELEGATION test + + Get read delegation, then ensure removing the file on the server + recalls it. Respond properly and send DELEGRETURN. + + FLAGS: delegations + CODE: DELEG16 + """ + c = env.c1 + count = c.cb_server.opcounts[OP_CB_RECALL] + c.init_connection('pynfs%i_%s' % (os.getpid(), t.code), cb_ident=0) + _get_deleg(t, c, c.homedir + [t.code], _recall, NFS4_OK) + env.serverhelper("unlink " + _listToPath(c.homedir + [t.code])); + _verify_cb_occurred(t, c, count)
sample_files/server_helper.sh +9 -4
@@ -1,9 +1,11 @@ #!/bin/bash -# A simple script for the reboot tests that reboots a virtual guest. -# It would be used by adding -# --serverhelper=sample/send_reboot.py --serverhelperarg=SERVERNAME -# to testserver.py's commandline arguments. +# A simple script that can reboot a virtual guest using virsh, or unlink +# a file on the server. It would be used by adding +# --serverhelper=sample/server_helper.sh --serverhelperarg=SERVERNAME +# to testserver.py's commandline arguments, where SERVERNAME is +# something that works either as a libvirt domain or as a hostname to +# ssh to. server=$1 command=$2
@@ -14,4 +16,7 @@ reboot ) virsh destroy $server virsh start $server ;; +unlink ) + path=$1 + ssh $server "rm $1" esac
Signature · 1 line
1.7.4.1