From 04eb30a51aa5e9983aeeb415cf6beb946b415286 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Mon, 9 Jan 2023 03:07:09 +0000 Subject: [PATCH] test/crimson/seastore: add the test case for overwriting big oi/ss with small ones Signed-off-by: Xuehan Xu --- src/test/crimson/seastore/test_seastore.cc | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/test/crimson/seastore/test_seastore.cc b/src/test/crimson/seastore/test_seastore.cc index 3a507f4b0f5..699cd283e5f 100644 --- a/src/test/crimson/seastore/test_seastore.cc +++ b/src/test/crimson/seastore/test_seastore.cc @@ -894,6 +894,43 @@ TEST_P(seastore_test_t, attr) EXPECT_EQ(attrs.find(SS_ATTR), attrs.end()); EXPECT_EQ(attrs.find("test_key"), attrs.end()); } + { + // create OI_ATTR with len > onode_layout_t::MAX_OI_LENGTH, then + // overwrite it with another OI_ATTR len of which < onode_layout_t::MAX_OI_LENGTH + // create SS_ATTR with len > onode_layout_t::MAX_SS_LENGTH, then + // overwrite it with another SS_ATTR len of which < onode_layout_t::MAX_SS_LENGTH + char oi_array[onode_layout_t::MAX_OI_LENGTH + 1] = {'a'}; + std::string oi(&oi_array[0], sizeof(oi_array)); + bufferlist bl; + encode(oi, bl); + test_obj.set_attr(*seastore, OI_ATTR, bl); + + oi = "asdfasdfasdf"; + bl.clear(); + encode(oi, bl); + test_obj.set_attr(*seastore, OI_ATTR, bl); + + char ss_array[onode_layout_t::MAX_SS_LENGTH + 1] = {'b'}; + std::string ss(&ss_array[0], sizeof(ss_array)); + bl.clear(); + encode(ss, bl); + test_obj.set_attr(*seastore, SS_ATTR, bl); + + ss = "f"; + bl.clear(); + encode(ss, bl); + test_obj.set_attr(*seastore, SS_ATTR, bl); + + auto attrs = test_obj.get_attrs(*seastore); + std::string oi2, ss2; + bufferlist bl2 = attrs[OI_ATTR]; + decode(oi2, bl2); + bl2.clear(); + bl2 = attrs[SS_ATTR]; + decode(ss2, bl2); + EXPECT_EQ(oi, oi2); + EXPECT_EQ(ss, ss2); + } }); } -- 2.47.3