[PATCH pynfs v3 14/26] server41tests: add test for RENAME event notifications
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Request a dir delegation with RENAME_ENTRY notifications. Create a file, then rename it from a second client. Verify the server sends a CB_NOTIFY with the correct RENAME event. Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_dir_deleg.py | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/nfs4.1/server41tests/st_dir_deleg.py b/nfs4.1/server41tests/st_dir_deleg.py index e906633a7972..00d74b2c7300 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -460,3 +460,50 @@ def testDirDelegAdd(t, env): fail("Expected ADD notification, got %d" % evt_type) if evt.nad_new_entry.ne_file != env.testname(t): fail("Wrong entry name in ADD notification") + +def testDirDelegRename(t, env): + """Create a dir_deleg that accepts notification of RENAME events + + FLAGS: dirdeleg all + CODE: DIRDELEG11 + """ + c = env.c1 + cb = threading.Event() + + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_RENAME_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + claim = open_claim4(CLAIM_NULL, env.testname(t)) + owner = open_owner4(0, b"owner") + how = openflag4(OPEN4_CREATE, createhow4(GUARDED4, {FATTR4_SIZE:0})) + open_op = [ op.putfh(fh), op.open(0, + OPEN4_SHARE_ACCESS_WRITE | OPEN4_SHARE_ACCESS_WANT_NO_DELEG, + OPEN4_SHARE_DENY_NONE, owner, how, claim), op.getfh() ] + res = sess1.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + close_file(sess1, file_fh, stateid=open_stateid) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + topdir = c.homedir + [t.code.encode('utf8')] + oldpath = topdir + [env.testname(t)] + newpath = topdir + [b"%s_2" % env.testname(t)] + res = rename_obj(sess2, oldpath, newpath) + check(res) + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + if (not completed or not cb.got_notify): + fail("Didn't receive a CB_NOTIFY from the server!") + + evt_type, evt = decode_notify_event(cb.changes[0]) + if evt_type != NOTIFY4_RENAME_ENTRY: + fail("Expected RENAME notification, got %d" % evt_type) + if evt.nrn_old_entry.nrm_old_entry.ne_file != env.testname(t): + fail("Wrong old entry name in RENAME notification") -- 2.54.0