Skip to content

Commit 2520927

Browse files
committed
test/crimson/seastore: add the test case for renaming objects
Signed-off-by: Xuehan Xu <[email protected]>
1 parent 70245c5 commit 2520927

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/crimson/seastore/test_seastore.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,19 @@ struct seastore_test_t :
262262
return clone_obj;
263263
}
264264

265+
void rename(
266+
SeaStoreShard &sharded_seastore,
267+
object_state_t &other) {
268+
CTransaction t;
269+
t.collection_move_rename(cid, oid, cid, other.oid);
270+
sharded_seastore.do_transaction(
271+
coll,
272+
std::move(t)).get0();
273+
other.contents = contents;
274+
other.omap = omap;
275+
other.clone_contents = clone_contents;
276+
}
277+
265278
void write(
266279
SeaStoreShard &sharded_seastore,
267280
uint64_t offset,
@@ -787,6 +800,25 @@ TEST_P(seastore_test_t, omap_test_simple)
787800
});
788801
}
789802

803+
TEST_P(seastore_test_t, rename)
804+
{
805+
run_async([this] {
806+
auto &test_obj = get_object(make_oid(0));
807+
test_obj.write(*sharded_seastore, 0, 4096, 'a');
808+
test_obj.set_omap(
809+
*sharded_seastore,
810+
"asdf",
811+
make_bufferlist(128));
812+
auto test_other = object_state_t{
813+
test_obj.cid,
814+
test_obj.coll,
815+
ghobject_t(hobject_t(sobject_t(std::string("object_1"), CEPH_NOSNAP)))};
816+
test_obj.rename(*sharded_seastore, test_other);
817+
test_other.read(*sharded_seastore, 0, 4096);
818+
test_other.check_omap(*sharded_seastore);
819+
});
820+
}
821+
790822
TEST_P(seastore_test_t, clone_aligned_extents)
791823
{
792824
run_async([this] {

0 commit comments

Comments
 (0)