From 154937005320f24f8d78310d4ffeac91571ac104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 22 Mar 2026 08:27:05 +0100 Subject: [PATCH] Address review feedback on hostgroups unit tests (PR #5506) - test_init.h: remove duplicate test_cleanup_query_processor() declaration (copy-paste artifact at line 130) - test_init.cpp: check MyHGM and PgHGM independently instead of using OR guard, so one can't be left null while the other exists --- test/tap/test_helpers/test_init.cpp | 24 ++++++++++++------------ test/tap/test_helpers/test_init.h | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/test/tap/test_helpers/test_init.cpp b/test/tap/test_helpers/test_init.cpp index b3af46f82..08261b2ef 100644 --- a/test/tap/test_helpers/test_init.cpp +++ b/test/tap/test_helpers/test_init.cpp @@ -173,24 +173,24 @@ void test_cleanup_query_processor() { // ============================================================================ int test_init_hostgroups() { - if (MyHGM != nullptr || PgHGM != nullptr) { - return 0; - } - // HostGroups Manager constructors register Prometheus metrics. if (GloVars.prometheus_registry == nullptr) { GloVars.prometheus_registry = std::make_shared(); } - MyHGM = new MySQL_HostGroups_Manager(); - // NOTE: We intentionally do NOT call MyHGM->init() here. - // init() starts background threads (HGCU_thread, GTID_syncer) - // that run forever and would cause the test process to hang on - // exit. The constructor alone sets up the internal SQLite3 - // database and all data structures needed for unit testing. + if (MyHGM == nullptr) { + MyHGM = new MySQL_HostGroups_Manager(); + // NOTE: We intentionally do NOT call MyHGM->init() here. + // init() starts background threads (HGCU_thread, GTID_syncer) + // that run forever and would cause the test process to hang on + // exit. The constructor alone sets up the internal SQLite3 + // database and all data structures needed for unit testing. + } - PgHGM = new PgSQL_HostGroups_Manager(); - // PgHGM->init() is a no-op, but we skip it for consistency. + if (PgHGM == nullptr) { + PgHGM = new PgSQL_HostGroups_Manager(); + // PgHGM->init() is a no-op, but we skip it for consistency. + } return 0; } diff --git a/test/tap/test_helpers/test_init.h b/test/tap/test_helpers/test_init.h index 6895630e3..5818bde0b 100644 --- a/test/tap/test_helpers/test_init.h +++ b/test/tap/test_helpers/test_init.h @@ -127,6 +127,5 @@ int test_init_hostgroups(); * Destroys MyHGM and PgHGM, setting them back to nullptr. */ void test_cleanup_hostgroups(); -void test_cleanup_query_processor(); #endif /* TEST_INIT_H */