Fix unit tests that use durations

The tests that used objects that expected a default value for a duration
failed due to missing parameters.
This commit is contained in:
Markus Mäkelä 2019-05-06 05:19:38 +03:00
parent 24df547ac8
commit 20a7170024
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
5 changed files with 37 additions and 16 deletions

View File

@ -50,7 +50,10 @@ static int test1()
DCB* dcb;
/* Single buffer tests */
fprintf(stderr, "testdcb : creating buffer with type DCB::Role::INTERNAL");
auto service = service_alloc("service", "readconnroute", nullptr);
MXS_CONFIG_PARAMETER parameters;
parameters.set("max_retry_interval", "10s");
parameters.set("connection_timeout", "10s");
auto service = service_alloc("service", "readconnroute", &parameters);
auto listener = Listener::create(service, "listener", "mariadbclient", "0.0.0.0", 3306, "", "", nullptr);
auto session = new mxs::Session(listener);
dcb = dcb_alloc(DCB::Role::INTERNAL, session);

View File

@ -409,6 +409,16 @@ int test_domain_matching(const char* actual_module,
char* libdir = MXS_STRDUP_A("../../modules/monitor/mariadbmon/");
set_libdir(libdir);
MXS_CONFIG_PARAMETER params;
params.set("monitor_interval", "1s");
params.set("backend_connect_timeout", "1s");
params.set("backend_read_timeout", "1s");
params.set("backend_write_timeout", "1s");
params.set("journal_max_age", "1s");
params.set("script_timeout", "1s");
params.set(CN_DISK_SPACE_CHECK_INTERVAL, "1s");
params.set("failover_timeout", "1s");
params.set("switchover_timeout", "1s");
params.set("master_failure_timeout", "1s");
params.set(CN_USER, "dummy");
params.set(CN_PASSWORD, "dummy");
MonitorManager::create_monitor(name, actual_module, &params);

View File

@ -56,8 +56,10 @@ static int test1()
"testpoll : Initialise the polling system.");
init_test_env(NULL);
fprintf(stderr, "\t..done\nAdd a DCB");
auto service = service_alloc("service", "readconnroute", nullptr);
MXS_CONFIG_PARAMETER parameters;
parameters.set(CN_MAX_RETRY_INTERVAL, "10s");
parameters.set(CN_CONNECTION_TIMEOUT, "10s");
auto service = service_alloc("service", "readconnroute", &parameters);
auto listener = Listener::create(service, "listener", "mariadbclient", "0.0.0.0", 3306, "", "", nullptr);
auto session = new mxs::Session(listener);
dcb = dcb_alloc(DCB::Role::CLIENT, session);

View File

@ -61,14 +61,18 @@ static int test1()
set_libdir(MXS_STRDUP_A("../../modules/routing/readconnroute/"));
load_module("readconnroute", MODULE_ROUTER);
MXS_CONFIG_PARAMETER parameters;
parameters.set(CN_MAX_RETRY_INTERVAL, "10s");
parameters.set(CN_CONNECTION_TIMEOUT, "10s");
/* Service tests */
fprintf(stderr,
"testservice : creating service called MyService with router nonexistent");
service = service_alloc("MyService", "non-existent", NULL);
service = service_alloc("MyService", "non-existent", &parameters);
mxb_assert_message(NULL == service, "New service with invalid router should be null");
mxb_assert_message(0 == service_isvalid(service), "Service must not be valid after incorrect creation");
fprintf(stderr, "\t..done\nValid service creation, router testroute.");
service = service_alloc("MyService", "readconnroute", NULL);
service = service_alloc("MyService", "readconnroute", &parameters);
mxb_assert_message(NULL != service, "New service with valid router must not be null");
mxb_assert_message(0 != service_isvalid(service), "Service must be valid after creation");

View File

@ -65,12 +65,12 @@ extern int blr_test_handle_change_master(ROUTER_INSTANCE* router, char* comman
static struct option long_options[] =
{
{"debug", no_argument, 0, 'd' },
{"verbose", no_argument, 0, 'v' },
{"version", no_argument, 0, 'V' },
{"fix", no_argument, 0, 'f' },
{"help", no_argument, 0, '?' },
{0, 0, 0, 0 }
{"debug", no_argument, 0, 'd'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{"fix", no_argument, 0, 'f'},
{"help", no_argument, 0, '?'},
{0, 0, 0, 0 }
};
int main(int argc, char** argv)
@ -113,6 +113,8 @@ int main(int argc, char** argv)
CONFIG_CONTEXT ctx {(char*)""};
config_add_defaults(&ctx, get_module("binlogrouter", MODULE_ROUTER)->parameters);
ctx.m_parameters.set(CN_MAX_RETRY_INTERVAL, "10s");
ctx.m_parameters.set(CN_CONNECTION_TIMEOUT, "10s");
const char* options = "server_id=3,heartbeat=200,binlogdir=/tmp/my_dir,"
"transaction_safety=1,master_version=5.6.99-common,"
@ -138,11 +140,11 @@ int main(int argc, char** argv)
MXS_CONFIG_PARAMETER params;
params.set_from_list({
{"address", "_none_"},
{"port", "3306"},
{"protocol", "MySQLBackend"},
{"authenticator", "MySQLBackendAuth"}
}, config_server_params);
{"address", "_none_"},
{"port", "3306"},
{"protocol", "MySQLBackend"},
{"authenticator", "MySQLBackendAuth"}
}, config_server_params);
Server* server = Server::server_alloc("binlog_router_master_host", &params);
if (server == NULL)