From: Sage Weil Date: Mon, 8 Sep 2014 20:45:52 +0000 (-0700) Subject: ceph_test_rados_api_io: add read timeout test X-Git-Tag: v0.86~108^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f295c1fee4afb9447cdf46f05a44234274d23b6c;p=ceph.git ceph_test_rados_api_io: add read timeout test Verify we don't receive data after a timeout. Based on reproducer for #9362 written by Matthias Kiefer . Signed-off-by: Sage Weil --- diff --git a/src/test/librados/io.cc b/src/test/librados/io.cc index ede81a326f5b..0cfa91e4b846 100644 --- a/src/test/librados/io.cc +++ b/src/test/librados/io.cc @@ -25,6 +25,58 @@ TEST_F(LibRadosIo, SimpleWrite) { ASSERT_EQ(0, rados_write(ioctx, "foo", buf, sizeof(buf), 0)); } +TEST_F(LibRadosIo, ReadTimeout) { + char buf[128]; + memset(buf, 'a', sizeof(buf)); + ASSERT_EQ(0, rados_write(ioctx, "foo", buf, sizeof(buf), 0)); + + { + // set up a second client + rados_t cluster; + rados_ioctx_t ioctx; + rados_create(&cluster, "admin"); + rados_conf_read_file(cluster, NULL); + rados_conf_parse_env(cluster, NULL); + rados_conf_set(cluster, "rados_osd_op_timeout", "0.00001"); // use any small value that will result in a timeout + rados_connect(cluster); + rados_ioctx_create(cluster, pool_name.c_str(), &ioctx); + rados_ioctx_set_namespace(ioctx, nspace.c_str()); + + // then we show that the buffer is changed after rados_read returned + // with a timeout + for (int i=0; i<5; i++) { + char buf2[sizeof(buf)]; + memset(buf2, 0, sizeof(buf2)); + int err = rados_read(ioctx, "foo", buf2, sizeof(buf2), 0); + if (err == -110) { + int startIndex = 0; + // find the index until which librados already read the object before the timeout occurred + for (unsigned b=0; b