From 3576780f789d1c5f053afc75af8aefea54346dca Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 21 Aug 2018 09:37:40 +0300 Subject: [PATCH] MXS-2008 Update gateway and tests to initialize maxbase Update gateway and tests to initialize maxbase using maxbase::init(); instead of initializing individual components. --- query_classifier/test/CMakeLists.txt | 2 +- .../{crash_qc_sqlite.c => crash_qc_sqlite.cc} | 3 +++ server/core/gateway.cc | 16 ++++------------ server/core/test/test_modulecmd.cc | 5 +++-- server/core/test/test_utils.h | 6 ++---- .../monitor/mariadbmon/test/test_cycle_find.cc | 4 ++-- 6 files changed, 15 insertions(+), 21 deletions(-) rename query_classifier/test/{crash_qc_sqlite.c => crash_qc_sqlite.cc} (96%) diff --git a/query_classifier/test/CMakeLists.txt b/query_classifier/test/CMakeLists.txt index 617942c31..5310121b4 100644 --- a/query_classifier/test/CMakeLists.txt +++ b/query_classifier/test/CMakeLists.txt @@ -30,7 +30,7 @@ if (BUILD_QC_MYSQLEMBEDDED) add_executable(version_sensitivity version_sensitivity.cc) target_link_libraries(version_sensitivity maxscale-common) - add_executable(crash_qc_sqlite crash_qc_sqlite.c) + add_executable(crash_qc_sqlite crash_qc_sqlite.cc) target_link_libraries(crash_qc_sqlite maxscale-common) add_test(TestQC_Crash_qcsqlite crash_qc_sqlite) diff --git a/query_classifier/test/crash_qc_sqlite.c b/query_classifier/test/crash_qc_sqlite.cc similarity index 96% rename from query_classifier/test/crash_qc_sqlite.c rename to query_classifier/test/crash_qc_sqlite.cc index edf6fb95b..97a14150a 100644 --- a/query_classifier/test/crash_qc_sqlite.c +++ b/query_classifier/test/crash_qc_sqlite.cc @@ -12,6 +12,7 @@ */ #include +#include #include #include #include @@ -39,6 +40,8 @@ int main() { int rv = EXIT_FAILURE; + maxbase::MaxBase init(MXB_LOG_TARGET_FS); + set_libdir(strdup("../qc_sqlite")); if (qc_setup(NULL, QC_SQL_MODE_DEFAULT, "qc_sqlite", NULL) && diff --git a/server/core/gateway.cc b/server/core/gateway.cc index 5d8e9c7ab..a9508af92 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include #include @@ -1941,16 +1941,9 @@ int main(int argc, char **argv) MXS_NOTICE("Module directory: %s", get_libdir()); MXS_NOTICE("Service cache: %s", get_cachedir()); - if (!mxb::MessageQueue::init()) + if (!maxbase::init()) { - MXS_ERROR("Failed to initialize message queue."); - rc = MAXSCALE_INTERNALERROR; - goto return_main; - } - - if (!mxb::Worker::init()) - { - MXS_ERROR("Failed to initialize workers."); + MXS_ERROR("Failed to initialize MaxScale base library."); rc = MAXSCALE_INTERNALERROR; goto return_main; } @@ -2193,8 +2186,7 @@ int main(int argc, char **argv) service_destroy_instances(); RoutingWorker::finish(); - mxb::Worker::finish(); - mxb::MessageQueue::finish(); + maxbase::finish(); /*< Call finish on all modules. */ modules_process_finish(); diff --git a/server/core/test/test_modulecmd.cc b/server/core/test/test_modulecmd.cc index 3ca5c3d22..61f782a0e 100644 --- a/server/core/test/test_modulecmd.cc +++ b/server/core/test/test_modulecmd.cc @@ -15,7 +15,7 @@ * Test modulecmd.h functionality */ -#include +#include #include #include #include @@ -466,7 +466,7 @@ int main(int argc, char **argv) int rc = 0; mxs_log_init(NULL, NULL, MXS_LOG_TARGET_STDOUT); - mxb::MessageQueue::init(); + maxbase::init(); rc += test_arguments(); rc += test_optional_arguments(); @@ -477,6 +477,7 @@ int main(int argc, char **argv) rc += test_domain_matching("mariadbmon", "mysqlmon", "test_domain_matching2"); rc += test_output(); + maxbase::finish(); mxs_log_finish(); return rc; } diff --git a/server/core/test/test_utils.h b/server/core/test/test_utils.h index 941637d33..8820f665f 100644 --- a/server/core/test/test_utils.h +++ b/server/core/test/test_utils.h @@ -15,8 +15,7 @@ */ #include -#include -#include +#include #include #include #include @@ -48,8 +47,7 @@ void init_test_env(char *path) qc_setup(NULL, QC_SQL_MODE_DEFAULT, NULL, NULL); qc_process_init(QC_INIT_BOTH); poll_init(); - mxb::MessageQueue::init(); - mxb::Worker::init(); + maxbase::init(); maxscale::RoutingWorker::init(); hkinit(); } diff --git a/server/modules/monitor/mariadbmon/test/test_cycle_find.cc b/server/modules/monitor/mariadbmon/test/test_cycle_find.cc index 2c7fcf058..176cc4521 100644 --- a/server/modules/monitor/mariadbmon/test/test_cycle_find.cc +++ b/server/modules/monitor/mariadbmon/test/test_cycle_find.cc @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -70,7 +70,7 @@ private: int main() { - mxb::MessageQueue::init(); + maxbase::init(); MariaDBMonitor::Test tester; return tester.run_tests();