@@ -180,3 +180,65 @@ def testOpenDowngradeLock(t, env):
os.open(OPEN4_SHARE_ACCESS_READ)
os.downgrade(OPEN4_SHARE_ACCESS_READ)
os.close()
+
+def testOpenUpgradeconflict(t, env):
+ """test open upgrade that conflicts with another active client
+
+ FLAGS: opendowngrade all
+ DEPEND: MKFILE
+ CODE:OPDG12
+ """
+ c = env.c1
+ c.init_connection()
+ os = open_sequence(c, t.word())
+ os.open(OPEN4_SHARE_ACCESS_WRITE)
+
+ c2 = env.c2
+ c2.init_connection()
+ res = c2.open_file(t.word(), access=OPEN4_SHARE_ACCESS_READ,
+ deny=OPEN4_SHARE_DENY_NONE)
+ check(res)
+ fh, stateid = c2.confirm(t.word(), res)
+ res = c2.open_file(t.word(), access=OPEN4_SHARE_ACCESS_READ,
+ deny=OPEN4_SHARE_DENY_WRITE)
+ check(res, NFS4ERR_SHARE_DENIED)
+
+ res = c2.close_file(t.word(), fh, stateid)
+ check(res)
+ os.close()
+
+def testOpenUpgradeCourtesy(t, env):
+ """test open upgrade that conflicts with courtesy client
+
+ FLAGS: opendowngrade all
+ DEPEND: MKFILE
+ CODE:OPDG13
+ """
+ c = env.c1
+ c.init_connection()
+ os = open_sequence(c, t.word())
+ os.open(OPEN4_SHARE_ACCESS_WRITE)
+ leasetime = c.getLeaseTime()
+ env.sleep(leasetime/2, "sleep 1/2 grace period")
+
+ c2 = env.c2
+ c2.init_connection()
+ owner = t.word()
+ res = c2.open_file(owner, access=OPEN4_SHARE_ACCESS_READ,
+ deny=OPEN4_SHARE_DENY_NONE)
+ check(res)
+ fh, stateid = c2.confirm(owner, res)
+
+ env.sleep((leasetime/2) + 5, "wait for c1's lease to expire")
+ while 1:
+ res = c2.open_file(owner, access=OPEN4_SHARE_ACCESS_READ,
+ deny=OPEN4_SHARE_DENY_WRITE)
+ if res.status == NFS4_OK: break
+ check(res, [NFS4_OK, NFS4ERR_DELAY],
+ "Open which causes conflict with courtesy client")
+ env.sleep(2, 'Got NFS4ERR_DELAY on open')
+
+ fh = res.resarray[-1].switch.switch.object
+ stateid = res.resarray[-2].switch.switch.stateid
+ res = c2.close_file(owner, fh, stateid)
+ check(res)
Add 2 tests, OPDG12 and OPDG13, to test deny mode code paths in nfs4_upgrade_open. OPDG12: test open upgrade that has deny mode conflict with an active client. OPDG12: test open upgrade that has deny mode conflict with a courtesy client. Signed-off-by: Dai Ngo <dai.ngo@oracle.com> --- nfs4.0/servertests/st_opendowngrade.py | 62 ++++++++++++++++++++++++++ 1 file changed, 62 insertions(+)