[PATCH pynfs v3 15/26] server41tests: verify child attributes 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. Verify the ADD notification includes child attributes with a correct size. 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 00d74b2c7300..a12fa13878e4 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -507,3 +507,54 @@ def testDirDelegRename(t, env): 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") + +def testDirDelegChildAttrs(t, env): + """Verify child attributes are present in ADD notification + + FLAGS: dirdeleg all + CODE: DIRDELEG12 + """ + 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 + if not any(attrs.attrmask): + fail("No child attributes in ADD notification") + attrs.attrmask = bitmap4_to_int(attrs.attrmask) + attr_dict = nfs4lib.fattr2dict(attrs) + if FATTR4_SIZE in attr_dict and attr_dict[FATTR4_SIZE] != 0: + fail("Expected size 0 for new file, got %d" % attr_dict[FATTR4_SIZE]) -- 2.54.0