From: Samuel Just Date: Thu, 10 Mar 2016 19:03:13 +0000 (-0800) Subject: store_test: add reproducer for #14766 X-Git-Tag: v0.94.8~51^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f500435da3ddf750cf0770c0f63e9cff0cebd7a7;p=ceph.git store_test: add reproducer for #14766 Signed-off-by: Samuel Just (cherry picked from commit 0fb67c772561aaca9261ac9094b74d7524498f6f) Conflicts: src/test/objectstore/store_test.cc --- diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index d3ce80ce0abc..5f6b7a35c794 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -342,6 +342,65 @@ TEST_P(StoreTest, SimpleObjectLongnameTest) { } } +ghobject_t generate_long_name(unsigned i) +{ + stringstream name; + name << "object id " << i << " "; + for (unsigned j = 0; j < 500; ++j) name << 'a'; + ghobject_t hoid(hobject_t(sobject_t(name.str(), CEPH_NOSNAP))); + hoid.hobj.set_hash(i % 2); + return hoid; +} + +TEST_P(StoreTest, LongnameSplitTest) { + ObjectStore::Sequencer osr("test"); + int r; + coll_t cid; + { + ObjectStore::Transaction t; + t.create_collection(cid); + cerr << "Creating collection " << cid << std::endl; + r = store->apply_transaction(&osr, t); + ASSERT_EQ(r, 0); + } + for (unsigned i = 0; i < 320; ++i) { + ObjectStore::Transaction t; + ghobject_t hoid = generate_long_name(i); + t.touch(cid, hoid); + cerr << "Creating object " << hoid << std::endl; + r = store->apply_transaction(&osr, t); + } + + ghobject_t test_obj = generate_long_name(319); + ghobject_t test_obj_2 = test_obj; + test_obj_2.generation = 0; + { + ObjectStore::Transaction t; + // should cause a split + t.collection_move_rename( + cid, test_obj, + cid, test_obj_2); + r = store->apply_transaction(&osr, t); + } + + for (unsigned i = 0; i < 319; ++i) { + ObjectStore::Transaction t; + ghobject_t hoid = generate_long_name(i); + t.remove(cid, hoid); + cerr << "Removing object " << hoid << std::endl; + r = store->apply_transaction(&osr, t); + } + { + ObjectStore::Transaction t; + t.remove(cid, test_obj_2); + t.remove_collection(cid); + cerr << "Cleaning" << std::endl; + r = store->apply_transaction(&osr, t); + ASSERT_EQ(r, 0); + } + +} + TEST_P(StoreTest, ManyObjectTest) { int NUM_OBJS = 2000; int r = 0;