diff options
author | Matt Benjamin <mbenjamin@redhat.com> | 2015-10-29 19:58:47 +0100 |
---|---|---|
committer | Matt Benjamin <mbenjamin@redhat.com> | 2016-02-12 18:05:26 +0100 |
commit | 540ce769ceaa860c8d4ff24f4fd2f5adc1ca2abc (patch) | |
tree | e3cac0be2c5ca67112ab640597a53ea1176bd5bc /src/test/librgw_file_gp.cc | |
parent | librgw: remove junk prints (diff) | |
download | ceph-540ce769ceaa860c8d4ff24f4fd2f5adc1ca2abc.tar.xz ceph-540ce769ceaa860c8d4ff24f4fd2f5adc1ca2abc.zip |
librgw: improve rgw_write and add WRITE_READ_VERIFY
Update rgw_write to return bytes written as an OUT argument,
use and verify in PUT test.
A new WRITE_READ_VERIFY test writes 16 checksummed, 64K data pages
to the object when --bulk specified. The returned write value is
checked, but pages not re-read (yet).
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
Diffstat (limited to 'src/test/librgw_file_gp.cc')
-rw-r--r-- | src/test/librgw_file_gp.cc | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/test/librgw_file_gp.cc b/src/test/librgw_file_gp.cc index bc3d8058d75..4b9fa9b28cf 100644 --- a/src/test/librgw_file_gp.cc +++ b/src/test/librgw_file_gp.cc @@ -39,6 +39,7 @@ namespace { bool do_pre_list = false; bool do_put = false; + bool do_bulk = false; bool do_get = false; bool do_delete = false; @@ -116,7 +117,7 @@ namespace { } ~ZPageSet() { - for (int ix = 0; ix < pages.size(); ++ix) + for (unsigned int ix = 0; ix < pages.size(); ++ix) delete pages[ix]; free(iovs); } @@ -175,7 +176,7 @@ TEST(LibRGW, LIST_OBJECTS) { } TEST(LibRGW, LOOKUP_OBJECT) { - if (do_get || do_put) { + if (do_get || do_put || do_bulk) { int ret = rgw_lookup(fs, bucket_fh, object_name.c_str(), &object_fh, 0 /* flags */); ASSERT_EQ(ret, 0); @@ -191,9 +192,12 @@ TEST(LibRGW, OBJ_OPEN) { TEST(LibRGW, PUT_OBJECT) { if (do_put) { + size_t nbytes; string data = "hi mom"; // fix this - int ret = rgw_write(fs, object_fh, 0, data.length(), (void*) data.c_str()); + int ret = rgw_write(fs, object_fh, 0, data.length(), &nbytes, + (void*) data.c_str()); ASSERT_EQ(ret, 0); + ASSERT_EQ(nbytes, data.length()); } } @@ -210,6 +214,25 @@ TEST(LibRGW, GET_OBJECT) { } } +TEST(LibRGW, WRITE_READ_VERIFY) +{ + if (do_bulk) { + const int iovcnt = 16; + ZPageSet zp_set1{iovcnt}; // 1M random data in 16 64K pages + struct iovec *iovs = zp_set1.get_iovs(); + + /* read after write POSIX-style */ + size_t nbytes, off = 0; + for (int ix = 0; ix < 16; ++ix, off += 65536) { + struct iovec *iov = &iovs[ix]; + int ret = rgw_write(fs, object_fh, off, 65536, &nbytes, iov->iov_base); + ASSERT_EQ(ret, 0); + ASSERT_EQ(nbytes, size_t(65536)); + } + zp_set1.reset_iovs(); + } +} + TEST(LibRGW, DELETE_OBJECT) { if (do_delete) { int ret = rgw_unlink(fs, bucket_fh, object_name.c_str()); @@ -276,6 +299,9 @@ int main(int argc, char *argv[]) } else if (ceph_argparse_flag(args, arg_iter, "--put", (char*) nullptr)) { do_put = true; + } else if (ceph_argparse_flag(args, arg_iter, "--bulk", + (char*) nullptr)) { + do_bulk = true; } else if (ceph_argparse_flag(args, arg_iter, "--delete", (char*) nullptr)) { do_delete = true; |