From cfdc64d7cf05047f5fe2a0b40babe9c12dd4f3cb Mon Sep 17 00:00:00 2001 From: Mike Ellery Date: Tue, 8 May 2018 08:46:31 -0700 Subject: [PATCH] Enable manual tests in CI: Fixes: RIPD-1575. Fix argument passing to runner. Allow multiple unit test selectors to be passed via --unittest argument. Add optional integer priority value to test suite list. Fix several failing manual tests. Update CLI usage message to make it clearer. --- Jenkinsfile | 5 +- bin/ci/ubuntu/build-and-test.sh | 28 +++- .../extras/beast/unit_test/global_suites.hpp | 4 +- src/beast/extras/beast/unit_test/suite.hpp | 15 +- .../extras/beast/unit_test/suite_info.hpp | 14 +- .../extras/beast/unit_test/suite_list.hpp | 8 +- src/ripple/app/main/Main.cpp | 149 ++++++++++++++---- src/test/README.md | 30 ++++ src/test/app/CrossingLimits_test.cpp | 2 +- src/test/app/Flow_test.cpp | 4 +- src/test/app/Offer_test.cpp | 4 +- src/test/app/OversizeMeta_test.cpp | 6 +- src/test/app/PayStrand_test.cpp | 2 +- src/test/app/TrustAndBalance_test.cpp | 2 +- src/test/app/TxQ_test.cpp | 2 +- .../DistributedValidatorsSim_test.cpp | 2 +- src/test/consensus/ScaleFreeSim_test.cpp | 2 +- src/test/ledger/Directory_test.cpp | 2 +- src/test/nodestore/Timing_test.cpp | 8 +- src/test/nodestore/import_test.cpp | 2 +- src/test/protocol/digest_test.cpp | 2 +- src/test/rpc/Book_test.cpp | 2 +- src/test/rpc/LedgerData_test.cpp | 2 +- src/test/rpc/NoRippleCheck_test.cpp | 18 ++- src/test/unit_test/multi_runner.h | 28 +--- 25 files changed, 243 insertions(+), 100 deletions(-) create mode 100644 src/test/README.md diff --git a/Jenkinsfile b/Jenkinsfile index 4b2451e981..91722d68fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -89,6 +89,7 @@ try { stage ('Parallel Build') { String[][] variants = [ + ['gcc.release.unity', '-Dassert=true', 'MANUAL_TESTS=true'], ['coverage'], ['docs'], ['msvc.debug'], @@ -101,8 +102,8 @@ try { ['clang.debug.nounity'], ['gcc.debug.unity'], ['gcc.debug.nounity'], - ['clang.release.unity'], - ['gcc.release.unity'], + ['clang.release.unity', '-Dassert=true'], + ['gcc.release.unity', '-Dassert=true'], // add a static build just to make sure it works ['gcc.debug.unity', '-Dstatic=true'], // TODO - sanitizer runs currently fail diff --git a/bin/ci/ubuntu/build-and-test.sh b/bin/ci/ubuntu/build-and-test.sh index 21ceda00a9..9165d12c53 100755 --- a/bin/ci/ubuntu/build-and-test.sh +++ b/bin/ci/ubuntu/build-and-test.sh @@ -96,8 +96,34 @@ echo "using APP_PATH: $APP_PATH" # See what we've actually built ldd $APP_PATH +function join_by { local IFS="$1"; shift; echo "$*"; } + +# This is a list of manual tests +# in rippled that we want to run +declare -a manual_tests=( + "beast.chrono.abstract_clock" + "beast.unit_test.print" + "ripple.NodeStore.Timing" + "ripple.app.Flow_manual" + "ripple.app.NoRippleCheckLimits" + "ripple.app.PayStrandAllPairs" + "ripple.consensus.ByzantineFailureSim" + "ripple.consensus.DistributedValidators" + "ripple.consensus.ScaleFreeSim" + "ripple.ripple_data.digest" + "ripple.tx.CrossingLimits" + "ripple.tx.FindOversizeCross" + "ripple.tx.Offer_manual" + "ripple.tx.OversizeMeta" + "ripple.tx.PlumpBook" +) + if [[ ${APP} == "rippled" ]]; then - APP_ARGS+="--unittest --quiet --unittest-log" + if [[ ${MANUAL_TESTS:-} == true ]]; then + APP_ARGS+="--unittest=$(join_by , "${manual_tests[@]}")" + else + APP_ARGS+="--unittest --quiet --unittest-log" + fi # Only report on src/ripple files export LCOV_FILES="*/src/ripple/*" # Nothing to explicitly exclude diff --git a/src/beast/extras/beast/unit_test/global_suites.hpp b/src/beast/extras/beast/unit_test/global_suites.hpp index 90664da494..3fbf79589f 100644 --- a/src/beast/extras/beast/unit_test/global_suites.hpp +++ b/src/beast/extras/beast/unit_test/global_suites.hpp @@ -28,10 +28,10 @@ template struct insert_suite { insert_suite(char const* name, char const* module, - char const* library, bool manual) + char const* library, bool manual, int priority) { global_suites().insert( - name, module, library, manual); + name, module, library, manual, priority); } }; diff --git a/src/beast/extras/beast/unit_test/suite.hpp b/src/beast/extras/beast/unit_test/suite.hpp index 571a910b64..90183e95b4 100644 --- a/src/beast/extras/beast/unit_test/suite.hpp +++ b/src/beast/extras/beast/unit_test/suite.hpp @@ -627,10 +627,10 @@ run(runner& r) // detail: // This inserts the suite with the given manual flag -#define BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual) \ +#define BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual,priority) \ static beast::unit_test::detail::insert_suite \ Library ## Module ## Class ## _test_instance( \ - #Class, #Module, #Library, manual) + #Class, #Module, #Library, manual, priority) //------------------------------------------------------------------------------ @@ -675,14 +675,19 @@ run(runner& r) #if BEAST_NO_UNIT_TEST_INLINE #define BEAST_DEFINE_TESTSUITE(Class,Module,Library) #define BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) +#define BEAST_DEFINE_TESTSUITE_PRIO(Class,Module,Library,Priority) +#define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class,Module,Library,Priority) #else #include #define BEAST_DEFINE_TESTSUITE(Class,Module,Library) \ - BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false) + BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false,0) #define BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) \ - BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true) - + BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true,0) +#define BEAST_DEFINE_TESTSUITE_PRIO(Class,Module,Library,Priority) \ + BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false,Priority) +#define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class,Module,Library,Priority) \ + BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true,Priority) #endif #endif diff --git a/src/beast/extras/beast/unit_test/suite_info.hpp b/src/beast/extras/beast/unit_test/suite_info.hpp index 6baf2c47b3..0131fb9028 100644 --- a/src/beast/extras/beast/unit_test/suite_info.hpp +++ b/src/beast/extras/beast/unit_test/suite_info.hpp @@ -27,6 +27,7 @@ class suite_info std::string module_; std::string library_; bool manual_; + int priority_; run_type run_; public: @@ -35,11 +36,13 @@ public: std::string module, std::string library, bool manual, + int priority, run_type run) : name_(std::move(name)) , module_(std::move(module)) , library_(std::move(library)) , manual_(manual) + , priority_(priority) , run_(std::move(run)) { } @@ -87,9 +90,10 @@ public: bool operator<(suite_info const& lhs, suite_info const& rhs) { - return - std::tie(lhs.library_, lhs.module_, lhs.name_) < - std::tie(rhs.library_, rhs.module_, rhs.name_); + // we want higher priority suites sorted first, thus the negation + // of priority value here + return std::forward_as_tuple(-lhs.priority_, lhs.library_, lhs.module_, lhs.name_) < + std::forward_as_tuple(-rhs.priority_, rhs.library_, rhs.module_, rhs.name_); } }; @@ -102,13 +106,15 @@ make_suite_info( std::string name, std::string module, std::string library, - bool manual) + bool manual, + int priority) { return suite_info( std::move(name), std::move(module), std::move(library), manual, + priority, [](runner& r) { Suite{}(r); diff --git a/src/beast/extras/beast/unit_test/suite_list.hpp b/src/beast/extras/beast/unit_test/suite_list.hpp index e22817708f..41526a2d05 100644 --- a/src/beast/extras/beast/unit_test/suite_list.hpp +++ b/src/beast/extras/beast/unit_test/suite_list.hpp @@ -39,7 +39,8 @@ public: char const* name, char const* module, char const* library, - bool manual); + bool manual, + int priority); }; //------------------------------------------------------------------------------ @@ -50,7 +51,8 @@ suite_list::insert( char const* name, char const* module, char const* library, - bool manual) + bool manual, + int priority) { #ifndef NDEBUG { @@ -67,7 +69,7 @@ suite_list::insert( } #endif cont().emplace(make_suite_info( - name, module, library, manual)); + name, module, library, manual, priority)); } } // unit_test diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index dcce0a563f..56c69c285f 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -182,6 +182,40 @@ void printHelp (const po::options_description& desc) //------------------------------------------------------------------------------ +/* simple unit test selector that allows a comma separated list + * of selectors + */ +class multi_selector +{ +private: + std::vector selectors_; +public: + explicit + multi_selector(std::string const& patterns = "") + { + std::vector v; + boost::split (v, patterns, boost::algorithm::is_any_of (",")); + selectors_.reserve(v.size()); + std::for_each(v.begin(), v.end(), + [this](std::string s) + { + boost::trim (s); + if (selectors_.empty() || !s.empty()) + selectors_.emplace_back( + beast::unit_test::selector::automatch, s); + }); + } + + bool + operator()(beast::unit_test::suite_info const& s) + { + for (auto& sel : selectors_) + if (sel(s)) + return true; + return false; + } +}; + static int runUnitTests( std::string const& pattern, std::string const& argument, @@ -202,7 +236,8 @@ static int runUnitTests( multi_runner_parent parent_runner; multi_runner_child child_runner{num_jobs, quiet, log}; - auto const any_failed = child_runner.run_multi(match_auto(pattern)); + child_runner.arg(argument); + auto const any_failed = child_runner.run_multi(multi_selector(pattern)); if (any_failed) return EXIT_FAILURE; @@ -251,7 +286,8 @@ static int runUnitTests( { // child multi_runner_child runner{num_jobs, quiet, log}; - auto const anyFailed = runner.run_multi(match_auto(pattern)); + runner.arg(argument); + auto const anyFailed = runner.run_multi(multi_selector(pattern)); if (anyFailed) return EXIT_FAILURE; @@ -291,50 +327,99 @@ int run (int argc, char** argv) // Set up option parsing. // - po::options_description desc ("General Options"); - desc.add_options () - ("help,h", "Display this message.") + po::options_description gen ("General Options"); + gen.add_options () ("conf", po::value (), "Specify the configuration file.") - ("rpc", "Perform rpc command (default).") - ("rpc_ip", po::value (), "Specify the IP address for RPC command. Format: [':']") - ("rpc_port", po::value (), "Specify the port number for RPC command.") - ("standalone,a", "Run with no peers.") - ("unittest,u", po::value ()->implicit_value (""), "Perform unit tests.") - ("unittest-arg", po::value ()->implicit_value (""), "Supplies argument to unit tests.") - ("unittest-log", po::value ()->implicit_value (""), "Force unit test log output, even in quiet mode.") -#if HAS_BOOST_PROCESS - ("unittest-jobs", po::value (), "Number of unittest jobs to run.") - ("unittest-child", "For internal use only. Run the process as a unit test child process.") -#endif - ("parameters", po::value< vector > (), "Specify comma separated parameters.") - ("quiet,q", "Reduce diagnotics.") - ("quorum", po::value (), "Override the minimum validation quorum.") - ("silent", "No output to the console after startup.") - ("verbose,v", "Verbose logging.") - ("load", "Load the current ledger from the local DB.") - ("valid", "Consider the initial ledger a valid network ledger.") - ("replay","Replay a ledger close.") - ("ledger", po::value (), "Load the specified ledger and start from .") - ("ledgerfile", po::value (), "Load the specified ledger file.") - ("start", "Start from a fresh Ledger.") - ("net", "Get the initial ledger from the network.") ("debug", "Enable normally suppressed debug logging") ("fg", "Run in the foreground.") - ("import", importText.c_str ()) - ("nodetoshard", "Import node store into shards") - ("validateShards", shardsText.c_str ()) + ("help,h", "Display this message.") + ("quorum", po::value (), + "Override the minimum validation quorum.") + ("silent", "No output to the console after startup.") + ("standalone,a", "Run with no peers.") + ("verbose,v", "Verbose logging.") ("version", "Display the build version.") ; + po::options_description data ("Ledger/Data Options"); + data.add_options () + ("import", importText.c_str ()) + ("ledger", po::value (), + "Load the specified ledger and start from the value given.") + ("ledgerfile", po::value (), "Load the specified ledger file.") + ("load", "Load the current ledger from the local DB.") + ("net", "Get the initial ledger from the network.") + ("nodetoshard", "Import node store into shards") + ("replay","Replay a ledger close.") + ("start", "Start from a fresh Ledger.") + ("valid", "Consider the initial ledger a valid network ledger.") + ("validateShards", shardsText.c_str ()) + ; + + po::options_description rpc ("RPC Client Options"); + rpc.add_options() + ("rpc", + "Perform rpc command - see below for available commands. " + "This is assumed if any positional parameters are provided.") + ("rpc_ip", po::value (), + "Specify the IP address for RPC command. " + "Format: [':']") + ("rpc_port", po::value (), + "Specify the port number for RPC command.") + ; + + po::options_description test ("Unit Test Options"); + test.add_options() + ("quiet,q", + "Suppress test suite messages, " + "including suite/case name (at start) and test log messages.") + ("unittest,u", po::value ()->implicit_value (""), + "Perform unit tests. The optional argument specifies one or " + "more comma-separated selectors. Each selector specifies a suite name, " + "full-name (lib.module.suite), module, or library " + "(checked in that ""order).") + ("unittest-arg", po::value ()->implicit_value (""), + "Supplies an argument string to unit tests. If provided, this argument " + "is made available to each suite that runs. Interpretation of the " + "argument is handled individually by any suite that accesses it -- " + "as such, it typically only make sense to provide this when running " + "a single suite.") + ("unittest-log", + "Force unit test log message output. Only useful in combination with " + "--quiet, in which case log messages will print but suite/case names " + "will not.") +#if HAS_BOOST_PROCESS + ("unittest-jobs", po::value (), + "Number of unittest jobs to run in parallel (child processes).") +#endif + ; + + // These are hidden options, not intended to be shown in the usage/help message + po::options_description hidden ("Hidden Options"); + hidden.add_options() + ("parameters", po::value< vector > (), + "Specify rpc command and parameters. This option must be repeated " + "for each command/param. Positional parameters also serve this purpose, " + "so this option is not needed for users") + ("unittest-child", + "For internal use only when spawning child unit test processes.") + ; + // Interpret positional arguments as --parameters. po::positional_options_description p; p.add ("parameters", -1); + po::options_description all; + all.add(gen).add(rpc).add(data).add(test).add(hidden); + + po::options_description desc; + desc.add(gen).add(rpc).add(data).add(test); + // Parse options, if no error. try { po::store (po::command_line_parser (argc, argv) - .options (desc) // Parse options. + .options (all) // Parse options. .positional (p) // Remainder as --parameters. .run (), vm); diff --git a/src/test/README.md b/src/test/README.md new file mode 100644 index 0000000000..7d342f24bf --- /dev/null +++ b/src/test/README.md @@ -0,0 +1,30 @@ + +# Unit Tests + +## Running Tests + +Unit tests are bundled in the `rippled` executable and can be executed using the +`--unittest` parameter. Without any arguments to this option, all non-manual +unit tests will be executed. If you want to run one or more manual tests, you +must specify it by suite or full-name (e.g. `ripple.app.NoRippleCheckLimits` or +just `NoRippleCheckLimits`). + +More than one suite or group of suites can be specified as a comma separated +list via the argument. For example, `--unittest=beast,OversizeMeta` will run +all suites in the `beast` library (root identifier) as well as the test suite +named `OversizeMeta`). All name matches are case sensitive. + +Tests can be executed in parallel using several child processes by specifying +the `--unittest-jobs=N` parameter. The default behavior is to execute serially +using a single process. + +The order that suites are executed is determined by the suite priority that +is optionally specified when the suite is declared in the code with one of the +`BEAST_DEFINE_TESTSUITE` macros. By default, suites have a priority of 0, and +other suites can choose to declare an integer priority value to make themselves +execute before or after other suites based on their specified priority value. + +By default, the framework will emit the name of each testcase/testsuite when it +starts and any messages sent to the suite `log` stream. The `--quiet` option will +suppress both types of messages, but combining `--unittest-log` with `--quiet` +will cause `log` messages to be emitted while suite/case names are suppressed. diff --git a/src/test/app/CrossingLimits_test.cpp b/src/test/app/CrossingLimits_test.cpp index f05aa3d4d8..377437e7f0 100644 --- a/src/test/app/CrossingLimits_test.cpp +++ b/src/test/app/CrossingLimits_test.cpp @@ -274,7 +274,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE_MANUAL(CrossingLimits,tx,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(CrossingLimits,tx,ripple,10); } // test } // ripple diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 081064e775..e511b8d1a7 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -1322,8 +1322,8 @@ struct Flow_manual_test : public Flow_test } }; -BEAST_DEFINE_TESTSUITE(Flow,app,ripple); -BEAST_DEFINE_TESTSUITE_MANUAL(Flow_manual,app,ripple); +BEAST_DEFINE_TESTSUITE_PRIO(Flow,app,ripple,2); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Flow_manual,app,ripple,4); } // test } // ripple diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index 48d5b322f8..0624c2863f 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -4658,8 +4658,8 @@ class Offer_manual_test : public Offer_test } }; -BEAST_DEFINE_TESTSUITE (Offer, tx, ripple); -BEAST_DEFINE_TESTSUITE_MANUAL (Offer_manual, tx, ripple); +BEAST_DEFINE_TESTSUITE_PRIO (Offer, tx, ripple, 4); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO (Offer_manual, tx, ripple, 20); } // test } // ripple diff --git a/src/test/app/OversizeMeta_test.cpp b/src/test/app/OversizeMeta_test.cpp index a50d13716a..6dc334277a 100644 --- a/src/test/app/OversizeMeta_test.cpp +++ b/src/test/app/OversizeMeta_test.cpp @@ -62,7 +62,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE_MANUAL(PlumpBook,tx,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(PlumpBook,tx,ripple,5); //------------------------------------------------------------------------------ @@ -121,7 +121,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE_MANUAL(OversizeMeta,tx,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(OversizeMeta,tx,ripple,3); //------------------------------------------------------------------------------ @@ -189,7 +189,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE_MANUAL(FindOversizeCross,tx,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(FindOversizeCross,tx,ripple,50); } // test } // ripple diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 7a39cf5861..0aafb08c44 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -852,7 +852,7 @@ struct PayStrandAllPairs_test : public beast::unit_test::suite } }; -BEAST_DEFINE_TESTSUITE_MANUAL(PayStrandAllPairs, app, ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(PayStrandAllPairs, app, ripple, 12); struct PayStrand_test : public beast::unit_test::suite { diff --git a/src/test/app/TrustAndBalance_test.cpp b/src/test/app/TrustAndBalance_test.cpp index b07db538e2..fd710f9484 100644 --- a/src/test/app/TrustAndBalance_test.cpp +++ b/src/test/app/TrustAndBalance_test.cpp @@ -515,7 +515,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE (TrustAndBalance, app, ripple); +BEAST_DEFINE_TESTSUITE_PRIO (TrustAndBalance, app, ripple, 1); } // ripple diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 1d8035f557..1228d05c79 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -2801,7 +2801,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE(TxQ,app,ripple); +BEAST_DEFINE_TESTSUITE_PRIO(TxQ,app,ripple,1); } } diff --git a/src/test/consensus/DistributedValidatorsSim_test.cpp b/src/test/consensus/DistributedValidatorsSim_test.cpp index 558ead706e..a406fd4b0f 100644 --- a/src/test/consensus/DistributedValidatorsSim_test.cpp +++ b/src/test/consensus/DistributedValidatorsSim_test.cpp @@ -266,7 +266,7 @@ class DistributedValidators_test : public beast::unit_test::suite } }; -BEAST_DEFINE_TESTSUITE_MANUAL(DistributedValidators, consensus, ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(DistributedValidators, consensus, ripple, 2); } // namespace test } // namespace ripple diff --git a/src/test/consensus/ScaleFreeSim_test.cpp b/src/test/consensus/ScaleFreeSim_test.cpp index 605e9d0caf..1163a28f80 100644 --- a/src/test/consensus/ScaleFreeSim_test.cpp +++ b/src/test/consensus/ScaleFreeSim_test.cpp @@ -116,7 +116,7 @@ class ScaleFreeSim_test : public beast::unit_test::suite } }; -BEAST_DEFINE_TESTSUITE_MANUAL(ScaleFreeSim, consensus, ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(ScaleFreeSim, consensus, ripple, 80); } // namespace test } // namespace ripple diff --git a/src/test/ledger/Directory_test.cpp b/src/test/ledger/Directory_test.cpp index 712c93576d..c1287b1be8 100644 --- a/src/test/ledger/Directory_test.cpp +++ b/src/test/ledger/Directory_test.cpp @@ -441,7 +441,7 @@ struct Directory_test : public beast::unit_test::suite } }; -BEAST_DEFINE_TESTSUITE(Directory,ledger,ripple); +BEAST_DEFINE_TESTSUITE_PRIO(Directory,ledger,ripple,1); } } diff --git a/src/test/nodestore/Timing_test.cpp b/src/test/nodestore/Timing_test.cpp index f674833d3d..ebf87c2f4f 100644 --- a/src/test/nodestore/Timing_test.cpp +++ b/src/test/nodestore/Timing_test.cpp @@ -83,14 +83,16 @@ private: beast::xor_shift_engine gen_; std::uint8_t prefix_; - std::uniform_int_distribution d_type_; + std::discrete_distribution d_type_; std::uniform_int_distribution d_size_; public: explicit Sequence(std::uint8_t prefix) : prefix_ (prefix) - , d_type_ (hotLEDGER, hotTRANSACTION_NODE) + // uniform distribution over hotLEDGER - hotTRANSACTION_NODE + // but exclude hotTRANSACTION = 2 (removed) + , d_type_ ({1, 1, 0, 1, 1}) , d_size_ (minSize, maxSize) { } @@ -744,7 +746,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE_MANUAL(Timing,NodeStore,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Timing,NodeStore,ripple,1); } } diff --git a/src/test/nodestore/import_test.cpp b/src/test/nodestore/import_test.cpp index 5121d2bfd9..b0e8e8712b 100644 --- a/src/test/nodestore/import_test.cpp +++ b/src/test/nodestore/import_test.cpp @@ -585,7 +585,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE(import,NodeStore,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL(import,NodeStore,ripple); #endif diff --git a/src/test/protocol/digest_test.cpp b/src/test/protocol/digest_test.cpp index 690a18d1a5..efcf32d1d5 100644 --- a/src/test/protocol/digest_test.cpp +++ b/src/test/protocol/digest_test.cpp @@ -156,6 +156,6 @@ public: } }; -BEAST_DEFINE_TESTSUITE_MANUAL(digest,ripple_data,ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(digest,ripple_data,ripple,20); } // ripple diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index 721deddc92..35328eaa66 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -1647,7 +1647,7 @@ public: } }; -BEAST_DEFINE_TESTSUITE(Book,app,ripple); +BEAST_DEFINE_TESTSUITE_PRIO(Book,app,ripple,1); } // test } // ripple diff --git a/src/test/rpc/LedgerData_test.cpp b/src/test/rpc/LedgerData_test.cpp index 91b8ac4c54..3ccfc03574 100644 --- a/src/test/rpc/LedgerData_test.cpp +++ b/src/test/rpc/LedgerData_test.cpp @@ -448,6 +448,6 @@ public: } }; -BEAST_DEFINE_TESTSUITE(LedgerData,app,ripple); +BEAST_DEFINE_TESTSUITE_PRIO(LedgerData,app,ripple,1); } diff --git a/src/test/rpc/NoRippleCheck_test.cpp b/src/test/rpc/NoRippleCheck_test.cpp index 74a86f5c28..8bb5692817 100644 --- a/src/test/rpc/NoRippleCheck_test.cpp +++ b/src/test/rpc/NoRippleCheck_test.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -273,9 +274,20 @@ class NoRippleCheckLimits_test : public beast::unit_test::suite {steady_clock::now()}; } } + + auto& txq = env.app().getTxQ(); auto const gw = Account {"gw" + std::to_string(i)}; - env.fund (XRP (1000), gw); - env (trust (alice, gw["USD"](10))); + env.memoize(gw); + env (pay (env.master, gw, XRP(1000)), + seq (autofill), + fee (txq.getMetrics(*env.current())->expFeeLevel + 1), + sig (autofill)); + env (fset (gw, asfDefaultRipple), + seq (autofill), + fee (txq.getMetrics(*env.current())->expFeeLevel + 1), + sig (autofill)); + env (trust (alice, gw["USD"](10)), + fee (txq.getMetrics(*env.current())->expFeeLevel + 1)); env.close(); } @@ -328,7 +340,7 @@ BEAST_DEFINE_TESTSUITE(NoRippleCheck, app, ripple); // offer/account setup, so making them manual -- the additional coverage provided // by them is minimal -BEAST_DEFINE_TESTSUITE_MANUAL(NoRippleCheckLimits, app, ripple); +BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(NoRippleCheckLimits, app, ripple, 1); } // ripple diff --git a/src/test/unit_test/multi_runner.h b/src/test/unit_test/multi_runner.h index 068b8d4056..15edd39ca9 100644 --- a/src/test/unit_test/multi_runner.h +++ b/src/test/unit_test/multi_runner.h @@ -285,32 +285,6 @@ multi_runner_child::run_multi(Pred pred) { auto const& suite = beast::unit_test::global_suites(); auto const num_tests = suite.size(); - // actual order to run the tests. Use this to move longer running tests to - // the beginning to better take advantage of a multi process run. - std::vector order(num_tests); - std::iota(order.begin(), order.end(), 0); - { - std::unordered_set prioritize{ - "ripple.app.Flow", "ripple.tx.Offer"}; - std::vector to_swap; - to_swap.reserve(prioritize.size()); - - size_t i = 0; - for (auto const& t : suite) - { - auto const full_name = t.full_name(); - if (prioritize.count(full_name)) - { - to_swap.push_back(i); - if (to_swap.size() == prioritize.size()) - break; - } - ++i; - } - - for (std::size_t i = 0; i < to_swap.size(); ++i) - std::swap(order[to_swap[i]], order[i]); - } bool failed = false; auto get_test = [&]() -> beast::unit_test::suite_info const* { @@ -318,7 +292,7 @@ multi_runner_child::run_multi(Pred pred) if (cur_test_index >= num_tests) return nullptr; auto iter = suite.begin(); - std::advance(iter, order[cur_test_index]); + std::advance(iter, cur_test_index); return &*iter; }; while (auto t = get_test())