From a8c216a635dc0dd65740e864b19f3ad199e9b3e5 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Thu, 27 Oct 2022 16:47:04 -0500 Subject: [PATCH] Merge pull request #3835 from simpsont-oci/bench_config_name [Bench] Give Name To Loaded Configuration To Avoid Static Build Issues (cherry picked from commit 0cef99cdcea049a2b55f61dd71dcab76d7bd7164) # Conflicts: # performance-tests/bench/worker/main.cpp --- performance-tests/bench/builder/BuilderProcess.cpp | 2 +- .../bench/builder/ConfigSectionManager.cpp | 4 +-- .../bench/builder/ConfigSectionManager.h | 2 +- performance-tests/bench/builder_idl/Builder.idl | 1 + performance-tests/bench/worker/main.cpp | 42 ++++++++++++---------- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/performance-tests/bench/builder/BuilderProcess.cpp b/performance-tests/bench/builder/BuilderProcess.cpp index 20636ba460..0406bb49c6 100644 --- a/performance-tests/bench/builder/BuilderProcess.cpp +++ b/performance-tests/bench/builder/BuilderProcess.cpp @@ -5,7 +5,7 @@ namespace Builder { BuilderProcess::BuilderProcess(const ProcessConfig& config) - : config_sections_(std::make_shared(config.config_sections)) + : config_sections_(std::make_shared(config.name.in(), config.config_sections)) , participants_(std::make_shared(config.participants, report_.participants, reader_map_, writer_map_, cft_map_)) { } diff --git a/performance-tests/bench/builder/ConfigSectionManager.cpp b/performance-tests/bench/builder/ConfigSectionManager.cpp index af215d609f..dd0c0e6672 100644 --- a/performance-tests/bench/builder/ConfigSectionManager.cpp +++ b/performance-tests/bench/builder/ConfigSectionManager.cpp @@ -8,7 +8,7 @@ namespace Builder { -ConfigSectionManager::ConfigSectionManager(const ConfigSectionSeq& seq) +ConfigSectionManager::ConfigSectionManager(const std::string& name, const ConfigSectionSeq& seq) { ACE_Configuration_Heap ach; ach.open(); @@ -40,7 +40,7 @@ ConfigSectionManager::ConfigSectionManager(const ConfigSectionSeq& seq) } } } - TheServiceParticipant->load_configuration(ach, ACE_TEXT("")); + TheServiceParticipant->load_configuration(ach, ACE_TEXT_CHAR_TO_TCHAR(name.c_str())); } } diff --git a/performance-tests/bench/builder/ConfigSectionManager.h b/performance-tests/bench/builder/ConfigSectionManager.h index a66c31ac0e..6deb0cacc2 100644 --- a/performance-tests/bench/builder/ConfigSectionManager.h +++ b/performance-tests/bench/builder/ConfigSectionManager.h @@ -6,7 +6,7 @@ namespace Builder { class ConfigSectionManager { public: - explicit ConfigSectionManager(const ConfigSectionSeq& seq); + ConfigSectionManager(const std::string& name, const ConfigSectionSeq& seq); }; } diff --git a/performance-tests/bench/builder_idl/Builder.idl b/performance-tests/bench/builder_idl/Builder.idl index 2d64b5eef5..51013946bf 100644 --- a/performance-tests/bench/builder_idl/Builder.idl +++ b/performance-tests/bench/builder_idl/Builder.idl @@ -396,6 +396,7 @@ module Builder { @topic struct ProcessConfig { + string name; ConfigSectionSeq config_sections; ParticipantConfigSeq participants; }; diff --git a/performance-tests/bench/worker/main.cpp b/performance-tests/bench/worker/main.cpp index 439cf5cb73..50a550bef6 100644 --- a/performance-tests/bench/worker/main.cpp +++ b/performance-tests/bench/worker/main.cpp @@ -103,26 +103,28 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { Builder::NullStream null_stream_i; std::ostream null_stream(&null_stream_i); - std::string log_file_path; - std::string report_file_path; - std::string config_file_path; + std::string log_file_fullname; + std::string report_file_fullname; + std::string config_file_fullname; + std::string config_file_basename; try { for (int i = 1; i < argc; i++) { const ACE_TCHAR* argument = argv[i]; if (!ACE_OS::strcmp(argv[i], ACE_TEXT("--log"))) { - log_file_path = get_option_argument(i, argc, argv); + log_file_fullname = get_option_argument(i, argc, argv); } else if (!ACE_OS::strcmp(argv[i], ACE_TEXT("--report"))) { - report_file_path = get_option_argument(i, argc, argv); - } else if (config_file_path.empty()) { - config_file_path = ACE_TEXT_ALWAYS_CHAR(argument); + report_file_fullname = get_option_argument(i, argc, argv); + } else if (config_file_fullname.empty()) { + config_file_fullname = ACE_TEXT_ALWAYS_CHAR(argument); + config_file_basename = ACE_TEXT_ALWAYS_CHAR(ACE::basename(argument)); } else { std::cerr << "Invalid option: " << argument << std::endl; return 1; } } - if (config_file_path.empty()) { + if (config_file_fullname.empty()) { std::cerr << "Must pass a configuration file" << std::endl; throw 1; } @@ -131,17 +133,17 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { return value; } - std::ifstream config_file(config_file_path); + std::ifstream config_file(config_file_fullname); if (!config_file.is_open()) { - std::cerr << "Unable to open configuration file: '" << config_file_path << "'" << std::endl; + std::cerr << "Unable to open configuration file: '" << config_file_fullname << "'" << std::endl; return 2; } std::ofstream log_file; - if (!log_file_path.empty()) { - log_file.open(log_file_path, ios::app); + if (!log_file_fullname.empty()) { + log_file.open(log_file_fullname, ios::app); if (!log_file.good()) { - std::cerr << "Unable to open log file: '" << log_file_path << "'" << std::endl; + std::cerr << "Unable to open log file: '" << log_file_fullname << "'" << std::endl; return 2; } Log::stream = &log_file; @@ -150,10 +152,10 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { } std::ofstream report_file; - if (!report_file_path.empty()) { - report_file.open(report_file_path); + if (!report_file_fullname.empty()) { + report_file.open(report_file_fullname); if (!report_file.good()) { - std::cerr << "Unable to open report file: '" << report_file_path << "'" << std::endl; + std::cerr << "Unable to open report file: '" << report_file_fullname << "'" << std::endl; return 2; } } @@ -174,6 +176,8 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { return 3; } + config.process.name = config_file_basename.c_str(); + // Bad-actor test & debugging options for node & test controllers Builder::ConstPropertyIndex force_worker_segfault_prop = @@ -277,8 +281,8 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { redirect_ace_log = static_cast(redirect_ace_log_prop->value.ull_prop()); } - if (redirect_ace_log && !log_file_path.empty()) { - std::ofstream* output_stream = new std::ofstream(log_file_path.c_str(), ios::app); + if (redirect_ace_log && !log_file_fullname.empty()) { + std::ofstream* output_stream = new std::ofstream(log_file_fullname.c_str(), ios::app); if (output_stream->bad()) { delete output_stream; } else { @@ -517,7 +521,7 @@ int ACE_TMAIN(int argc, ACE_TCHAR* argv[]) { // If requested, write out worker report to file - if (!report_file_path.empty()) { + if (!report_file_fullname.empty()) { idl_2_json(worker_report, report_file, max_decimal_places); } -- 2.11.4.GIT