From: David Zafman Date: Fri, 30 Aug 2013 23:17:16 +0000 (-0700) Subject: unittest_lfnindex testing older HASH_INDEX_TAG X-Git-Tag: v0.69~28 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ec0b4fb780b91b44427ed94eee82c3c6b6fff9f;p=ceph.git unittest_lfnindex testing older HASH_INDEX_TAG Switch to work with new HOBJECT_WITH_POOL fixes: #6196 Signed-off-by: David Zafman Reviewed-by: Samuel Just --- diff --git a/src/test/os/TestLFNIndex.cc b/src/test/os/TestLFNIndex.cc index 33dbfe532a9c..3947329d9957 100644 --- a/src/test/os/TestLFNIndex.cc +++ b/src/test/os/TestLFNIndex.cc @@ -162,7 +162,7 @@ TEST_F(TestHOBJECT_WITH_POOL, generate_and_parse_name) { class TestLFNIndex : public TestWrapLFNIndex, public ::testing::Test { public: - TestLFNIndex() : TestWrapLFNIndex(coll_t("ABC"), "PATH", CollectionIndex::HASH_INDEX_TAG) { + TestLFNIndex() : TestWrapLFNIndex(coll_t("ABC"), "PATH", CollectionIndex::HOBJECT_WITH_POOL) { } virtual void SetUp() { @@ -237,7 +237,12 @@ TEST_F(TestLFNIndex, remove_object) { std::string pathname("PATH/" + mangled_name); EXPECT_EQ(0, ::close(::creat(pathname.c_str(), 0600))); EXPECT_EQ(0, created(hoid, pathname.c_str())); - const string LFN_ATTR = "user.cephos.lfn"; + string LFN_ATTR = "user.cephos.lfn"; + if (index_version != HASH_INDEX_TAG) { + char buf[100]; + snprintf(buf, sizeof(buf), "%d", index_version); + LFN_ATTR += string(buf); + } const std::string object_name_1 = object_name + "SUFFIX"; EXPECT_EQ(object_name_1.size(), (unsigned)chain_setxattr(pathname.c_str(), LFN_ATTR.c_str(), object_name_1.c_str(), object_name_1.size())); @@ -321,13 +326,13 @@ TEST_F(TestLFNIndex, get_mangled_name) { hobject_t hoid(sobject_t("ABC", CEPH_NOSNAP)); EXPECT_EQ(0, get_mangled_name(path, hoid, &mangled_name, &exists)); - EXPECT_NE(std::string::npos, mangled_name.find("ABC_head")); + EXPECT_NE(std::string::npos, mangled_name.find("ABC__head")); EXPECT_EQ(std::string::npos, mangled_name.find("0_long")); EXPECT_EQ(0, exists); const std::string pathname("PATH/" + mangled_name); EXPECT_EQ(0, ::close(::creat(pathname.c_str(), 0600))); EXPECT_EQ(0, get_mangled_name(path, hoid, &mangled_name, &exists)); - EXPECT_NE(std::string::npos, mangled_name.find("ABC_head")); + EXPECT_NE(std::string::npos, mangled_name.find("ABC__head")); EXPECT_EQ(1, exists); EXPECT_EQ(0, ::unlink(pathname.c_str())); } @@ -399,7 +404,12 @@ TEST_F(TestLFNIndex, get_mangled_name) { // are not identical and it so happens that their SHA1 is // identical : a collision number is used to differentiate them // - const string LFN_ATTR = "user.cephos.lfn"; + string LFN_ATTR = "user.cephos.lfn"; + if (index_version != HASH_INDEX_TAG) { + char buf[100]; + snprintf(buf, sizeof(buf), "%d", index_version); + LFN_ATTR += string(buf); + } const std::string object_name_same_prefix = object_name + "SUFFIX"; EXPECT_EQ(object_name_same_prefix.size(), (unsigned)chain_setxattr(pathname.c_str(), LFN_ATTR.c_str(), object_name_same_prefix.c_str(), object_name_same_prefix.size())); std::string mangled_name_same_prefix;