From: Sage Weil Date: Sat, 29 Jun 2013 00:45:21 +0000 (-0700) Subject: librados: add test for large and many xattrs X-Git-Tag: v0.67-rc1~165^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1b578a804beda391dfde25e0e828fc99785f8487;p=ceph.git librados: add test for large and many xattrs Verify that we can set large and large numbers of attrs on an object. Signed-off-by: Sage Weil --- diff --git a/src/Makefile.am b/src/Makefile.am index 3f8369bfeda..4393fc9180b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1025,7 +1025,7 @@ bin_DEBUGPROGRAMS += ceph_test_rados_api_cls ceph_test_rados_api_misc_SOURCES = test/librados/misc.cc test/librados/test.cc ceph_test_rados_api_misc_LDFLAGS = ${AM_LDFLAGS} -ceph_test_rados_api_misc_LDADD = librados.la ${UNITTEST_STATIC_LDADD} +ceph_test_rados_api_misc_LDADD = librados.la $(LIBGLOBAL_LDA) ${UNITTEST_STATIC_LDADD} ceph_test_rados_api_misc_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS} bin_DEBUGPROGRAMS += ceph_test_rados_api_misc diff --git a/src/test/librados/misc.cc b/src/test/librados/misc.cc index c4bc465fa4a..852f3338c5c 100644 --- a/src/test/librados/misc.cc +++ b/src/test/librados/misc.cc @@ -1,11 +1,17 @@ +#include "gtest/gtest.h" + #include "mds/mdstypes.h" #include "include/buffer.h" #include "include/rbd_types.h" #include "include/rados/librados.h" #include "include/rados/librados.hpp" +#include "include/stringify.h" +#include "global/global_context.h" +#include "global/global_init.h" +#include "common/ceph_argparse.h" +#include "common/common_init.h" #include "test/librados/test.h" -#include "gtest/gtest.h" #include #include #include @@ -512,3 +518,57 @@ TEST(LibRadosMisc, AssertExistsPP) { ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster)); } +TEST(LibRadosMisc, BigAttrPP) { + Rados cluster; + std::string pool_name = get_temp_pool_name(); + ASSERT_EQ("", create_one_pool_pp(pool_name, cluster)); + IoCtx ioctx; + ASSERT_EQ(0, cluster.ioctx_create(pool_name.c_str(), ioctx)); + + char buf[64]; + memset(buf, 0xcc, sizeof(buf)); + bufferlist bl; + bl.append(buf, sizeof(buf)); + + ASSERT_EQ(0, ioctx.create("foo", true)); + + bufferlist got; + + bl.clear(); + got.clear(); + bl.append(buffer::create(g_conf->osd_max_attr_size)); + ASSERT_EQ(0, ioctx.setxattr("foo", "one", bl)); + ASSERT_EQ((int)bl.length(), ioctx.getxattr("foo", "one", got)); + ASSERT_TRUE(bl.contents_equal(got)); + + bl.clear(); + bl.append(buffer::create(g_conf->osd_max_attr_size+1)); + ASSERT_EQ(-EFBIG, ioctx.setxattr("foo", "one", bl)); + + for (int i=0; i<1000; i++) { + bl.clear(); + got.clear(); + bl.append(buffer::create(g_conf->osd_max_attr_size)); + char n[10]; + snprintf(n, sizeof(n), "a%d", i); + ASSERT_EQ(0, ioctx.setxattr("foo", n, bl)); + ASSERT_EQ((int)bl.length(), ioctx.getxattr("foo", n, got)); + ASSERT_TRUE(bl.contents_equal(got)); + } + + ioctx.close(); + ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster)); +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + + vector args; + argv_to_vec(argc, (const char **)argv, args); + + global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); + common_init_finish(g_ceph_context); + + return RUN_ALL_TESTS(); +}