[PATCH pynfs v3 19/26] server41tests: verify filehandle in ADD notification
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, recording its filehandle via GETFH. Verify the ADD notification includes a filehandle attribute that matches. Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_dir_deleg.py | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/nfs4.1/server41tests/st_dir_deleg.py b/nfs4.1/server41tests/st_dir_deleg.py index c4778da61dcd..5d7c1a8fbaca 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -687,3 +687,54 @@ def testDirDelegReturnStopsNotify(t, env): if cb.got_notify or cb.got_recall: fail("Received callback after DELEGRETURN") + +def testDirDelegFilehandle(t, env): + """Verify filehandle in ADD notification matches GETFH result + + FLAGS: dirdeleg all + CODE: DIRDELEG16 + """ + 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) + + attrs = evt.nad_new_entry.ne_attrs + attrs.attrmask = bitmap4_to_int(attrs.attrmask) + attr_dict = nfs4lib.fattr2dict(attrs) + if FATTR4_FILEHANDLE not in attr_dict: + fail("No filehandle in ADD notification attributes") + if attr_dict[FATTR4_FILEHANDLE] != file_fh: + fail("Filehandle in notification doesn't match GETFH result") -- 2.54.0