test(mysqlx): add runtime_mysqlx_variables to config-store test fixture

MysqlxConfigStore::load_from_runtime issues five fetch_result queries
in sequence and returns false (leaving the store empty) if any one
fails. One of those queries — SELECT FROM runtime_mysqlx_variables —
hit a table that create_test_db() never created, so every scenario
that depended on data actually being loaded silently short-circuited
before the swap.

Effect: eight assertions in mysqlx_config_store_pure_unit-t.cpp were
quietly failing under the pre-existing plan(25) — none of the tests
that exercised a loaded identity, route, or endpoint were actually
verifying the production code, because identities_/routes_/
hostgroup_endpoints_ were never populated.

Adding the DDL fixes all eight. No production changes; test harness
only.
ProtocolX
Rene Cannao 1 month ago
parent c32c2fed35
commit 017496bc45

@ -46,6 +46,16 @@ const char kRuntimeMysqlxEndpointsDdl[] =
" PRIMARY KEY (hostname, mysql_port)"
" )";
// load_from_runtime also queries runtime_mysqlx_variables. Without the table
// fetch_result returns false and the load short-circuits before swapping in
// the newly-loaded routes/identities, silently breaking every scenario in
// this file that depended on data actually being loaded.
const char kRuntimeMysqlxVariablesDdl[] =
"CREATE TABLE runtime_mysqlx_variables ("
" variable_name VARCHAR NOT NULL PRIMARY KEY,"
" variable_value VARCHAR NOT NULL DEFAULT ''"
" )";
std::unique_ptr<SQLite3DB> create_test_db() {
auto db = std::make_unique<SQLite3DB>();
db->open((char*)":memory:", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX);
@ -54,6 +64,7 @@ std::unique_ptr<SQLite3DB> create_test_db() {
db->execute(kRuntimeMysqlxUsersDdl);
db->execute(kRuntimeMysqlxRoutesDdl);
db->execute(kRuntimeMysqlxEndpointsDdl);
db->execute(kRuntimeMysqlxVariablesDdl);
return db;
}

Loading…
Cancel
Save