fix(test): test_mysqlx_plugin_load-t needs Phase B between load and init

Pre-existing test bug surfaced by CI-unit-tests-asan-coverage on
plugin-chassis (run 25202654334, head bb199c6c). 4 of 6 assertions
failed:

  not ok 3 - mysqlx_users registered in admin_db
  not ok 4 - mysqlx_users registered in config_db
  not ok 5 - mysqlx_users admin schema includes allowed_auth_methods
  not ok 6 - mysqlx_users config schema includes backend_auth_mode

Root cause: the mysqlx plugin (ABI 2+) registers its admin tables in
register_schemas() — Phase B of the four-phase lifecycle — not in
init() / Phase D. The test only does load() + init_all(), skipping
Phase B entirely, so mgr.tables(admin_db) and mgr.tables(config_db)
return empty vectors and find_table() returns nullptr for every
table-existence assertion.

The test was written before the four-phase lifecycle was finalised;
when mysqlx_register_admin_schema moved into Phase B (the Phase B
mysqlx_register_schemas wraps it; init_all() no longer touches the
admin-table-registration path), this test was not updated.

# Fix

Insert mgr.invoke_register_schemas_phase(err) between load() and
init_all(). For ABI-1 plugins that don't declare register_schemas
the call is a no-op (returns true with err empty). The plan goes
from 6 to 7 to cover the new assertion.

Verified locally:

  $ ./test_mysqlx_plugin_load-t
  1..7
  ok 1 - load mysqlx plugin succeeds
  ok 2 - invoke_register_schemas_phase registers mysqlx schema
  ok 3 - init_all completes after schema registration
  ok 4 - mysqlx_users registered in admin_db
  ok 5 - mysqlx_users registered in config_db
  ok 6 - mysqlx_users admin schema includes allowed_auth_methods
  ok 7 - mysqlx_users config schema includes backend_auth_mode

# Why now

This wasn't caught earlier because the same plugin-load assertions
were partially covered by sibling tests (test_mysqlx_admin_tables-t,
plugin_manager_unit-t) that drove the full Phase A→B→D lifecycle.
test_mysqlx_plugin_load-t was the only test with the load+init-only
shortcut. CI-unit-tests-asan-coverage on plugin-chassis is the
specific job that runs every *-t binary in test/tap/tests/unit (the
file lives in test/tap/tests/, not unit/, but groups.json registers
it with @proxysql_min_version:4.0 so the chassis gates are right).
fix/test-mysqlx-plugin-load-phase-b
Rene Cannao 4 weeks ago
parent f1587cf5c2
commit eebfbde2b3

@ -28,7 +28,7 @@ const ProxySQL_PluginTableDef* find_table(
} // namespace } // namespace
int main() { int main() {
plan(6); plan(7);
ProxySQL_PluginManager mgr; ProxySQL_PluginManager mgr;
std::string err {}; std::string err {};
@ -41,7 +41,20 @@ int main() {
BAIL_OUT("mysqlx plugin must load before schema assertions"); BAIL_OUT("mysqlx plugin must load before schema assertions");
} }
ok(mgr.init_all(err), "init_all registers mysqlx schema"); // Phase B: the mysqlx plugin (ABI 2+) registers its admin tables in
// register_schemas() rather than init(). Without this call the
// tables(kind) getters below return empty vectors regardless of
// init_all() succeeding. Plugins that opt out of Phase B (ABI 1)
// register everything in init_all(); for those the call below is a
// no-op (returns true with err empty).
ok(mgr.invoke_register_schemas_phase(err),
"invoke_register_schemas_phase registers mysqlx schema");
if (!err.empty()) {
diag("register_schemas error: %s", err.c_str());
err.clear();
}
ok(mgr.init_all(err), "init_all completes after schema registration");
if (!err.empty()) { if (!err.empty()) {
diag("init error: %s", err.c_str()); diag("init error: %s", err.c_str());
} }

Loading…
Cancel
Save