From: Bill Scales Date: Wed, 9 Apr 2025 09:58:15 +0000 (+0100) Subject: test: add replica pool support to ceph_test_rados_io_sequence X-Git-Tag: testing/wip-vshankar-testing-20250910.085256-debug~21^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1654b8f0bdf0cf0214121cefc6801ee4ae6b2c90;p=ceph-ci.git 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 Signed-off-by: Jon Bailey --- diff --git a/src/common/io_exerciser/RadosIo.cc b/src/common/io_exerciser/RadosIo.cc index 985101170a3..468b454273e 100644 --- a/src/common/io_exerciser/RadosIo.cc +++ b/src/common/io_exerciser/RadosIo.cc @@ -46,14 +46,14 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio, const std::string& pool, const std::string& oid, const std::optional>& cached_shard_order, uint64_t block_size, int seed, int threads, ceph::mutex& lock, - ceph::condition_variable& cond, bool ec_optimizations) + ceph::condition_variable& cond, bool is_replicated_pool, + bool ec_optimizations) : Model(oid, block_size), rados(rados), asio(asio), om(std::make_unique(oid, block_size, seed)), db(data_generation::DataGenerator::create_generator( data_generation::GenerationType::HeaderedSeededRandom, *om)), - cc(std::make_unique(rados, asio, pool)), pool(pool), cached_shard_order(cached_shard_order), threads(threads), @@ -63,6 +63,9 @@ RadosIo::RadosIo(librados::Rados& rados, boost::asio::io_context& asio, int rc; rc = rados.ioctx_create(pool.c_str(), io); ceph_assert(rc == 0); + if (!is_replicated_pool) { + cc = std::make_unique(rados, asio, pool); + } } RadosIo::~RadosIo() {} diff --git a/src/common/io_exerciser/RadosIo.h b/src/common/io_exerciser/RadosIo.h index f3dc0beac19..ef43ad4317d 100644 --- a/src/common/io_exerciser/RadosIo.h +++ b/src/common/io_exerciser/RadosIo.h @@ -48,7 +48,8 @@ class RadosIo : public Model { const std::string& pool, const std::string& oid, const std::optional>& cached_shard_order, uint64_t block_size, int seed, int threads, ceph::mutex& lock, - ceph::condition_variable& cond, bool ec_optimizations); + ceph::condition_variable& cond, bool is_replicated_pool, + bool ec_optimizations); ~RadosIo(); diff --git a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc index 0526527be0a..2d31bf872b6 100644 --- a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc +++ b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc @@ -134,7 +134,7 @@ constexpr std::string_view usage[] = { "ceph_test_rados_io_sequence --blocksize --pool

--object ", " --objectsize --threads ", "\tCustomize the test, if a pool is specified then it defines the", - "\tReplica/EC configuration", + "\tReplicated/EC configuration", "", "ceph_test_rados_io_sequence --listsequence", "\t Display list of supported I/O sequences", @@ -793,6 +793,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool( bool allow_pool_balancer, bool allow_pool_deep_scrubbing, bool allow_pool_scrubbing, + bool check_consistency, bool test_recovery, bool allow_pool_ec_optimizations) : ProgramOptionReader(vm, "pool"), @@ -802,6 +803,7 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool( allow_pool_balancer(allow_pool_balancer), allow_pool_deep_scrubbing(allow_pool_deep_scrubbing), allow_pool_scrubbing(allow_pool_scrubbing), + check_consistency(check_consistency), test_recovery(test_recovery), allow_pool_ec_optimizations(allow_pool_ec_optimizations), first_use(true), @@ -844,18 +846,32 @@ const std::string ceph::io_sequence::tester::SelectErasurePool::select() { ceph::messaging::osd::OSDPoolGetReply pool_get_reply; pool_get_reply.decode_json(&p); - profile = sep.selectExistingProfile(pool_get_reply.erasure_code_profile); + if (pool_get_reply.erasure_code_profile.has_value()) { + pool_type = pg_pool_t::TYPE_ERASURE; + profile = sep.selectExistingProfile(*pool_get_reply.erasure_code_profile); + } else { + pool_type = pg_pool_t::TYPE_REPLICATED; + if (check_consistency) { + throw std::invalid_argument(fmt::format("checkconsistency option not " + "allowed if using a {} pool", + pg_pool_t::get_type_name(pool_type))); + } + } } else { + pool_type = pg_pool_t::TYPE_ERASURE; created_pool_name = create(); } if (!dry_run) { - configureServices(force_value.value_or(created_pool_name), + configureServices(force_value.value_or(created_pool_name), pool_type, allow_pool_autoscaling, allow_pool_balancer, allow_pool_deep_scrubbing, allow_pool_scrubbing, allow_pool_ec_optimizations, true, test_recovery); - setApplication(created_pool_name); + if (!force_value) + { + setApplication(created_pool_name); + } } } @@ -898,6 +914,7 @@ void ceph::io_sequence::tester::SelectErasurePool::setApplication( void ceph::io_sequence::tester::SelectErasurePool::configureServices( const std::string& pool_name, + PoolType pool_type, bool allow_pool_autoscaling, bool allow_pool_balancer, bool allow_pool_deep_scrubbing, @@ -953,26 +970,29 @@ void ceph::io_sequence::tester::SelectErasurePool::configureServices( ceph_assert(rc == 0); } - if (allow_pool_ec_optimizations) { - ceph::messaging::osd::OSDPoolSetRequest - allow_ec_optimisations_request{pool_name, - "allow_ec_optimizations", - "true", - std::nullopt}; - rc = send_mon_command(allow_ec_optimisations_request, rados, - "OSDPoolSetRequest", inbl, &outbl, formatter.get()); - ceph_assert(rc == 0); - } + if (pool_type == pg_pool_t::TYPE_ERASURE) + { + if (allow_pool_ec_optimizations) { + ceph::messaging::osd::OSDPoolSetRequest + allow_ec_optimisations_request{pool_name, + "allow_ec_optimizations", + "true", + std::nullopt}; + rc = send_mon_command(allow_ec_optimisations_request, rados, + "OSDPoolSetRequest", inbl, &outbl, formatter.get()); + ceph_assert(rc == 0); + } - if (allow_pool_ec_overwrites) { - ceph::messaging::osd::OSDPoolSetRequest - allow_ec_optimisations_request{pool_name, - "allow_ec_overwrites", - "true", - std::nullopt}; - rc = send_mon_command(allow_ec_optimisations_request, rados, - "OSDPoolSetRequest", inbl, &outbl, formatter.get()); - ceph_assert(rc == 0); + if (allow_pool_ec_overwrites) { + ceph::messaging::osd::OSDPoolSetRequest + allow_ec_optimisations_request{pool_name, + "allow_ec_overwrites", + "true", + std::nullopt}; + rc = send_mon_command(allow_ec_optimisations_request, rados, + "OSDPoolSetRequest", inbl, &outbl, formatter.get()); + ceph_assert(rc == 0); + } } if (test_recovery) { @@ -1005,11 +1025,13 @@ ceph::io_sequence::tester::TestObject::TestObject( } else { const std::string pool = spo.select(); if (!dryrun) { - ceph_assert(spo.getProfile()); - pool_km = spo.getProfile()->km; - if (spo.getProfile()->mapping && spo.getProfile()->layers) { - pool_mappinglayers = {*spo.getProfile()->mapping, - *spo.getProfile()->layers}; + if (!spo.is_replicated_pool()) { + ceph_assert(spo.getProfile()); + pool_km = spo.getProfile()->km; + if (spo.getProfile()->mapping && spo.getProfile()->layers) { + pool_mappinglayers = {*spo.getProfile()->mapping, + *spo.getProfile()->layers}; + } } } @@ -1039,7 +1061,8 @@ ceph::io_sequence::tester::TestObject::TestObject( exerciser_model = std::make_unique( rados, asio, pool, oid, cached_shard_order, sbs.select(), rng(), - threads, lock, cond, spo.get_allow_pool_ec_optimizations()); + threads, lock, cond, spo.is_replicated_pool(), + spo.get_allow_pool_ec_optimizations()); dout(0) << "= " << oid << " pool=" << pool << " threads=" << threads << " blocksize=" << exerciser_model->get_block_size() << " =" << dendl; @@ -1131,6 +1154,7 @@ ceph::io_sequence::tester::TestRunner::TestRunner( vm.contains("allow_pool_balancer"), vm.contains("allow_pool_deep_scrubbing"), vm.contains("allow_pool_scrubbing"), + vm.contains("checkconsistency"), vm.contains("testrecovery"), !vm.contains("disable_pool_ec_optimizations")}, snt{rng, vm, "threads", true}, @@ -1318,7 +1342,7 @@ bool ceph::io_sequence::tester::TestRunner::run_interactive_test() { model = std::make_unique( rados, asio, pool, object_name, osd_map_reply.acting, sbs.select(), rng(), 1, // 1 thread - lock, cond, + lock, cond, spo.is_replicated_pool(), spo.get_allow_pool_ec_optimizations()); } @@ -1474,6 +1498,10 @@ bool ceph::io_sequence::tester::TestRunner::run_automated_test() { std::cerr << "Error: " << e.what() << std::endl; return false; } + catch (const std::invalid_argument &e) { + std::cerr << "Error: " << e.what() << std::endl; + return false; + } } if (!dryrun) { rados.wait_for_latest_osdmap(); diff --git a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h index 50b9f9ac36c..a874cfa924a 100644 --- a/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h +++ b/src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.h @@ -388,6 +388,7 @@ class SelectErasurePool : public ProgramOptionReader { bool allow_pool_balancer, bool allow_pool_deep_scrubbing, bool allow_pool_scrubbing, + bool check_consistency, bool test_recovery, bool allow_pool_ec_optimizations); const std::string select() override; @@ -402,6 +403,9 @@ class SelectErasurePool : public ProgramOptionReader { inline bool get_allow_pool_ec_optimizations() { return allow_pool_ec_optimizations; } + + inline bool is_replicated_pool() const { return pool_type + == pg_pool_t::TYPE_REPLICATED; } inline std::optional getProfile() { return profile; } private: @@ -412,9 +416,13 @@ class SelectErasurePool : public ProgramOptionReader { bool allow_pool_balancer; bool allow_pool_deep_scrubbing; bool allow_pool_scrubbing; + bool check_consistency; bool test_recovery; bool allow_pool_ec_optimizations; + using PoolType = int; + PoolType pool_type; + bool first_use; SelectErasureProfile sep; @@ -422,6 +430,7 @@ class SelectErasurePool : public ProgramOptionReader { std::optional profile; void configureServices(const std::string& pool_name, + PoolType pool_type, bool allow_pool_autoscaling, bool allow_pool_balancer, bool allow_pool_deep_scrubbing,