From: Jon Date: Thu, 19 Jun 2025 14:16:36 +0000 (+0100) Subject: test/osd: Make error messages that occur based on configuration problems or user... X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=784c750df07d816e32d8588e4c3daf8a2cf6917a;p=ceph.git 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 --- 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 e15635612555f..396ec815afaff 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 @@ -333,7 +333,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)); } } @@ -570,10 +578,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)); } } } @@ -653,7 +660,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(); @@ -799,10 +808,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)); } } } @@ -1401,10 +1409,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(); @@ -1488,8 +1502,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; }