tests/perf: provide random-seed option
Signed-off-by: Benny Halevy <bhalevy@scylladb.com> Message-Id: <20190613114307.31038-2-bhalevy@scylladb.com>
This commit is contained in:
@@ -853,8 +853,6 @@ tests_not_using_seastar_test_framework = set([
|
||||
'tests/perf/perf_hash',
|
||||
'tests/perf/perf_cql_parser',
|
||||
'tests/message',
|
||||
'tests/perf/perf_simple_query',
|
||||
'tests/perf/perf_fast_forward',
|
||||
'tests/perf/perf_cache_eviction',
|
||||
'tests/row_cache_stress_test',
|
||||
'tests/memory_footprint',
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "partition_slice_builder.hh"
|
||||
#include <seastar/core/reactor.hh>
|
||||
#include <seastar/core/units.hh>
|
||||
#include <seastar/testing/test_runner.hh>
|
||||
#include "sstables/compaction_manager.hh"
|
||||
#include "transport/messages/result_message.hh"
|
||||
#include "sstables/shared_index_lists.hh"
|
||||
@@ -1741,6 +1742,7 @@ auto make_compaction_disabling_guard(std::vector<table*> tables) {
|
||||
int main(int argc, char** argv) {
|
||||
namespace bpo = boost::program_options;
|
||||
app.add_options()
|
||||
("random-seed", boost::program_options::value<unsigned>(), "Random number generator seed")
|
||||
("run-tests", bpo::value<std::vector<std::string>>()->default_value(
|
||||
boost::copy_range<std::vector<std::string>>(
|
||||
test_groups | boost::adaptors::transformed([] (auto&& tc) { return tc.name; }))
|
||||
@@ -1824,7 +1826,17 @@ int main(int argc, char** argv) {
|
||||
|
||||
std::cout << "Data directory: " << db_cfg.data_file_directories() << "\n";
|
||||
|
||||
return do_with_cql_env([] (cql_test_env& env) {
|
||||
auto init = [] {
|
||||
auto conf_seed = app.configuration()["random-seed"];
|
||||
auto seed = conf_seed.empty() ? std::random_device()() : conf_seed.as<unsigned>();
|
||||
std::cout << "random-seed=" << seed << '\n';
|
||||
return smp::invoke_on_all([seed] {
|
||||
seastar::testing::local_random_engine.seed(seed + engine().cpu_id());
|
||||
});
|
||||
};
|
||||
|
||||
return init().then([db_cfg = std::move(db_cfg)] {
|
||||
return do_with_cql_env([] (cql_test_env& env) {
|
||||
return seastar::async([&env] {
|
||||
cql_env = &env;
|
||||
sstring name = app.configuration()["name"].as<std::string>();
|
||||
@@ -1908,5 +1920,6 @@ int main(int argc, char** argv) {
|
||||
}, db_cfg).then([] {
|
||||
return errors_found ? -1 : 0;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "tests/cql_test_env.hh"
|
||||
#include "tests/perf/perf.hh"
|
||||
#include <seastar/core/app-template.hh>
|
||||
#include <seastar/testing/test_runner.hh>
|
||||
#include "schema_builder.hh"
|
||||
#include "release.hh"
|
||||
|
||||
@@ -251,6 +252,7 @@ int main(int argc, char** argv) {
|
||||
namespace bpo = boost::program_options;
|
||||
app_template app;
|
||||
app.add_options()
|
||||
("random-seed", boost::program_options::value<unsigned>(), "Random number generator seed")
|
||||
("partitions", bpo::value<unsigned>()->default_value(10000), "number of partitions")
|
||||
("write", "test write path instead of read path")
|
||||
("delete", "test delete path instead of read path")
|
||||
@@ -263,7 +265,17 @@ int main(int argc, char** argv) {
|
||||
;
|
||||
|
||||
return app.run(argc, argv, [&app] {
|
||||
return do_with_cql_env([&app] (auto&& env) {
|
||||
auto init = [&app] {
|
||||
auto conf_seed = app.configuration()["random-seed"];
|
||||
auto seed = conf_seed.empty() ? std::random_device()() : conf_seed.as<unsigned>();
|
||||
std::cout << "random-seed=" << seed << '\n';
|
||||
return smp::invoke_on_all([seed] {
|
||||
seastar::testing::local_random_engine.seed(seed + engine().cpu_id());
|
||||
});
|
||||
};
|
||||
|
||||
return init().then([&app] {
|
||||
return do_with_cql_env([&app] (auto&& env) {
|
||||
auto cfg = test_config();
|
||||
cfg.partitions = app.configuration()["partitions"].as<unsigned>();
|
||||
cfg.duration_in_seconds = app.configuration()["duration"].as<unsigned>();
|
||||
@@ -297,6 +309,7 @@ int main(int argc, char** argv) {
|
||||
write_json_result(app.configuration()["json-result"].as<std::string>(), cfg, median, mad, max, min);
|
||||
}
|
||||
return make_ready_future<>();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <seastar/tests/perf/perf_tests.hh>
|
||||
#include <seastar/testing/test_runner.hh>
|
||||
|
||||
#include <random>
|
||||
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
: _integers(count)
|
||||
, _serialized(bytes::initialized_later{}, count * max_vint_length)
|
||||
{
|
||||
auto eng = std::default_random_engine{std::random_device{}()};
|
||||
auto eng = seastar::testing::local_random_engine;
|
||||
auto dist = std::uniform_int_distribution<uint64_t>{};
|
||||
std::generate_n(_integers.begin(), count, [&] { return dist(eng); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user