Skip to content

Commit a668040

Browse files
Merge pull request ceph#64046 from JonBailey1993/ceph_test_rados_io_sequence_error_readability
test/osd: Improve readability of errors in ceph_test_rados_io_sequence Reviewed-by: Bill Scales <[email protected]> Reviewed-by: Ronen Friedman <[email protected]>
2 parents f0b7646 + 784c750 commit a668040

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

src/test/osd/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ install(TARGETS
2121

2222
add_executable(ceph_test_rados_io_sequence
2323
${CMAKE_CURRENT_SOURCE_DIR}/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc)
24+
add_dependencies(ceph_test_rados_io_sequence erasure_code_plugins)
2425
target_link_libraries(ceph_test_rados_io_sequence
2526
librados global object_io_exerciser json_structures)
2627
install(TARGETS

src/test/osd/ceph_test_rados_io_sequence/ceph_test_rados_io_sequence.cc

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,15 @@ ceph::io_sequence::tester::lrc::SelectMappingAndLayers::SelectMappingAndLayers(
333333
sma{mapping_rng, vm, "mapping", first_use},
334334
sly{layers_rng, vm, "layers", first_use} {
335335
if (sma.isForced() != sly.isForced()) {
336-
ceph_abort_msg("Mapping and layers must be used together when one is used");
336+
std::string forced_parameter = "mapping";
337+
std::string unforced_parameter = "layers";
338+
if (sly.isForced()) {
339+
std::swap(forced_parameter, unforced_parameter);
340+
}
341+
342+
throw std::invalid_argument(fmt::format("The parameter --{} can only be used"
343+
" when a --{} parameter is also supplied.",
344+
forced_parameter, unforced_parameter));
337345
}
338346
}
339347

@@ -570,10 +578,9 @@ ceph::io_sequence::tester::SelectErasureProfile::SelectErasureProfile(
570578

571579
for (std::string& option : disallowed_options) {
572580
if (vm.count(option) > 0) {
573-
ceph_abort_msg(
574-
fmt::format("{} option not allowed "
575-
"if profile is specified",
576-
option));
581+
throw std::invalid_argument(fmt::format("{} option not allowed "
582+
"if profile is specified",
583+
option));
577584
}
578585
}
579586
}
@@ -653,7 +660,9 @@ ceph::io_sequence::tester::SelectErasureProfile::select() {
653660
instance.factory(std::string(profile.plugin),
654661
cct->_conf.get_val<std::string>("erasure_code_dir"),
655662
erasure_code_profile, &ec_impl, &ss);
656-
ceph_assert(ec_impl);
663+
if (!ec_impl) {
664+
throw std::runtime_error(ss.str());
665+
}
657666

658667
SelectErasureChunkSize scs{rng, vm, ec_impl, first_use};
659668
profile.chunk_size = scs.select();
@@ -799,10 +808,9 @@ ceph::io_sequence::tester::SelectErasurePool::SelectErasurePool(
799808

800809
for (std::string& option : disallowed_options) {
801810
if (vm.count(option) > 0) {
802-
ceph_abort_msg(
803-
fmt::format("{} option not allowed "
804-
"if pool is specified",
805-
option));
811+
throw std::invalid_argument(fmt::format("{} option not allowed "
812+
"if pool is specified",
813+
option));
806814
}
807815
}
808816
}
@@ -1401,10 +1409,16 @@ bool ceph::io_sequence::tester::TestRunner::run_automated_test() {
14011409
} else {
14021410
name = object_name + std::to_string(obj);
14031411
}
1404-
test_objects.push_back(
1405-
std::make_shared<ceph::io_sequence::tester::TestObject>(
1406-
name, rados, asio, sbs, spo, sos, snt, ssr, rng, lock, cond, dryrun,
1407-
verbose, seqseed, testrecovery));
1412+
try {
1413+
test_objects.push_back(
1414+
std::make_shared<ceph::io_sequence::tester::TestObject>(
1415+
name, rados, asio, sbs, spo, sos, snt, ssr, rng, lock, cond,
1416+
dryrun, verbose, seqseed, testrecovery));
1417+
}
1418+
catch (const std::runtime_error &e) {
1419+
std::cerr << "Error: " << e.what() << std::endl;
1420+
return false;
1421+
}
14081422
}
14091423
if (!dryrun) {
14101424
rados.wait_for_latest_osdmap();
@@ -1488,8 +1502,14 @@ int main(int argc, char** argv) {
14881502
std::make_unique<ceph::io_sequence::tester::TestRunner>(cct, vm, rados);
14891503
} catch (const po::error& e) {
14901504
return 1;
1505+
} catch (const std::invalid_argument& e) {
1506+
std::cerr << "Error: " << e.what() << std::endl;
1507+
return 1;
1508+
}
1509+
1510+
if (!runner->run_test()) {
1511+
return 1;
14911512
}
1492-
runner->run_test();
14931513

14941514
return 0;
14951515
}

0 commit comments

Comments
 (0)