#include #include #include "Runner.h" #include "Common/Exception.h" #include #include #include namespace { template std::optional valueToOptional(const boost::program_options::variable_value & value) { if (value.empty()) return std::nullopt; return value.as(); } } int mainEntryClickHouseKeeperBench(int argc, char ** argv) { bool print_stacktrace = true; //Poco::AutoPtr channel(new Poco::ConsoleChannel(std::cerr)); //Poco::Logger::root().setChannel(channel); //Poco::Logger::root().setLevel("trace"); try { using boost::program_options::value; boost::program_options::options_description desc = createOptionsDescription("Allowed options", getTerminalWidth()); desc.add_options() ("help", "produce help message") ("config", value()->default_value(""), "yaml/xml file containing configuration") ("input-request-log", value()->default_value(""), "log of requests that will be replayed") ("setup-nodes-snapshot-path", value()->default_value(""), "directory containing snapshots with starting state") ("concurrency,c", value(), "number of parallel queries") ("report-delay,d", value(), "delay between intermediate reports in seconds (set 0 to disable reports)") ("iterations,i", value(), "amount of queries to be executed") ("time-limit,t", value(), "stop launch of queries after specified time limit") ("hosts,h", value()->multitoken()->default_value(Strings{}, ""), "") ("continue_on_errors", "continue testing even if a query fails") ; boost::program_options::variables_map options; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), options); boost::program_options::notify(options); if (options.count("help")) { std::cout << "Usage: " << argv[0] << " [options] < queries.txt\n"; std::cout << desc << "\n"; return 1; } Runner runner(valueToOptional(options["concurrency"]), options["config"].as(), options["input-request-log"].as(), options["setup-nodes-snapshot-path"].as(), options["hosts"].as(), valueToOptional(options["time-limit"]), valueToOptional(options["report-delay"]), options.count("continue_on_errors") ? std::optional(true) : std::nullopt, valueToOptional(options["iterations"])); try { runner.runBenchmark(); } catch (...) { std::cout << "Got exception while trying to run benchmark: " << DB::getCurrentExceptionMessage(true) << std::endl; } return 0; } catch (...) { std::cerr << DB::getCurrentExceptionMessage(print_stacktrace, true) << std::endl; return DB::getCurrentExceptionCode(); } }