[PATCH 2/2] pynfs: courtesy: add a test to ensure server releases state appropriately

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This test checks that the server will allow a conflicting lock from a
second client, after lease expiry of the first client.

This applies to both courteous, and discourteous servers, but ensures
that courteous servers don't just hang onto state indefinitely.

Signed-off-by: Calum Mackay <calum.mackay@xxxxxxxxxx>
---
 nfs4.1/server41tests/st_courtesy.py | 33 +++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/nfs4.1/server41tests/st_courtesy.py b/nfs4.1/server41tests/st_courtesy.py
index e74d9afbca60..dd911a37772d 100644
--- a/nfs4.1/server41tests/st_courtesy.py
+++ b/nfs4.1/server41tests/st_courtesy.py
@@ -48,3 +48,36 @@ def testLockSleepLockU(t, env):
 
     res = close_file(sess1, fh, stateid=stateid)
     check(res)
+
+def testLockSleepLock(t, env):
+    """ensure that a courteous server will allow a conflicting lock from
+       a second client, after lease expiry of the first client.
+       A discourteous server should allow this too, of course.
+
+    FLAGS: courteous all
+    CODE: COUR2
+    """
+
+    sess1 = env.c1.new_client_session(env.testname(t))
+
+    res = create_file(sess1, env.testname(t))
+    check(res)
+
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+    res = sess1.compound(cour_lockargs(fh, stateid))
+    check(res, NFS4_OK)
+
+    lease_time = _getleasetime(sess1)
+    env.sleep(lease_time * 2, "twice the lease period")
+
+    c2 = env.c1.new_client(b"%s_2" % env.testname(t))
+    sess2 = c2.create_session()
+
+    res = open_file(sess2, env.testname(t), access=OPEN4_SHARE_ACCESS_WRITE)
+    check(res)
+
+    fh = res.resarray[-1].object
+    stateid = res.resarray[-2].stateid
+    res = sess2.compound(cour_lockargs(fh, stateid))
+    check(res, NFS4_OK)
-- 
2.27.0




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux