mirror of
https://github.com/ceph/ceph
synced 2025-04-01 00:26:47 +00:00
crimson/os: fix unittest error for multicore seastore
Signed-off-by: chunmei <chunmei.liu@intel.com>
This commit is contained in:
parent
ad4f7bbf15
commit
91572c1799
@ -70,15 +70,15 @@ struct fltree_onode_manager_test_t
|
||||
return tm_teardown();
|
||||
}
|
||||
|
||||
|
||||
virtual void _init() final {
|
||||
TMTestState::_init();
|
||||
manager.reset(new FLTreeOnodeManager(*tm));
|
||||
virtual seastar::future<> _init() final {
|
||||
return TMTestState::_init().then([this] {
|
||||
manager.reset(new FLTreeOnodeManager(*tm));
|
||||
});
|
||||
}
|
||||
|
||||
virtual void _destroy() final {
|
||||
virtual seastar::future<> _destroy() final {
|
||||
manager.reset();
|
||||
TMTestState::_destroy();
|
||||
return TMTestState::_destroy();
|
||||
}
|
||||
|
||||
virtual FuturizedStore::mkfs_ertr::future<> _mkfs() final {
|
||||
|
@ -16,6 +16,7 @@
|
||||
using namespace crimson;
|
||||
using namespace crimson::os;
|
||||
using namespace crimson::os::seastore;
|
||||
using SeaStoreShard = FuturizedStore::Shard;
|
||||
using CTransaction = ceph::os::Transaction;
|
||||
using namespace std;
|
||||
|
||||
@ -75,12 +76,12 @@ struct seastore_test_t :
|
||||
}
|
||||
return tm_setup(journal
|
||||
).then([this] {
|
||||
return seastore->create_new_collection(coll_name);
|
||||
return sharded_seastore->create_new_collection(coll_name);
|
||||
}).then([this](auto coll_ref) {
|
||||
coll = coll_ref;
|
||||
CTransaction t;
|
||||
t.create_collection(coll_name, 0);
|
||||
return seastore->do_transaction(
|
||||
return sharded_seastore->do_transaction(
|
||||
coll,
|
||||
std::move(t));
|
||||
});
|
||||
@ -92,7 +93,7 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void do_transaction(CTransaction &&t) {
|
||||
return seastore->do_transaction(
|
||||
return sharded_seastore->do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
@ -122,10 +123,10 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void touch(
|
||||
SeaStore &seastore) {
|
||||
SeaStoreShard &sharded_seastore) {
|
||||
CTransaction t;
|
||||
touch(t);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
@ -137,26 +138,26 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void truncate(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
uint64_t off) {
|
||||
CTransaction t;
|
||||
truncate(t, off);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
|
||||
std::map<uint64_t, uint64_t> fiemap(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
uint64_t off,
|
||||
uint64_t len) {
|
||||
return seastore.fiemap(coll, oid, off, len).unsafe_get0();
|
||||
return sharded_seastore.fiemap(coll, oid, off, len).unsafe_get0();
|
||||
}
|
||||
|
||||
bufferlist readv(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
interval_set<uint64_t>&m) {
|
||||
return seastore.readv(coll, oid, m).unsafe_get0();
|
||||
return sharded_seastore.readv(coll, oid, m).unsafe_get0();
|
||||
}
|
||||
|
||||
void remove(
|
||||
@ -166,10 +167,10 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void remove(
|
||||
SeaStore &seastore) {
|
||||
SeaStoreShard &sharded_seastore) {
|
||||
CTransaction t;
|
||||
remove(t);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
@ -188,18 +189,18 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void set_omap(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
const string &key,
|
||||
const bufferlist &val) {
|
||||
CTransaction t;
|
||||
set_omap(t, key, val);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
|
||||
void write(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
CTransaction &t,
|
||||
uint64_t offset,
|
||||
bufferlist bl) {
|
||||
@ -234,17 +235,17 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void write(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
uint64_t offset,
|
||||
bufferlist bl) {
|
||||
CTransaction t;
|
||||
write(seastore, t, offset, bl);
|
||||
seastore.do_transaction(
|
||||
write(sharded_seastore, t, offset, bl);
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
void write(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
uint64_t offset,
|
||||
size_t len,
|
||||
char fill) {
|
||||
@ -252,11 +253,11 @@ struct seastore_test_t :
|
||||
::memset(buffer.c_str(), fill, len);
|
||||
bufferlist bl;
|
||||
bl.append(buffer);
|
||||
write(seastore, offset, bl);
|
||||
write(sharded_seastore, offset, bl);
|
||||
}
|
||||
|
||||
void zero(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
CTransaction &t,
|
||||
uint64_t offset,
|
||||
size_t len) {
|
||||
@ -292,18 +293,18 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
void zero(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
uint64_t offset,
|
||||
size_t len) {
|
||||
CTransaction t;
|
||||
zero(seastore, t, offset, len);
|
||||
seastore.do_transaction(
|
||||
zero(sharded_seastore, t, offset, len);
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
|
||||
void read(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
uint64_t offset,
|
||||
uint64_t len) {
|
||||
bufferlist to_check;
|
||||
@ -311,7 +312,7 @@ struct seastore_test_t :
|
||||
contents,
|
||||
offset,
|
||||
len);
|
||||
auto ret = seastore.read(
|
||||
auto ret = sharded_seastore.read(
|
||||
coll,
|
||||
oid,
|
||||
offset,
|
||||
@ -320,65 +321,65 @@ struct seastore_test_t :
|
||||
EXPECT_EQ(ret, to_check);
|
||||
}
|
||||
|
||||
void check_size(SeaStore &seastore) {
|
||||
auto st = seastore.stat(
|
||||
void check_size(SeaStoreShard &sharded_seastore) {
|
||||
auto st = sharded_seastore.stat(
|
||||
coll,
|
||||
oid).get0();
|
||||
EXPECT_EQ(contents.length(), st.st_size);
|
||||
}
|
||||
|
||||
void set_attr(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
std::string key,
|
||||
bufferlist& val) {
|
||||
CTransaction t;
|
||||
t.setattr(cid, oid, key, val);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
|
||||
void rm_attr(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
std::string key) {
|
||||
CTransaction t;
|
||||
t.rmattr(cid, oid, key);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
|
||||
void rm_attrs(
|
||||
SeaStore &seastore) {
|
||||
SeaStoreShard &sharded_seastore) {
|
||||
CTransaction t;
|
||||
t.rmattrs(cid, oid);
|
||||
seastore.do_transaction(
|
||||
sharded_seastore.do_transaction(
|
||||
coll,
|
||||
std::move(t)).get0();
|
||||
}
|
||||
|
||||
SeaStore::attrs_t get_attrs(
|
||||
SeaStore &seastore) {
|
||||
return seastore.get_attrs(coll, oid)
|
||||
.handle_error(SeaStore::get_attrs_ertr::discard_all{})
|
||||
SeaStoreShard::attrs_t get_attrs(
|
||||
SeaStoreShard &sharded_seastore) {
|
||||
return sharded_seastore.get_attrs(coll, oid)
|
||||
.handle_error(SeaStoreShard::get_attrs_ertr::discard_all{})
|
||||
.get();
|
||||
}
|
||||
|
||||
ceph::bufferlist get_attr(
|
||||
SeaStore& seastore,
|
||||
SeaStoreShard& sharded_seastore,
|
||||
std::string_view name) {
|
||||
return seastore.get_attr(coll, oid, name)
|
||||
return sharded_seastore.get_attr(coll, oid, name)
|
||||
.handle_error(
|
||||
SeaStore::get_attr_errorator::discard_all{})
|
||||
SeaStoreShard::get_attr_errorator::discard_all{})
|
||||
.get();
|
||||
}
|
||||
|
||||
void check_omap_key(
|
||||
SeaStore &seastore,
|
||||
SeaStoreShard &sharded_seastore,
|
||||
const string &key) {
|
||||
std::set<string> to_check;
|
||||
to_check.insert(key);
|
||||
auto result = seastore.omap_get_values(
|
||||
auto result = sharded_seastore.omap_get_values(
|
||||
coll,
|
||||
oid,
|
||||
to_check).unsafe_get0();
|
||||
@ -394,11 +395,11 @@ struct seastore_test_t :
|
||||
}
|
||||
}
|
||||
|
||||
void check_omap(SeaStore &seastore) {
|
||||
void check_omap(SeaStoreShard &sharded_seastore) {
|
||||
auto refiter = omap.begin();
|
||||
std::optional<std::string> start;
|
||||
while(true) {
|
||||
auto [done, kvs] = seastore.omap_get_values(
|
||||
auto [done, kvs] = sharded_seastore.omap_get_values(
|
||||
coll,
|
||||
oid,
|
||||
start).unsafe_get0();
|
||||
@ -446,7 +447,7 @@ struct seastore_test_t :
|
||||
void remove_object(
|
||||
object_state_t &sobj) {
|
||||
|
||||
sobj.remove(*seastore);
|
||||
sobj.remove(*sharded_seastore);
|
||||
auto erased = test_objects.erase(sobj.oid);
|
||||
ceph_assert(erased == 1);
|
||||
}
|
||||
@ -456,7 +457,7 @@ struct seastore_test_t :
|
||||
for (auto& [oid, obj] : test_objects) {
|
||||
oids.emplace_back(oid);
|
||||
}
|
||||
auto ret = seastore->list_objects(
|
||||
auto ret = sharded_seastore->list_objects(
|
||||
coll,
|
||||
ghobject_t(),
|
||||
ghobject_t::get_max(),
|
||||
@ -529,8 +530,8 @@ struct seastore_test_t :
|
||||
auto create = [this, &objs](ghobject_t hoid) {
|
||||
objs.emplace_back(std::move(hoid));
|
||||
auto &obj = get_object(objs.back());
|
||||
obj.touch(*seastore);
|
||||
obj.check_size(*seastore);
|
||||
obj.touch(*sharded_seastore);
|
||||
obj.check_size(*sharded_seastore);
|
||||
};
|
||||
for (unsigned i = 0; i < temp_to_create; ++i) {
|
||||
create(make_temp_oid(i));
|
||||
@ -545,7 +546,7 @@ struct seastore_test_t :
|
||||
auto right_bound = in_right_bound.get_oid(*seastore, coll);
|
||||
|
||||
// get results from seastore
|
||||
auto [listed, next] = seastore->list_objects(
|
||||
auto [listed, next] = sharded_seastore->list_objects(
|
||||
coll, left_bound, right_bound, limit).get0();
|
||||
|
||||
// compute correct answer
|
||||
@ -593,7 +594,7 @@ struct seastore_test_t :
|
||||
}
|
||||
|
||||
// teardown
|
||||
for (auto &&hoid : objs) { get_object(hoid).remove(*seastore); }
|
||||
for (auto &&hoid : objs) { get_object(hoid).remove(*sharded_seastore); }
|
||||
}
|
||||
};
|
||||
|
||||
@ -610,7 +611,7 @@ TEST_P(seastore_test_t, collection_create_list_remove)
|
||||
run_async([this] {
|
||||
coll_t test_coll{spg_t{pg_t{1, 0}}};
|
||||
{
|
||||
seastore->create_new_collection(test_coll).get0();
|
||||
sharded_seastore->create_new_collection(test_coll).get0();
|
||||
{
|
||||
CTransaction t;
|
||||
t.create_collection(test_coll, 4);
|
||||
@ -663,8 +664,8 @@ TEST_P(seastore_test_t, touch_stat_list_remove)
|
||||
{
|
||||
run_async([this] {
|
||||
auto &test_obj = get_object(make_oid(0));
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.check_size(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
test_obj.check_size(*sharded_seastore);
|
||||
validate_objects();
|
||||
|
||||
remove_object(test_obj);
|
||||
@ -755,13 +756,13 @@ TEST_P(seastore_test_t, omap_test_simple)
|
||||
{
|
||||
run_async([this] {
|
||||
auto &test_obj = get_object(make_oid(0));
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
test_obj.set_omap(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
"asdf",
|
||||
make_bufferlist(128));
|
||||
test_obj.check_omap_key(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
"asdf");
|
||||
});
|
||||
}
|
||||
@ -770,24 +771,24 @@ TEST_P(seastore_test_t, attr)
|
||||
{
|
||||
run_async([this] {
|
||||
auto& test_obj = get_object(make_oid(0));
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
{
|
||||
std::string oi("asdfasdfasdf");
|
||||
bufferlist bl;
|
||||
encode(oi, bl);
|
||||
test_obj.set_attr(*seastore, OI_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
|
||||
|
||||
std::string ss("fdsfdsfs");
|
||||
bl.clear();
|
||||
encode(ss, bl);
|
||||
test_obj.set_attr(*seastore, SS_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
|
||||
|
||||
std::string test_val("ssssssssssss");
|
||||
bl.clear();
|
||||
encode(test_val, bl);
|
||||
test_obj.set_attr(*seastore, "test_key", bl);
|
||||
test_obj.set_attr(*sharded_seastore, "test_key", bl);
|
||||
|
||||
auto attrs = test_obj.get_attrs(*seastore);
|
||||
auto attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
std::string oi2;
|
||||
bufferlist bl2 = attrs[OI_ATTR];
|
||||
decode(oi2, bl2);
|
||||
@ -804,13 +805,13 @@ TEST_P(seastore_test_t, attr)
|
||||
EXPECT_EQ(test_val, test_val2);
|
||||
|
||||
bl2.clear();
|
||||
bl2 = test_obj.get_attr(*seastore, "test_key");
|
||||
bl2 = test_obj.get_attr(*sharded_seastore, "test_key");
|
||||
test_val2.clear();
|
||||
decode(test_val2, bl2);
|
||||
EXPECT_EQ(test_val, test_val2);
|
||||
//test rm_attrs
|
||||
test_obj.rm_attrs(*seastore);
|
||||
attrs = test_obj.get_attrs(*seastore);
|
||||
test_obj.rm_attrs(*sharded_seastore);
|
||||
attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
EXPECT_EQ(attrs.find(OI_ATTR), attrs.end());
|
||||
EXPECT_EQ(attrs.find(SS_ATTR), attrs.end());
|
||||
EXPECT_EQ(attrs.find("test_key"), attrs.end());
|
||||
@ -822,15 +823,15 @@ TEST_P(seastore_test_t, attr)
|
||||
std::string oi_str(&oi_array[0], sizeof(oi_array));
|
||||
bl.clear();
|
||||
encode(oi_str, bl);
|
||||
test_obj.set_attr(*seastore, OI_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
|
||||
|
||||
char ss_array[onode_layout_t::MAX_SS_LENGTH + 1] = {'b'};
|
||||
std::string ss_str(&ss_array[0], sizeof(ss_array));
|
||||
bl.clear();
|
||||
encode(ss_str, bl);
|
||||
test_obj.set_attr(*seastore, SS_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
|
||||
|
||||
attrs = test_obj.get_attrs(*seastore);
|
||||
attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
bl2.clear();
|
||||
bl2 = attrs[OI_ATTR];
|
||||
std::string oi_str2;
|
||||
@ -845,20 +846,20 @@ TEST_P(seastore_test_t, attr)
|
||||
|
||||
bl2.clear();
|
||||
ss_str2.clear();
|
||||
bl2 = test_obj.get_attr(*seastore, SS_ATTR);
|
||||
bl2 = test_obj.get_attr(*sharded_seastore, SS_ATTR);
|
||||
decode(ss_str2, bl2);
|
||||
EXPECT_EQ(ss_str, ss_str2);
|
||||
|
||||
bl2.clear();
|
||||
oi_str2.clear();
|
||||
bl2 = test_obj.get_attr(*seastore, OI_ATTR);
|
||||
bl2 = test_obj.get_attr(*sharded_seastore, OI_ATTR);
|
||||
decode(oi_str2, bl2);
|
||||
EXPECT_EQ(oi_str, oi_str2);
|
||||
|
||||
test_obj.rm_attr(*seastore, OI_ATTR);
|
||||
test_obj.rm_attr(*seastore, SS_ATTR);
|
||||
test_obj.rm_attr(*sharded_seastore, OI_ATTR);
|
||||
test_obj.rm_attr(*sharded_seastore, SS_ATTR);
|
||||
|
||||
attrs = test_obj.get_attrs(*seastore);
|
||||
attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
EXPECT_EQ(attrs.find(OI_ATTR), attrs.end());
|
||||
EXPECT_EQ(attrs.find(SS_ATTR), attrs.end());
|
||||
}
|
||||
@ -868,19 +869,19 @@ TEST_P(seastore_test_t, attr)
|
||||
std::string oi("asdfasdfasdf");
|
||||
bufferlist bl;
|
||||
encode(oi, bl);
|
||||
test_obj.set_attr(*seastore, OI_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
|
||||
|
||||
std::string ss("f");
|
||||
bl.clear();
|
||||
encode(ss, bl);
|
||||
test_obj.set_attr(*seastore, SS_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
|
||||
|
||||
std::string test_val("ssssssssssss");
|
||||
bl.clear();
|
||||
encode(test_val, bl);
|
||||
test_obj.set_attr(*seastore, "test_key", bl);
|
||||
test_obj.set_attr(*sharded_seastore, "test_key", bl);
|
||||
|
||||
auto attrs = test_obj.get_attrs(*seastore);
|
||||
auto attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
std::string oi2;
|
||||
bufferlist bl2 = attrs[OI_ATTR];
|
||||
decode(oi2, bl2);
|
||||
@ -896,11 +897,11 @@ TEST_P(seastore_test_t, attr)
|
||||
EXPECT_EQ(oi, oi2);
|
||||
EXPECT_EQ(test_val, test_val2);
|
||||
|
||||
test_obj.rm_attr(*seastore, OI_ATTR);
|
||||
test_obj.rm_attr(*seastore, SS_ATTR);
|
||||
test_obj.rm_attr(*seastore, "test_key");
|
||||
test_obj.rm_attr(*sharded_seastore, OI_ATTR);
|
||||
test_obj.rm_attr(*sharded_seastore, SS_ATTR);
|
||||
test_obj.rm_attr(*sharded_seastore, "test_key");
|
||||
|
||||
attrs = test_obj.get_attrs(*seastore);
|
||||
attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
EXPECT_EQ(attrs.find(OI_ATTR), attrs.end());
|
||||
EXPECT_EQ(attrs.find(SS_ATTR), attrs.end());
|
||||
EXPECT_EQ(attrs.find("test_key"), attrs.end());
|
||||
@ -914,25 +915,25 @@ TEST_P(seastore_test_t, attr)
|
||||
std::string oi(&oi_array[0], sizeof(oi_array));
|
||||
bufferlist bl;
|
||||
encode(oi, bl);
|
||||
test_obj.set_attr(*seastore, OI_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, OI_ATTR, bl);
|
||||
|
||||
oi = "asdfasdfasdf";
|
||||
bl.clear();
|
||||
encode(oi, bl);
|
||||
test_obj.set_attr(*seastore, OI_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_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);
|
||||
test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
|
||||
|
||||
ss = "f";
|
||||
bl.clear();
|
||||
encode(ss, bl);
|
||||
test_obj.set_attr(*seastore, SS_ATTR, bl);
|
||||
test_obj.set_attr(*sharded_seastore, SS_ATTR, bl);
|
||||
|
||||
auto attrs = test_obj.get_attrs(*seastore);
|
||||
auto attrs = test_obj.get_attrs(*sharded_seastore);
|
||||
std::string oi2, ss2;
|
||||
bufferlist bl2 = attrs[OI_ATTR];
|
||||
decode(oi2, bl2);
|
||||
@ -954,14 +955,14 @@ TEST_P(seastore_test_t, omap_test_iterator)
|
||||
return ss.str();
|
||||
};
|
||||
auto &test_obj = get_object(make_oid(0));
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
for (unsigned i = 0; i < 20; ++i) {
|
||||
test_obj.set_omap(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
make_key(i),
|
||||
make_bufferlist(128));
|
||||
}
|
||||
test_obj.check_omap(*seastore);
|
||||
test_obj.check_omap(*sharded_seastore);
|
||||
});
|
||||
}
|
||||
|
||||
@ -974,23 +975,23 @@ TEST_P(seastore_test_t, object_data_omap_remove)
|
||||
return ss.str();
|
||||
};
|
||||
auto &test_obj = get_object(make_oid(0));
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
for (unsigned i = 0; i < 1024; ++i) {
|
||||
test_obj.set_omap(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
make_key(i),
|
||||
make_bufferlist(128));
|
||||
}
|
||||
test_obj.check_omap(*seastore);
|
||||
test_obj.check_omap(*sharded_seastore);
|
||||
|
||||
for (uint64_t i = 0; i < 16; i++) {
|
||||
test_obj.write(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
4096 * i,
|
||||
4096,
|
||||
'a');
|
||||
}
|
||||
test_obj.remove(*seastore);
|
||||
test_obj.remove(*sharded_seastore);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1000,15 +1001,15 @@ TEST_P(seastore_test_t, simple_extent_test)
|
||||
run_async([this] {
|
||||
auto &test_obj = get_object(make_oid(0));
|
||||
test_obj.write(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
1024,
|
||||
1024,
|
||||
'a');
|
||||
test_obj.read(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
1024,
|
||||
1024);
|
||||
test_obj.check_size(*seastore);
|
||||
test_obj.check_size(*sharded_seastore);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1016,14 +1017,14 @@ TEST_P(seastore_test_t, fiemap_empty)
|
||||
{
|
||||
run_async([this] {
|
||||
auto &test_obj = get_object(make_oid(0));
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.truncate(*seastore, 100000);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
test_obj.truncate(*sharded_seastore, 100000);
|
||||
|
||||
std::map<uint64_t, uint64_t> m;
|
||||
m = test_obj.fiemap(*seastore, 0, 100000);
|
||||
m = test_obj.fiemap(*sharded_seastore, 0, 100000);
|
||||
EXPECT_TRUE(m.empty());
|
||||
|
||||
test_obj.remove(*seastore);
|
||||
test_obj.remove(*sharded_seastore);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1038,14 +1039,14 @@ TEST_P(seastore_test_t, fiemap_holes)
|
||||
bufferlist bl;
|
||||
bl.append("foo");
|
||||
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
|
||||
test_obj.write(*seastore, SKIP_STEP * i, bl);
|
||||
test_obj.write(*sharded_seastore, SKIP_STEP * i, bl);
|
||||
}
|
||||
|
||||
{ // fiemap test from 0 to SKIP_STEP * (MAX_EXTENTS - 1) + 3
|
||||
auto m = test_obj.fiemap(
|
||||
*seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3);
|
||||
*sharded_seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3);
|
||||
ASSERT_EQ(m.size(), MAX_EXTENTS);
|
||||
for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
|
||||
ASSERT_TRUE(m.count(SKIP_STEP * i));
|
||||
@ -1055,7 +1056,7 @@ TEST_P(seastore_test_t, fiemap_holes)
|
||||
|
||||
{ // fiemap test from SKIP_STEP to SKIP_STEP * (MAX_EXTENTS - 2) + 3
|
||||
auto m = test_obj.fiemap(
|
||||
*seastore, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 3) + 3);
|
||||
*sharded_seastore, SKIP_STEP, SKIP_STEP * (MAX_EXTENTS - 3) + 3);
|
||||
ASSERT_EQ(m.size(), MAX_EXTENTS - 2);
|
||||
for (uint64_t i = 1; i < MAX_EXTENTS - 1; i++) {
|
||||
ASSERT_TRUE(m.count(SKIP_STEP * i));
|
||||
@ -1065,7 +1066,7 @@ TEST_P(seastore_test_t, fiemap_holes)
|
||||
|
||||
{ // fiemap test SKIP_STEP + 1 to 2 * SKIP_STEP + 1 (partial overlap)
|
||||
auto m = test_obj.fiemap(
|
||||
*seastore, SKIP_STEP + 1, SKIP_STEP + 1);
|
||||
*sharded_seastore, SKIP_STEP + 1, SKIP_STEP + 1);
|
||||
ASSERT_EQ(m.size(), 2);
|
||||
ASSERT_EQ(m.begin()->first, SKIP_STEP + 1);
|
||||
ASSERT_GE(m.begin()->second, bl.length());
|
||||
@ -1073,7 +1074,7 @@ TEST_P(seastore_test_t, fiemap_holes)
|
||||
ASSERT_EQ(m.rbegin()->first + m.rbegin()->second, 2 * SKIP_STEP + 2);
|
||||
}
|
||||
|
||||
test_obj.remove(*seastore);
|
||||
test_obj.remove(*sharded_seastore);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1086,16 +1087,16 @@ TEST_P(seastore_test_t, sparse_read)
|
||||
bufferlist wbl;
|
||||
wbl.append("foo");
|
||||
|
||||
test_obj.touch(*seastore);
|
||||
test_obj.touch(*sharded_seastore);
|
||||
for (uint64_t i = 0; i < MAX_EXTENTS; i++) {
|
||||
test_obj.write(*seastore, SKIP_STEP * i, wbl);
|
||||
test_obj.write(*sharded_seastore, SKIP_STEP * i, wbl);
|
||||
}
|
||||
interval_set<uint64_t> m;
|
||||
m = interval_set<uint64_t>(
|
||||
test_obj.fiemap(*seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3));
|
||||
test_obj.fiemap(*sharded_seastore, 0, SKIP_STEP * (MAX_EXTENTS - 1) + 3));
|
||||
ASSERT_TRUE(!m.empty());
|
||||
uint64_t off = 0;
|
||||
auto rbl = test_obj.readv(*seastore, m);
|
||||
auto rbl = test_obj.readv(*sharded_seastore, m);
|
||||
|
||||
for (auto &&miter : m) {
|
||||
bufferlist subl;
|
||||
@ -1103,7 +1104,7 @@ TEST_P(seastore_test_t, sparse_read)
|
||||
ASSERT_TRUE(subl.contents_equal(wbl));
|
||||
off += miter.second;
|
||||
}
|
||||
test_obj.remove(*seastore);
|
||||
test_obj.remove(*sharded_seastore);
|
||||
});
|
||||
}
|
||||
|
||||
@ -1120,21 +1121,21 @@ TEST_P(seastore_test_t, zero)
|
||||
uint64_t size = 0;
|
||||
for (auto &[off, len, repeat]: writes) {
|
||||
for (decltype(repeat) i = 0; i < repeat; ++i) {
|
||||
test_obj.write(*seastore, off + (len * repeat), len, 'a');
|
||||
test_obj.write(*sharded_seastore, off + (len * repeat), len, 'a');
|
||||
}
|
||||
size = off + (len * (repeat + 1));
|
||||
}
|
||||
test_obj.read(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
0,
|
||||
size);
|
||||
test_obj.check_size(*seastore);
|
||||
test_obj.zero(*seastore, zero_off, zero_len);
|
||||
test_obj.check_size(*sharded_seastore);
|
||||
test_obj.zero(*sharded_seastore, zero_off, zero_len);
|
||||
test_obj.read(
|
||||
*seastore,
|
||||
*sharded_seastore,
|
||||
0,
|
||||
size);
|
||||
test_obj.check_size(*seastore);
|
||||
test_obj.check_size(*sharded_seastore);
|
||||
remove_object(test_obj);
|
||||
};
|
||||
|
||||
|
@ -181,11 +181,11 @@ protected:
|
||||
|
||||
virtual seastar::future<> _init() = 0;
|
||||
|
||||
virtual void _destroy() = 0;
|
||||
virtual seastar::future<> _destroy() = 0;
|
||||
virtual seastar::future<> _teardown() = 0;
|
||||
seastar::future<> teardown() {
|
||||
return _teardown().then([this] {
|
||||
_destroy();
|
||||
return _destroy();
|
||||
});
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ protected:
|
||||
}
|
||||
SUBINFO(test, "begin with {} devices ...", devices->get_num_devices());
|
||||
return devices->setup(
|
||||
).then([this]() {
|
||||
).then([this] {
|
||||
return _init();
|
||||
}).then([this, FNAME] {
|
||||
return _mkfs(
|
||||
@ -273,18 +273,16 @@ protected:
|
||||
return seastar::now();
|
||||
}
|
||||
|
||||
virtual void _destroy() override {
|
||||
virtual seastar::future<> _destroy() override {
|
||||
epm = nullptr;
|
||||
lba_manager = nullptr;
|
||||
cache = nullptr;
|
||||
tm.reset();
|
||||
return seastar::now();
|
||||
}
|
||||
|
||||
virtual seastar::future<> _teardown() {
|
||||
return tm->close().safe_then([this] {
|
||||
_destroy();
|
||||
return seastar::now();
|
||||
}).handle_error(
|
||||
return tm->close().handle_error(
|
||||
crimson::ct_error::assert_all{"Error in teardown"}
|
||||
);
|
||||
}
|
||||
@ -407,18 +405,24 @@ class SeaStoreTestState : public EphemeralTestState {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<SeaStore> seastore;
|
||||
FuturizedStore::Shard *sharded_seastore;
|
||||
|
||||
SeaStoreTestState() : EphemeralTestState(1, 0) {}
|
||||
|
||||
virtual seastar::future<> _init() final {
|
||||
seastore = make_test_seastore(
|
||||
std::make_unique<TestMDStoreState::Store>(mdstore_state.get_mdstore()));
|
||||
return seastore->test_start(devices->get_primary_device_ref());
|
||||
return seastore->test_start(devices->get_primary_device_ref()
|
||||
).then([this] {
|
||||
sharded_seastore = &(seastore->get_sharded_store());
|
||||
});
|
||||
}
|
||||
|
||||
virtual void _destroy() final {
|
||||
virtual seastar::future<> _destroy() final {
|
||||
devices->set_primary_device_ref(seastore->get_primary_device_ref());
|
||||
seastore.reset();
|
||||
return seastore->stop().then([this] {
|
||||
seastore.reset();
|
||||
});
|
||||
}
|
||||
|
||||
virtual seastar::future<> _teardown() final {
|
||||
|
Loading…
Reference in New Issue
Block a user