[PATCH pynfs v3 13/26] server41tests: add a test for directory add notifications
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Request a dir delegation with ADD_ENTRY notifications. Create a file from a second client. Verify the server sends a CB_NOTIFY with the correct ADD event. Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_dir_deleg.py | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/nfs4.1/server41tests/st_dir_deleg.py b/nfs4.1/server41tests/st_dir_deleg.py index 5b39f38a478c..e906633a7972 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -415,3 +415,48 @@ def testDirDelegRemove(t, env): fail("Expected REMOVE notification, got %d" % evt_type) if evt.nrm_old_entry.ne_file != env.testname(t): fail("Wrong entry name in REMOVE notification") + +def testDirDelegAdd(t, env): + """Create a dir_deleg that accepts notification of ADD events + + FLAGS: dirdeleg all + CODE: DIRDELEG10 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_ADD_ENTRY, + NOTIFY4_GFLAG_EXTEND], cb) + + sess2 = c.new_client_session(b"%s_2" % env.testname(t)) + 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 = sess2.compound(open_op) + check(res) + open_stateid = res.resarray[-2].stateid + file_fh = res.resarray[-1].object + + completed = cb.wait(2) + + delegreturn_op = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(delegreturn_op) + check(res) + + close_file(sess2, file_fh, stateid=open_stateid) + + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_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_ADD_ENTRY: + 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") -- 2.54.0