diff mbox

[pynfs,05/12] Really, really close those open temp files to remove state on the server

Message ID 1480228001-64821-6-git-send-email-loghyr@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Haynes Nov. 27, 2016, 6:26 a.m. UTC
Signed-off-by: Tom Haynes <loghyr@primarydata.com>
---
 nfs4.1/server41tests/st_current_stateid.py  | 24 ++++++++++++++++++++++++
 nfs4.1/server41tests/st_reclaim_complete.py |  4 ++++
 nfs4.1/server41tests/st_rename.py           |  4 ++++
 nfs4.1/server41tests/st_secinfo.py          | 20 ++++++++++++++++----
 nfs4.1/server41tests/st_sequence.py         |  8 ++++++++
 5 files changed, 56 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/nfs4.1/server41tests/st_current_stateid.py b/nfs4.1/server41tests/st_current_stateid.py
index 01d78c0..792eee8 100644
--- a/nfs4.1/server41tests/st_current_stateid.py
+++ b/nfs4.1/server41tests/st_current_stateid.py
@@ -99,10 +99,23 @@  def testOpenLookupClose(t, env):
 
     fname = env.testname(t)
     open_op = open_create_file_op(sess1, fname, open_create=OPEN4_CREATE)
+
     lookup_op = env.home + [op.lookup(fname)]
     res = sess1.compound(open_op + lookup_op + [op.close(0, current_stateid)])
     check(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID])
 
+    # An unknown number of lookups will be present
+    for r in res.resarray:
+        if r.resop == OP_OPEN:
+            stateid = r.stateid
+        elif r.resop == OP_GETFH:
+            fh = r.object
+            break
+
+    # Test passed, now cleanup!
+    res = sess1.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
+
 def testCloseNoStateid(t, env):
     """test current state id processing by having CLOSE
        without operation which provides stateid
@@ -120,6 +133,10 @@  def testCloseNoStateid(t, env):
     res = sess1.compound([op.putfh(fh), op.close(0, current_stateid)])
     check(res, [NFS4ERR_STALE_STATEID, NFS4ERR_BAD_STATEID])
 
+    # Test passed, now cleanup!
+    res = sess1.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
+
 def testOpenLayoutGet(t, env):
     """test current state id processing by having OPEN and LAYOUTGET
        in a single compound
@@ -170,6 +187,13 @@  def testOpenFreestateidClose(t, env):
     open_op = open_create_file_op(sess1, env.testname(t), open_create=OPEN4_CREATE)
     res = sess1.compound(open_op + [op.free_stateid(current_stateid), op.close(0, current_stateid)])
     check(res, NFS4ERR_LOCKS_HELD)
+    fh = res.resarray[-2].object
+    stateid = res.resarray[-3].stateid
+
+    # Test passed, now cleanup!
+    res = sess1.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
+
 
 def testOpenSaveFHLookupRestoreFHClose(t, env):
     """test current state id processing by having OPEN, SAVEFH, LOOKUP, RESTOREFH and CLOSE
diff --git a/nfs4.1/server41tests/st_reclaim_complete.py b/nfs4.1/server41tests/st_reclaim_complete.py
index e945a9f..642ada2 100644
--- a/nfs4.1/server41tests/st_reclaim_complete.py
+++ b/nfs4.1/server41tests/st_reclaim_complete.py
@@ -47,6 +47,10 @@  def testReclaimAfterRECC(t, env):
 
     check(res, NFS4ERR_NO_GRACE, warnlist = [NFS4ERR_EXIST | NFS4ERR_RECLAIM_BAD])
 
+    # Cleanup
+    res = sess.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
+
 def testOpenBeforeRECC(t, env):
     """After a client establishes a new client ID, if non-reclaim
        locking operations are done before the RECLAIM_COMPLETE,
diff --git a/nfs4.1/server41tests/st_rename.py b/nfs4.1/server41tests/st_rename.py
index d87cca0..c7c2c20 100644
--- a/nfs4.1/server41tests/st_rename.py
+++ b/nfs4.1/server41tests/st_rename.py
@@ -496,6 +496,10 @@  def testSelfRenameFile(t, env):
         t.fail("RENAME of file %s into itself should do nothing, "
                "but cinfo was changed" % name)
 
+    # Cleanup
+    res = sess.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
+
 def testLinkRename(t, env):
     """RENAME of file into its hard link should do nothing
 
diff --git a/nfs4.1/server41tests/st_secinfo.py b/nfs4.1/server41tests/st_secinfo.py
index 234ec80..008dc1e 100644
--- a/nfs4.1/server41tests/st_secinfo.py
+++ b/nfs4.1/server41tests/st_secinfo.py
@@ -20,14 +20,20 @@  def testSupported(t, env):
     path = sess.c.homedir + [name]
     res = create_file(sess, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
     check(res)
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
 
     # Get the filehandle of the tmpfile's parent dir
     res = sess.compound(use_obj(sess.c.homedir) + [op.getfh()])
     check(res)
-    fh = res.resarray[-1].object
+    fh_p = res.resarray[-1].object
 
     # Just do a simple SECINFO
-    res = sess.compound([op.putfh(fh), op.secinfo(name)])
+    res = sess.compound([op.putfh(fh_p), op.secinfo(name)])
+    check(res)
+
+    # Cleanup
+    res = sess.compound([op.putfh(fh), op.close(0, stateid)])
     check(res)
 
 def testSupported2(t, env):
@@ -45,12 +51,18 @@  def testSupported2(t, env):
     path = sess.c.homedir + [name]
     res = create_file(sess, owner, path, access=OPEN4_SHARE_ACCESS_WRITE)
     check(res)
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
 
     # Get the filehandle of the tmpfile's parent dir
     res = sess.compound(use_obj(sess.c.homedir) + [op.getfh()])
     check(res)
-    fh = res.resarray[-1].object
+    fh_p = res.resarray[-1].object
 
     # GETFH after do a SECINFO should get error NFS4ERR_NOFILEHANDLE
-    res = sess.compound([op.putfh(fh), op.secinfo(name), op.getfh()])
+    res = sess.compound([op.putfh(fh_p), op.secinfo(name), op.getfh()])
     check(res, NFS4ERR_NOFILEHANDLE)
+
+    # Cleanup
+    res = sess.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
diff --git a/nfs4.1/server41tests/st_sequence.py b/nfs4.1/server41tests/st_sequence.py
index d12f355..d8d460c 100644
--- a/nfs4.1/server41tests/st_sequence.py
+++ b/nfs4.1/server41tests/st_sequence.py
@@ -129,6 +129,9 @@  def testReplayCache002(t, env):
     """
     sess1 = env.c1.new_client_session(env.testname(t))
     res = create_file(sess1, "%s_1" % env.testname(t))
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+
     check(res)
     ops = env.home + [op.savefh(),\
           op.rename("%s_1" % env.testname(t), "%s_2" % env.testname(t))]
@@ -140,6 +143,11 @@  def testReplayCache002(t, env):
     if not nfs4lib.test_equal(res1, res2):
         fail("Replay results not equal")
 
+    # Cleanup
+    res = sess1.compound([op.putfh(fh), op.close(0, stateid)])
+    check(res)
+
+
 def testReplayCache003(t, env):
     """Send two unsuccessful idempotent compounds with same seqid