summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-07-23 17:34:25 -0700
committerSamuel Just <sam.just@inktank.com>2013-07-25 10:37:22 -0700
commit8f73302b4e637ca8b85d68ea7503279faecb57d8 (patch)
tree5d32a64af0a13a87c3a7d7efbd49169b3db88e8b
parent6a7b9e5f0c1d2344209c69ab9992f94221a16468 (diff)
downloadceph-8f73302b4e637ca8b85d68ea7503279faecb57d8.tar.gz
test/filestore/store_test: add test for 5723
Signed-off-by: Samuel Just <sam.just@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com> (cherry picked from commit 37a4c4af54879512429bb114285bcb4c7c3488d5) Conflicts: src/os/LFNIndex.cc src/test/filestore/store_test.cc
-rw-r--r--src/os/LFNIndex.cc11
-rw-r--r--src/test/filestore/store_test.cc71
2 files changed, 77 insertions, 5 deletions
diff --git a/src/os/LFNIndex.cc b/src/os/LFNIndex.cc
index 12aabfd8fd1..92b30ceae58 100644
--- a/src/os/LFNIndex.cc
+++ b/src/os/LFNIndex.cc
@@ -71,16 +71,19 @@ int LFNIndex::init() {
}
int LFNIndex::created(const hobject_t &hoid, const char *path) {
+ WRAP_RETRY(
vector<string> path_comp;
string short_name;
- int r;
r = decompose_full_path(path, &path_comp, 0, &short_name);
if (r < 0)
- return r;
+ goto out;
r = lfn_created(path_comp, hoid, short_name);
if (r < 0)
- return r;
- return _created(path_comp, hoid, short_name);
+ goto out;
+ r = _created(path_comp, hoid, short_name);
+ if (r < 0)
+ goto out;
+ );
}
int LFNIndex::unlink(const hobject_t &hoid) {
diff --git a/src/test/filestore/store_test.cc b/src/test/filestore/store_test.cc
index c98ffb047ac..c0b009bb95c 100644
--- a/src/test/filestore/store_test.cc
+++ b/src/test/filestore/store_test.cc
@@ -823,6 +823,75 @@ TEST_F(StoreTest, ColSplitTest3) {
}
#endif
+/**
+ * This test tests adding two different groups
+ * of objects, each with 1 common prefix and 1
+ * different prefix. We then remove half
+ * in order to verify that the merging correctly
+ * stops at the common prefix subdir. See bug
+ * #5273 */
+TEST_F(StoreTest, TwoHash) {
+ coll_t cid("asdf");
+ int r;
+ {
+ ObjectStore::Transaction t;
+ t.create_collection(cid);
+ r = store->apply_transaction(t);
+ ASSERT_EQ(r, 0);
+ }
+ std::cout << "Making objects" << std::endl;
+ for (int i = 0; i < 360; ++i) {
+ ObjectStore::Transaction t;
+ hobject_t o;
+ if (i < 8) {
+ o.hash = (i << 16) | 0xA1;
+ t.touch(cid, o);
+ }
+ o.hash = (i << 16) | 0xB1;
+ t.touch(cid, o);
+ r = store->apply_transaction(t);
+ ASSERT_EQ(r, 0);
+ }
+ std::cout << "Removing half" << std::endl;
+ for (int i = 1; i < 8; ++i) {
+ ObjectStore::Transaction t;
+ hobject_t o;
+ o.hash = (i << 16) | 0xA1;
+ t.remove(cid, o);
+ r = store->apply_transaction(t);
+ ASSERT_EQ(r, 0);
+ }
+ std::cout << "Checking" << std::endl;
+ for (int i = 1; i < 8; ++i) {
+ ObjectStore::Transaction t;
+ hobject_t o;
+ o.hash = (i << 16) | 0xA1;
+ bool exists = store->exists(cid, o);
+ ASSERT_EQ(exists, false);
+ }
+ {
+ hobject_t o;
+ o.hash = 0xA1;
+ bool exists = store->exists(cid, o);
+ ASSERT_EQ(exists, true);
+ }
+ std::cout << "Cleanup" << std::endl;
+ for (int i = 0; i < 360; ++i) {
+ ObjectStore::Transaction t;
+ hobject_t o;
+ o.hash = (i << 16) | 0xA1;
+ t.remove(cid, o);
+ o.hash = (i << 16) | 0xB1;
+ t.remove(cid, o);
+ r = store->apply_transaction(t);
+ ASSERT_EQ(r, 0);
+ }
+ ObjectStore::Transaction t;
+ t.remove_collection(cid);
+ r = store->apply_transaction(t);
+ ASSERT_EQ(r, 0);
+}
+
int main(int argc, char **argv) {
vector<const char*> args;
argv_to_vec(argc, (const char **)argv, args);
@@ -830,7 +899,7 @@ int main(int argc, char **argv) {
global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
common_init_finish(g_ceph_context);
g_ceph_context->_conf->set_val("osd_journal_size", "400");
- g_ceph_context->_conf->set_val("filestore_index_retry_probability", "1");
+ g_ceph_context->_conf->set_val("filestore_index_retry_probability", "0.5");
g_ceph_context->_conf->set_val("filestore_op_thread_timeout", "1000");
g_ceph_context->_conf->set_val("filestore_op_thread_suicide_timeout", "10000");
g_ceph_context->_conf->apply_changes(NULL);