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
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 20 additions and 3 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");
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);
fprintf(stderr, "\t..done\nAllocated dcb.");
// TODO: Without running workers, the following will hang. As it does not

View File

@ -38,6 +38,8 @@
#include <maxscale/service.hh>
#include "test_utils.h"
#include "../internal/service.hh"
#include "../internal/session.hh"
/**
* test1 Allocate a service and do lots of other things
@ -54,7 +56,11 @@ static int test1()
"testpoll : Initialise the polling system.");
init_test_env(NULL);
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)
{

View File

@ -29,7 +29,7 @@
#include <sys/stat.h>
#include "../internal/poll.hh"
#include "../internal/modules.hh"
void init_test_env(char* path)
{
@ -48,6 +48,14 @@ void init_test_env(char* path)
maxbase::init();
maxscale::RoutingWorker::init();
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