[PATCH pynfs 03/13] server41tests: test async COPY with OFFLOAD_STATUS polling
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Add _poll_offload_status() helper that polls OFFLOAD_STATUS in a loop until the copy completes or a timeout is reached. Add testAsyncCopy (COPY3) which writes 1MB to a source file, requests an asynchronous copy (ca_synchronous=0), polls OFFLOAD_STATUS until completion, and verifies the destination file contents. If the server chooses to perform the copy synchronously, the test still verifies the result. Signed-off-by: Jeff Layton <[email protected]> --- nfs4.1/server41tests/st_copy.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/nfs4.1/server41tests/st_copy.py b/nfs4.1/server41tests/st_copy.py index bfc64bbe1584..8c320173db1f 100644 --- a/nfs4.1/server41tests/st_copy.py +++ b/nfs4.1/server41tests/st_copy.py @@ -122,6 +122,39 @@ def testCopyWithOffset(t, env): if res.data != b"B" * 4096: fail("Destination data at offset 512 does not match expected content") +def testAsyncCopy(t, env): + """request async copy, poll OFFLOAD_STATUS, verify data + + FLAGS: copy + CODE: COPY3 + """ + sess = env.c1.new_client_session(env.testname(t)) + src_fh, src_stateid = _create_and_open(sess, env.testname(t)) + data = b"C" * (1024 * 1024) + _write_data(sess, src_fh, src_stateid, data) + + dst_fh, dst_stateid = _create_and_open(sess, env.testname(t) + b"_dst") + + res = _do_copy(sess, src_fh, src_stateid, dst_fh, dst_stateid, + count=len(data), synchronous=0) + check(res) + cr = res.resarray[-1] + + if not cr.cr_resok4.cr_requirements.cr_synchronous: + copy_stateid = cr.cr_response.wr_callback_id[0] + status = _poll_offload_status(sess, dst_fh, copy_stateid) + if status.osr_complete[0] != NFS4_OK: + fail("Async copy completed with error: %d" % status.osr_complete[0]) + if status.osr_count != len(data): + fail("Expected %d bytes copied, got %d" % + (len(data), status.osr_count)) + else: + if cr.cr_response.wr_count != len(data): + fail("Sync copy returned %d bytes, expected %d" % + (cr.cr_response.wr_count, len(data))) + + _verify_data(sess, dst_fh, dst_stateid, data) + def testZeroLengthCopy(t, env): """test that zero-length copy copies to EOF -- 2.55.0