From 0cc083135ee0464364172fc6958204508ae5a101 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 19 Jun 2025 15:16:36 +0100 Subject: [PATCH] test/osd: Make error messages that occur based on configuration problems or user error more readable in ceph_test_rados_io_sequence Move away from using ceph_abort for error messages that occur from configuration issues and user error to printing to std::error as it is not necissairy to produce a call stack and core dumps in these cases and much better to give an easily readable message to the user. Signed-off-by: Jon Bailey (cherry picked from commit 784c750df07d816e32d8588e4c3daf8a2cf6917a) --- .../ceph_test_rados_io_sequence.cc | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) 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 03949ff3c48e4..936a6719fc048 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 @@ -318,7 +318,15 @@ ceph::io_sequence::tester::lrc::SelectMappingAndLayers::SelectMappingAndLayers( sma{mapping_rng, vm, "mapping", first_use}, sly{layers_rng, vm, "layers", first_use} { if (sma.isForced() != sly.isForced()) { - ceph_abort_msg("Mapping and layers must be used together when one is used"); + std::string forced_parameter = "mapping"; + std::string unforced_parameter = "layers"; + if (sly.isForced()) { + std::swap(forced_parameter, unforced_parameter); + } + + throw std::invalid_argument(fmt::format("The parameter --{} can only be used" + " when a --{} parameter is also supplied.", + forced_parameter, unforced_parameter)); } } @@ -555,10 +563,9 @@ ceph::io_sequence::tester::SelectErasureProfile::SelectErasureProfile( for (std::string& option : disallowed_options) { if (vm.count(option) > 0) { - ceph_abort_msg( - fmt::format("{} option not allowed " - "if profile is specified", - option)); + throw std::invalid_argument(fmt::format("{} option not allowed " + "if profile is specified", + option)); } } } @@ -638,7 +645,9 @@ ceph::io_sequence::tester::SelectErasureProfile::select() { instance.factory(std::string(profile.plugin), cct->_conf.get_val("erasure_code_dir"), erasure_code_profile, &ec_impl, &ss); - ceph_assert(ec_impl); + if (!ec_impl) { + throw std::runtime_error(ss.str()); + } SelectErasureChunkSize scs{rng, vm, ec_impl, first_use}; profile.chunk_size = scs.select(); @@ -784,10 +793,9 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool( for (std::string& option : disallowed_options) { if (vm.count(option) > 0) { - ceph_abort_msg( - fmt::format("{} option not allowed " - "if pool is specified", - option)); + throw std::invalid_argument(fmt::format("{} option not allowed " + "if pool is specified", + option)); } } } @@ -1381,10 +1389,16 @@ bool ceph::io_sequence::tester::TestRunner::run_automated_test() { } else { name = object_name + std::to_string(obj); } - test_objects.push_back( - std::make_shared( - name, rados, asio, sbs, spo, sos, snt, ssr, rng, lock, cond, dryrun, - verbose, seqseed, testrecovery)); + try { + test_objects.push_back( + std::make_shared( + name, rados, asio, sbs, spo, sos, snt, ssr, rng, lock, cond, + dryrun, verbose, seqseed, testrecovery)); + } + catch (const std::runtime_error &e) { + std::cerr << "Error: " << e.what() << std::endl; + return false; + } } if (!dryrun) { rados.wait_for_latest_osdmap(); @@ -1468,8 +1482,14 @@ int main(int argc, char** argv) { std::make_unique(cct, vm, rados); } catch (const po::error& e) { return 1; + } catch (const std::invalid_argument& e) { + std::cerr << "Error: " << e.what() << std::endl; + return 1; + } + + if (!runner->run_test()) { + return 1; } - runner->run_test(); return 0; } -- 2.39.5