Fix tests and limit internal test set size
Some of the tests depended on a working installation where modules are all located at the default paths. These tests now explicitly set the module directory which fixes the immediate problem. Disabled the starting of services in the service test as this will fail with real modules. The dummy internal modules aren't build and should be removed in a later commit. In general, it might be better to do service level testing outside the internal test suite.
This commit is contained in:
parent
cff90ffee8
commit
d961864635
@ -15,6 +15,7 @@ cd build
|
||||
cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=Y -DBUILD_AVRO=N
|
||||
|
||||
make
|
||||
make test
|
||||
sudo make install
|
||||
|
||||
sudo ./postinst
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/server.h>
|
||||
#include <maxscale/log_manager.h>
|
||||
#include <maxscale/gwdirs.h>
|
||||
/**
|
||||
* test1 Allocate a server and do lots of other things
|
||||
*
|
||||
@ -48,8 +49,8 @@ test1()
|
||||
char *status;
|
||||
|
||||
/* Server tests */
|
||||
ss_dfprintf(stderr,
|
||||
"testserver : creating server called MyServer");
|
||||
ss_dfprintf(stderr, "testserver : creating server called MyServer");
|
||||
set_libdir(MXS_STRDUP_A("../../modules/authenticator/"));
|
||||
server = server_alloc("MyServer", "HTTPD", 9876, "NullAuthAllow", NULL);
|
||||
ss_info_dassert(server, "Allocating the server should not fail");
|
||||
mxs_log_flush_sync();
|
||||
|
@ -51,45 +51,29 @@ test1()
|
||||
int result;
|
||||
int argc = 3;
|
||||
|
||||
mxs_log_init(NULL, "/tmp", MXS_LOG_TARGET_FS);
|
||||
init_test_env(NULL);
|
||||
|
||||
/* Service tests */
|
||||
ss_dfprintf(stderr,
|
||||
"testservice : creating service called MyService with router nonexistent");
|
||||
service = service_alloc("MyService", "non-existent");
|
||||
mxs_log_flush_sync();
|
||||
ss_info_dassert(NULL == service, "New service with invalid router should be null");
|
||||
ss_info_dassert(0 == service_isvalid(service), "Service must not be valid after incorrect creation");
|
||||
ss_dfprintf(stderr, "\t..done\nValid service creation, router testroute.");
|
||||
set_libdir(MXS_STRDUP_A("../../modules/routing/"));
|
||||
service = service_alloc("MyService", "testroute");
|
||||
mxs_log_flush_sync();
|
||||
set_libdir(MXS_STRDUP_A("../../modules/routing/readconnroute/"));
|
||||
service = service_alloc("MyService", "readconnroute");
|
||||
|
||||
ss_info_dassert(NULL != service, "New service with valid router must not be null");
|
||||
ss_info_dassert(0 != service_isvalid(service), "Service must be valid after creation");
|
||||
ss_info_dassert(0 == strcmp("MyService", service_get_name(service)), "Service must have given name");
|
||||
ss_dfprintf(stderr, "\t..done\nAdding protocol testprotocol.");
|
||||
set_libdir(MXS_STRDUP_A("../../modules/authenticator/MySQLAuth/"));
|
||||
ss_info_dassert(0 != serviceAddProtocol(service, "TestProtocol", "testprotocol",
|
||||
"localhost", 9876, "MySQLClient", "MySQLAuth", NULL),
|
||||
"localhost", 9876, "MySQLAuth", NULL, NULL),
|
||||
"Add Protocol should succeed");
|
||||
ss_info_dassert(0 != serviceHasProtocol(service, "testprotocol", "localhost", 9876),
|
||||
"Service should have new protocol as requested");
|
||||
set_libdir(MXS_STRDUP_A("../../modules/protocol/"));
|
||||
serviceStartProtocol(service, "testprotocol", 9876);
|
||||
mxs_log_flush_sync();
|
||||
ss_dfprintf(stderr, "\t..done\nStarting Service.");
|
||||
result = serviceStart(service);
|
||||
mxs_log_flush_sync();
|
||||
ss_info_dassert(0 != result, "Start should succeed");
|
||||
serviceStop(service);
|
||||
mxs_log_flush_sync();
|
||||
ss_info_dassert(service->state == SERVICE_STATE_STOPPED, "Stop should succeed");
|
||||
result = serviceStartAll();
|
||||
mxs_log_flush_sync();
|
||||
ss_info_dassert(0 != result, "Start all should succeed");
|
||||
ss_dfprintf(stderr, "\t..done\nStopping Service.");
|
||||
serviceStop(service);
|
||||
ss_info_dassert(service->state == SERVICE_STATE_STOPPED, "Stop should succeed");
|
||||
ss_dfprintf(stderr, "\t..done\n");
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -102,7 +102,7 @@ int main(int argc, char **argv) {
|
||||
serviceAddRouterOption(service, s);
|
||||
s = strtok_r(NULL, ",", &lasts);
|
||||
}
|
||||
|
||||
set_libdir(MXS_STRDUP_A("../../../authenticator/"));
|
||||
server = server_alloc("_none_", "MySQLBackend", 3306, "MySQLBackendAuth", NULL);
|
||||
if (server == NULL) {
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user