]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crimson/seastore: add the test case for renaming objects 55947/head
authorXuehan Xu <xuxuehan@qianxin.com>
Thu, 7 Mar 2024 09:06:13 +0000 (17:06 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Mon, 11 Mar 2024 08:59:39 +0000 (16:59 +0800)
Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/test/crimson/seastore/test_seastore.cc

index 1e0028b97acac0348adfbbfb44fb9cb3e54d6d60..a252cbfd57820c0841236a116639c10af42fb3d6 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] {