[PATCH pynfs v3 12/26] server41tests: add a test for removal from dir with dir delegation
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Request a dir delegation with REMOVE_ENTRY notifications. Create a file, then remove it from a second client. Verify the server sends a CB_NOTIFY with the correct REMOVE event. Also add full child and directory attribute bitmaps to the GET_DIR_DELEGATION request for all CB_NOTIFY tests. Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_dir_deleg.py | 65 ++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/nfs4.1/server41tests/st_dir_deleg.py b/nfs4.1/server41tests/st_dir_deleg.py index 8fe2ba54fc67..5b39f38a478c 100644 --- a/nfs4.1/server41tests/st_dir_deleg.py +++ b/nfs4.1/server41tests/st_dir_deleg.py @@ -68,8 +68,26 @@ def _getDirDeleg(t, env, notify_mask, cb): mask_bm = nfs4lib.list2bitmap(notify_mask) ops = [ op.putfh(fh), op.get_dir_delegation(False, nfs4lib.list2bitmap(notify_mask), zerotime, zerotime, - nfs4lib.list2bitmap([]), - nfs4lib.list2bitmap([]))] + nfs4lib.list2bitmap([FATTR4_TYPE, + FATTR4_CHANGE, + FATTR4_SIZE, + FATTR4_FILEID, + FATTR4_FILEHANDLE, + FATTR4_MODE, + FATTR4_NUMLINKS, + FATTR4_RAWDEV, + FATTR4_SPACE_USED, + FATTR4_TIME_ACCESS, + FATTR4_TIME_METADATA, + FATTR4_TIME_MODIFY, + FATTR4_TIME_CREATE]), + nfs4lib.list2bitmap([FATTR4_CHANGE, + FATTR4_SIZE, + FATTR4_NUMLINKS, + FATTR4_SPACE_USED, + FATTR4_TIME_ACCESS, + FATTR4_TIME_METADATA, + FATTR4_TIME_MODIFY]))] res = sess1.compound(ops) check(res, [NFS4_OK, NFS4ERR_NOTSUPP]) if (res.status == NFS4ERR_NOTSUPP): @@ -354,3 +372,46 @@ def testDirDelegFiltering(t, env): if not cb.got_recall: fail("Expected CB_RECALL for unrequested notification type") + +def testDirDelegRemove(t, env): + """Create a dir_deleg that accepts notification of REMOVE events + + FLAGS: dirdeleg all + CODE: DIRDELEG9 + """ + c = env.c1 + cb = threading.Event() + sess1, fh, deleg = _getDirDeleg(t, env, + [NOTIFY4_CHANGE_DIR_ATTRS, + NOTIFY4_REMOVE_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)) + remove_op = [ op.putfh(fh), op.remove(env.testname(t)) ] + res = sess2.compound(remove_op) + check(res) + + completed = cb.wait(5) + ops = [ op.putfh(fh), op.delegreturn(deleg) ] + res = sess1.compound(ops) + + 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_REMOVE_ENTRY: + 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") -- 2.54.0