MXS-2196: Fix core unit tests

Fixed the tests so that they properly allocate a service and a listener
for it after which a new session and a DCB are created.
This commit is contained in:
Markus Mäkelä
2018-12-03 21:19:03 +02:00
parent 43c33e9f4a
commit cb18670013
3 changed files with 20 additions and 3 deletions

View File

@ -50,7 +50,10 @@ static int test1()
DCB* dcb; DCB* dcb;
/* Single buffer tests */ /* Single buffer tests */
fprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_INTERNAL"); fprintf(stderr, "testdcb : creating buffer with type DCB_ROLE_INTERNAL");
dcb = dcb_alloc(DCB_ROLE_INTERNAL, nullptr); auto service = service_alloc("service", "readconnroute", nullptr);
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);
printDCB(dcb); printDCB(dcb);
fprintf(stderr, "\t..done\nAllocated dcb."); fprintf(stderr, "\t..done\nAllocated dcb.");
// TODO: Without running workers, the following will hang. As it does not // TODO: Without running workers, the following will hang. As it does not

View File

@ -38,6 +38,8 @@
#include <maxscale/service.hh> #include <maxscale/service.hh>
#include "test_utils.h" #include "test_utils.h"
#include "../internal/service.hh"
#include "../internal/session.hh"
/** /**
* test1 Allocate a service and do lots of other things * test1 Allocate a service and do lots of other things
@ -54,7 +56,11 @@ static int test1()
"testpoll : Initialise the polling system."); "testpoll : Initialise the polling system.");
init_test_env(NULL); init_test_env(NULL);
fprintf(stderr, "\t..done\nAdd a DCB"); fprintf(stderr, "\t..done\nAdd a DCB");
dcb = dcb_alloc(DCB_ROLE_CLIENT_HANDLER, nullptr);
auto service = service_alloc("service", "readconnroute", nullptr);
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_HANDLER, session);
if (dcb == NULL) if (dcb == NULL)
{ {

View File

@ -29,7 +29,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "../internal/poll.hh" #include "../internal/poll.hh"
#include "../internal/modules.hh"
void init_test_env(char* path) void init_test_env(char* path)
{ {
@ -48,6 +48,14 @@ void init_test_env(char* path)
maxbase::init(); maxbase::init();
maxscale::RoutingWorker::init(); maxscale::RoutingWorker::init();
hkinit(); hkinit();
set_libdir(MXS_STRDUP(TEST_DIR "/server/modules/protocol/MySQL/mariadbclient/"));
load_module("mariadbclient", MODULE_PROTOCOL);
set_libdir(MXS_STRDUP(TEST_DIR "/server/modules/routing/readconnroute/"));
load_module("readconnroute", MODULE_ROUTER);
set_libdir(MXS_STRDUP(TEST_DIR "/server/modules/routing/readwritesplit/"));
load_module("readwritesplit", MODULE_ROUTER);
set_libdir(MXS_STRDUP(TEST_DIR "/server/modules/authenticator/MySQLAuth/"));
load_module("mysqlauth", MODULE_AUTHENTICATOR);
} }
#endif #endif