]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crimson/seastore: add the test case for renaming objects 57481/head
authorXuehan Xu <xuxuehan@qianxin.com>
Thu, 7 Mar 2024 09:06:13 +0000 (17:06 +0800)
committerMatan Breizman <mbreizma@redhat.com>
Wed, 15 May 2024 14:57:15 +0000 (17:57 +0300)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
(cherry picked from commit 2520927590ac48783cb35feb570285ec066964a4)

src/test/crimson/seastore/test_seastore.cc

index d3a21261e27ab27494a6e0e95d15263c18c79f28..4d671cebd5b81a34d2242af2cf50573871648cd6 100644 (file)
@@ -262,6 +262,19 @@ struct seastore_test_t :
       return clone_obj;
     }
 
+    void rename(
+      SeaStoreShard &sharded_seastore,
+      object_state_t &other) {
+      CTransaction t;
+      t.collection_move_rename(cid, oid, cid, other.oid);
+      sharded_seastore.do_transaction(
+       coll,
+       std::move(t)).get0();
+      other.contents = contents;
+      other.omap = omap;
+      other.clone_contents = clone_contents;
+    }
+
     void write(
       SeaStoreShard &sharded_seastore,
       uint64_t offset,
@@ -787,6 +800,25 @@ TEST_P(seastore_test_t, omap_test_simple)
   });
 }
 
+TEST_P(seastore_test_t, rename)
+{
+  run_async([this] {
+    auto &test_obj = get_object(make_oid(0));
+    test_obj.write(*sharded_seastore, 0, 4096, 'a');
+    test_obj.set_omap(
+      *sharded_seastore,
+      "asdf",
+      make_bufferlist(128));
+    auto test_other = object_state_t{
+      test_obj.cid, 
+      test_obj.coll,
+      ghobject_t(hobject_t(sobject_t(std::string("object_1"), CEPH_NOSNAP)))};
+    test_obj.rename(*sharded_seastore, test_other);
+    test_other.read(*sharded_seastore, 0, 4096);
+    test_other.check_omap(*sharded_seastore);
+  });
+}
+
 TEST_P(seastore_test_t, clone_aligned_extents)
 {
   run_async([this] {