Skip to content

Commit 1654b8f

Browse files
bill-scalesJonBailey1993
authored andcommitted
test: add replica pool support to ceph_test_rados_io_sequence
Make 'ceph_test_rados_io_sequenece --pool rbd' work, replica pools don't have an erausre code profile and do not have the ec_allow_overwrites or ec_allow_optimizations flags Fixes: https://tracker.ceph.com/issues/70844 Signed-off-by: Bill Scales <[email protected]> Signed-off-by: Jon Bailey <[email protected]>
1 parent e8ef0f4 commit 1654b8f

File tree

4 files changed

+74
-33
lines changed

4 files changed

+74
-33
lines changed

src/common/io_exerciser/RadosIo.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio,
4646
const std::string& pool, const std::string& oid,
4747
const std::optional<std::vector<int>>& cached_shard_order,
4848
uint64_t block_size, int seed, int threads, ceph::mutex& lock,
49-
ceph::condition_variable& cond, bool ec_optimizations)
49+
ceph::condition_variable& cond, bool is_replicated_pool,
50+
bool ec_optimizations)
5051
: Model(oid, block_size),
5152
rados(rados),
5253
asio(asio),
5354
om(std::make_unique<ObjectModel>(oid, block_size, seed)),
5455
db(data_generation::DataGenerator::create_generator(
5556
data_generation::GenerationType::HeaderedSeededRandom, *om)),
56-
cc(std::make_unique<ConsistencyChecker>(rados, asio, pool)),
5757
pool(pool),
5858
cached_shard_order(cached_shard_order),
5959
threads(threads),
@@ -63,6 +63,9 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio,
6363
int rc;
6464
rc = rados.ioctx_create(pool.c_str(), io);
6565
ceph_assert(rc == 0);
66+
if (!is_replicated_pool) {
67+
cc = std::make_unique<ConsistencyChecker>(rados, asio, pool);
68+
}
6669
}
6770

6871
RadosIo::~RadosIo() {}

src/common/io_exerciser/RadosIo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class RadosIo : public Model {
4848
const std::string& pool, const std::string& oid,
4949
const std::optional<std::vector<int>>& cached_shard_order,
5050
uint64_t block_size, int seed, int threads, ceph::mutex& lock,
51-
ceph::condition_variable& cond, bool ec_optimizations);
51+
ceph::condition_variable& cond, bool is_replicated_pool,
52+
bool ec_optimizations);
5253

5354
~RadosIo();
5455

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ constexpr std::string_view usage[] = {
134134
"ceph_test_rados_io_sequence --blocksize <b> --pool <p> --object <oid>",
135135
" --objectsize <min,max> --threads <t>",
136136
"\tCustomize the test, if a pool is specified then it defines the",
137-
"\tReplica/EC configuration",
137+
"\tReplicated/EC configuration",
138138
"",
139139
"ceph_test_rados_io_sequence --listsequence",
140140
"\t Display list of supported I/O sequences",
@@ -793,6 +793,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
793793
bool allow_pool_balancer,
794794
bool allow_pool_deep_scrubbing,
795795
bool allow_pool_scrubbing,
796+
bool check_consistency,
796797
bool test_recovery,
797798
bool allow_pool_ec_optimizations)
798799
: ProgramOptionReader<std::string>(vm, "pool"),
@@ -802,6 +803,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
802803
allow_pool_balancer(allow_pool_balancer),
803804
allow_pool_deep_scrubbing(allow_pool_deep_scrubbing),
804805
allow_pool_scrubbing(allow_pool_scrubbing),
806+
check_consistency(check_consistency),
805807
test_recovery(test_recovery),
806808
allow_pool_ec_optimizations(allow_pool_ec_optimizations),
807809
first_use(true),
@@ -844,18 +846,32 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() {
844846
ceph::messaging::osd::OSDPoolGetReply pool_get_reply;
845847
pool_get_reply.decode_json(&p);
846848

847-
profile = sep.selectExistingProfile(pool_get_reply.erasure_code_profile);
849+
if (pool_get_reply.erasure_code_profile.has_value()) {
850+
pool_type = pg_pool_t::TYPE_ERASURE;
851+
profile = sep.selectExistingProfile(*pool_get_reply.erasure_code_profile);
852+
} else {
853+
pool_type = pg_pool_t::TYPE_REPLICATED;
854+
if (check_consistency) {
855+
throw std::invalid_argument(fmt::format("checkconsistency option not "
856+
"allowed if using a {} pool",
857+
pg_pool_t::get_type_name(pool_type)));
858+
}
859+
}
848860
} else {
861+
pool_type = pg_pool_t::TYPE_ERASURE;
849862
created_pool_name = create();
850863
}
851864

852865
if (!dry_run) {
853-
configureServices(force_value.value_or(created_pool_name),
866+
configureServices(force_value.value_or(created_pool_name), pool_type,
854867
allow_pool_autoscaling, allow_pool_balancer,
855868
allow_pool_deep_scrubbing, allow_pool_scrubbing,
856869
allow_pool_ec_optimizations, true, test_recovery);
857870

858-
setApplication(created_pool_name);
871+
if (!force_value)
872+
{
873+
setApplication(created_pool_name);
874+
}
859875
}
860876
}
861877

@@ -898,6 +914,7 @@ void ceph::io_sequence::tester::SelectErasurePool::setApplication(
898914

899915
void ceph::io_sequence::tester::SelectErasurePool::configureServices(
900916
const std::string& pool_name,
917+
PoolType pool_type,
901918
bool allow_pool_autoscaling,
902919
bool allow_pool_balancer,
903920
bool allow_pool_deep_scrubbing,
@@ -953,26 +970,29 @@ void ceph::io_sequence::tester::SelectErasurePool::configureServices(
953970
ceph_assert(rc == 0);
954971
}
955972

956-
if (allow_pool_ec_optimizations) {
957-
ceph::messaging::osd::OSDPoolSetRequest
958-
allow_ec_optimisations_request{pool_name,
959-
"allow_ec_optimizations",
960-
"true",
961-
std::nullopt};
962-
rc = send_mon_command(allow_ec_optimisations_request, rados,
963-
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
964-
ceph_assert(rc == 0);
965-
}
973+
if (pool_type == pg_pool_t::TYPE_ERASURE)
974+
{
975+
if (allow_pool_ec_optimizations) {
976+
ceph::messaging::osd::OSDPoolSetRequest
977+
allow_ec_optimisations_request{pool_name,
978+
"allow_ec_optimizations",
979+
"true",
980+
std::nullopt};
981+
rc = send_mon_command(allow_ec_optimisations_request, rados,
982+
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
983+
ceph_assert(rc == 0);
984+
}
966985

967-
if (allow_pool_ec_overwrites) {
968-
ceph::messaging::osd::OSDPoolSetRequest
969-
allow_ec_optimisations_request{pool_name,
970-
"allow_ec_overwrites",
971-
"true",
972-
std::nullopt};
973-
rc = send_mon_command(allow_ec_optimisations_request, rados,
974-
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
975-
ceph_assert(rc == 0);
986+
if (allow_pool_ec_overwrites) {
987+
ceph::messaging::osd::OSDPoolSetRequest
988+
allow_ec_optimisations_request{pool_name,
989+
"allow_ec_overwrites",
990+
"true",
991+
std::nullopt};
992+
rc = send_mon_command(allow_ec_optimisations_request, rados,
993+
"OSDPoolSetRequest", inbl, &outbl, formatter.get());
994+
ceph_assert(rc == 0);
995+
}
976996
}
977997

978998
if (test_recovery) {
@@ -1005,11 +1025,13 @@ ceph::io_sequence::tester::TestObject::TestObject(
10051025
} else {
10061026
const std::string pool = spo.select();
10071027
if (!dryrun) {
1008-
ceph_assert(spo.getProfile());
1009-
pool_km = spo.getProfile()->km;
1010-
if (spo.getProfile()->mapping && spo.getProfile()->layers) {
1011-
pool_mappinglayers = {*spo.getProfile()->mapping,
1012-
*spo.getProfile()->layers};
1028+
if (!spo.is_replicated_pool()) {
1029+
ceph_assert(spo.getProfile());
1030+
pool_km = spo.getProfile()->km;
1031+
if (spo.getProfile()->mapping && spo.getProfile()->layers) {
1032+
pool_mappinglayers = {*spo.getProfile()->mapping,
1033+
*spo.getProfile()->layers};
1034+
}
10131035
}
10141036
}
10151037

@@ -1039,7 +1061,8 @@ ceph::io_sequence::tester::TestObject::TestObject(
10391061

10401062
exerciser_model = std::make_unique<ceph::io_exerciser::RadosIo>(
10411063
rados, asio, pool, oid, cached_shard_order, sbs.select(), rng(),
1042-
threads, lock, cond, spo.get_allow_pool_ec_optimizations());
1064+
threads, lock, cond, spo.is_replicated_pool(),
1065+
spo.get_allow_pool_ec_optimizations());
10431066
dout(0) << "= " << oid << " pool=" << pool << " threads=" << threads
10441067
<< " blocksize=" << exerciser_model->get_block_size() << " ="
10451068
<< dendl;
@@ -1131,6 +1154,7 @@ ceph::io_sequence::tester::TestRunner::TestRunner(
11311154
vm.contains("allow_pool_balancer"),
11321155
vm.contains("allow_pool_deep_scrubbing"),
11331156
vm.contains("allow_pool_scrubbing"),
1157+
vm.contains("checkconsistency"),
11341158
vm.contains("testrecovery"),
11351159
!vm.contains("disable_pool_ec_optimizations")},
11361160
snt{rng, vm, "threads", true},
@@ -1318,7 +1342,7 @@ bool ceph::io_sequence::tester::TestRunner::run_interactive_test() {
13181342
model = std::make_unique<ceph::io_exerciser::RadosIo>(
13191343
rados, asio, pool, object_name, osd_map_reply.acting, sbs.select(), rng(),
13201344
1, // 1 thread
1321-
lock, cond,
1345+
lock, cond, spo.is_replicated_pool(),
13221346
spo.get_allow_pool_ec_optimizations());
13231347
}
13241348

@@ -1474,6 +1498,10 @@ bool ceph::io_sequence::tester::TestRunner::run_automated_test() {
14741498
std::cerr << "Error: " << e.what() << std::endl;
14751499
return false;
14761500
}
1501+
catch (const std::invalid_argument &e) {
1502+
std::cerr << "Error: " << e.what() << std::endl;
1503+
return false;
1504+
}
14771505
}
14781506
if (!dryrun) {
14791507
rados.wait_for_latest_osdmap();

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
388388
bool allow_pool_balancer,
389389
bool allow_pool_deep_scrubbing,
390390
bool allow_pool_scrubbing,
391+
bool check_consistency,
391392
bool test_recovery,
392393
bool allow_pool_ec_optimizations);
393394
const std::string select() override;
@@ -402,6 +403,9 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
402403
inline bool get_allow_pool_ec_optimizations() {
403404
return allow_pool_ec_optimizations;
404405
}
406+
407+
inline bool is_replicated_pool() const { return pool_type
408+
== pg_pool_t::TYPE_REPLICATED; }
405409
inline std::optional<Profile> getProfile() { return profile; }
406410

407411
private:
@@ -412,16 +416,21 @@ class SelectErasurePool : public ProgramOptionReader<std::string> {
412416
bool allow_pool_balancer;
413417
bool allow_pool_deep_scrubbing;
414418
bool allow_pool_scrubbing;
419+
bool check_consistency;
415420
bool test_recovery;
416421
bool allow_pool_ec_optimizations;
417422

423+
using PoolType = int;
424+
PoolType pool_type;
425+
418426
bool first_use;
419427

420428
SelectErasureProfile sep;
421429

422430
std::optional<Profile> profile;
423431

424432
void configureServices(const std::string& pool_name,
433+
PoolType pool_type,
425434
bool allow_pool_autoscaling,
426435
bool allow_pool_balancer,
427436
bool allow_pool_deep_scrubbing,

0 commit comments

Comments
 (0)