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
pull/5506/head
René Cannaò 1 month ago
parent e4972ac739
commit 1549370053

@ -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<prometheus::Registry>();
}
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;
}

@ -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 */

Loading…
Cancel
Save