]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
store_test: add a TryMoveRename test
authorSamuel Just <sjust@redhat.com>
Fri, 18 Mar 2016 18:22:00 +0000 (11:22 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 29 Mar 2016 18:13:52 +0000 (11:13 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/test/objectstore/store_test.cc

index e1f01cdbf782ce144229721316541d99d6ac4744..79c6b3f51f267ec86554c14b88aca6557349fc6c 100644 (file)
@@ -3441,6 +3441,41 @@ TEST_P(StoreTest, SetAllocHint) {
   }
 }
 
+TEST_P(StoreTest, TryMoveRename) {
+  ObjectStore::Sequencer osr("test");
+  coll_t cid;
+  ghobject_t hoid(hobject_t("test_hint", "", CEPH_NOSNAP, 0, 0, ""));
+  ghobject_t hoid2(hobject_t("test_hint2", "", CEPH_NOSNAP, 0, 0, ""));
+  int r;
+  {
+    ObjectStore::Transaction t;
+    t.create_collection(cid, 0);
+    r = store->apply_transaction(&osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.try_rename(cid, hoid, hoid2);
+    r = store->apply_transaction(&osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.touch(cid, hoid);
+    r = store->apply_transaction(&osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  {
+    ObjectStore::Transaction t;
+    t.try_rename(cid, hoid, hoid2);
+    r = store->apply_transaction(&osr, std::move(t));
+    ASSERT_EQ(r, 0);
+  }
+  struct stat st;
+  ASSERT_EQ(store->stat(cid, hoid, &st), -2);
+  ASSERT_EQ(store->stat(cid, hoid2, &st), 0);
+}
+
 INSTANTIATE_TEST_CASE_P(
   ObjectStore,
   StoreTest,