diff mbox series

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

Message ID 20210324014630.2454-3-calum.mackay@oracle.com (mailing list archive)
State New
Headers show
Series add another courteous server test | expand

Commit Message

Calum Mackay March 24, 2021, 1:46 a.m. UTC
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@oracle.com>
---
 nfs4.1/server41tests/st_courtesy.py | 33 +++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff mbox series

Patch

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)