Test system for MaxScale.
Every test/makefile have the following targets: cleantests - clean local and subdirectories' tests buildtests - build all local and subdirectories' tests runtests - run all local tests testall - clean, build and run local and subdirectories' tests Tests for directory random_dir are always in its subdirectory, in this case in random_dir/test . If random_dir has subdirectories with tests, random_dir/child_dir, for example, tests of child_dir can be started from random_dir/test/makefile where make -C child_dir/test <test target> is called. See MAXSCALE_HOME/test/README for further information.
This commit is contained in:
30
Makefile
30
Makefile
@ -18,8 +18,23 @@
|
||||
# Date Who Description
|
||||
# 16/07/13 Mark Riddoch Initial implementation
|
||||
|
||||
include build_gateway.inc
|
||||
|
||||
DEST=$(HOME)/usr/local/skysql
|
||||
|
||||
#
|
||||
# A special build of MaxScale is done for tests.
|
||||
# HAVE_SRV carries information whether test MaxScale server
|
||||
# is built already or not.
|
||||
# HAVE_SRV == Y when test server is built,
|
||||
# HAVE_SRV == N when not.
|
||||
# It prevents unnecessary recompilation and also clean-up
|
||||
# in the middle of the test.
|
||||
#
|
||||
HAVE_SRV := N
|
||||
|
||||
.PHONY: buildtestserver
|
||||
|
||||
all:
|
||||
(cd log_manager; make)
|
||||
(cd query_classifier; make)
|
||||
@ -40,5 +55,20 @@ install:
|
||||
(cd log_manager; make DEST=$(DEST) install)
|
||||
(cd query_classifier; make DEST=$(DEST) install)
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test buildtests
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test HAVE_SRV=$(HAVE_SRV) testall
|
||||
|
||||
buildtestserver:
|
||||
$(MAKE) DEBUG=Y DYNLIB=Y DEST=$(ROOT_PATH)/server/test clean depend all install
|
||||
$(eval HAVE_SRV := Y)
|
||||
|
||||
documentation:
|
||||
doxygen doxygate
|
||||
|
||||
|
||||
|
@ -4,14 +4,14 @@ include ../makefile.inc
|
||||
CC = gcc
|
||||
CPP = g++
|
||||
|
||||
SRCS = log_manager.cc
|
||||
|
||||
LOG_WRITER_PATH := $(shell pwd)
|
||||
SRCS := log_manager.cc
|
||||
UTILS_PATH := $(ROOT_PATH)/utils
|
||||
CUR_DIR := $(shell pwd)
|
||||
|
||||
makeall: clean all
|
||||
|
||||
clean:
|
||||
make -C ../utils clean
|
||||
$(MAKE) -C $(UTILS_PATH) clean
|
||||
- $(DEL) *.o
|
||||
- $(DEL) *.so
|
||||
- $(DEL) *.so.1.0.1
|
||||
@ -20,16 +20,16 @@ clean:
|
||||
|
||||
all: utils lib
|
||||
|
||||
|
||||
utils:
|
||||
make -C $(ROOT_PATH)/utils clean all
|
||||
$(COPY) $(ROOT_PATH)/utils/skygw_utils.o ./
|
||||
$(MAKE) -C $(UTILS_PATH) clean all
|
||||
|
||||
lib: libcomp liblink
|
||||
|
||||
libcomp:
|
||||
$(CPP) -c $(CFLAGS) \
|
||||
$(MYSQL_HEADERS) \
|
||||
-I../utils/ -I./ \
|
||||
-I$(UTILS_PATH) -I./ \
|
||||
-fPIC ./log_manager.cc -o log_manager.o $(LDLIBS)
|
||||
|
||||
liblink:
|
||||
@ -47,7 +47,21 @@ depend:
|
||||
@rm -f depend
|
||||
$(CPP) -M $(CFLAGS) \
|
||||
$(MYSQL_HEADERS) \
|
||||
-I../utils/ -I./ \
|
||||
-I$(UTILS_PATH) -I./ \
|
||||
$(SRCS) > depend
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test DEBUG=Y buildtests
|
||||
|
||||
runtests:
|
||||
$(MAKE) -C test runtests
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test testall
|
||||
|
||||
|
||||
|
||||
include depend
|
||||
|
@ -1,3 +1,8 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../build_gateway.inc
|
||||
include ../../makefile.inc
|
||||
|
||||
@ -5,31 +10,55 @@ CC = gcc
|
||||
CPP = g++
|
||||
|
||||
TESTPATH := $(shell pwd)
|
||||
TESTLOG := $(TESTPATH)/testlog.log
|
||||
LOG_MANAGER_PATH:= $(ROOT_PATH)/log_manager
|
||||
TESTAPP = $(TESTPATH)/testlog
|
||||
TESTAPP := $(TESTPATH)/testlog
|
||||
UTILS_PATH := $(ROOT_PATH)/utils
|
||||
|
||||
runtest: makeall testall
|
||||
# Use two threads by default
|
||||
ifndef NTHR
|
||||
NTHR=2
|
||||
endif
|
||||
|
||||
makeall: clean all
|
||||
testall:
|
||||
$(MAKE) cleantests
|
||||
$(MAKE) DEBUG=Y buildtests
|
||||
$(MAKE) runtests
|
||||
|
||||
clean:
|
||||
cleantests:
|
||||
- $(DEL) *.o
|
||||
- $(DEL) testlog
|
||||
- $(DEL) *~
|
||||
|
||||
all: testcomp testall
|
||||
|
||||
testcomp:
|
||||
buildtests:
|
||||
$(CC) $(CFLAGS) \
|
||||
-L$(LOG_MANAGER_PATH) \
|
||||
-Wl,-rpath,$(DEST)/lib \
|
||||
-Wl,-rpath,$(LOG_MANAGER_PATH)/ \
|
||||
-o testlog \
|
||||
-I$(MARIADB_SRC_PATH)/include \
|
||||
-I$(LOG_MANAGER_PATH) -I$(ROOT_PATH)/utils testlog.c \
|
||||
-I$(LOG_MANAGER_PATH) -I$(UTILS_PATH) testlog.c \
|
||||
-llog_manager $(LDLIBS) \
|
||||
$(LOG_MANAGER_PATH)/skygw_utils.o \
|
||||
$(UTILS_PATH)/skygw_utils.o
|
||||
|
||||
|
||||
testall:
|
||||
- $(LAUNCH_DEBUGGER) $(TESTAPP) $(BACKGR)
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Log Manager" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "Use 1 thread" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@-$(LAUNCH_DEBUGGER) $(TESTAPP) "-t 1" 2>>$(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "Use 8 threads" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@-$(LAUNCH_DEBUGGER) $(TESTAPP) "-t 8" 2>>$(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "Use 16 threads" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@-$(LAUNCH_DEBUGGER) $(TESTAPP) "-t 16" 2>>$(TESTLOG)
|
||||
@echo "Log Manager PASSED" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
|
@ -37,7 +37,7 @@ typedef struct thread_st {
|
||||
static void* thr_run(void* data);
|
||||
static void* thr_run_morelog(void* data);
|
||||
|
||||
#define NTHR 256
|
||||
#define MAX_NTHR 256
|
||||
#define NITER 100
|
||||
|
||||
#if 1
|
||||
@ -57,22 +57,56 @@ int main(int argc, char* argv[])
|
||||
char* logstr;
|
||||
|
||||
int i;
|
||||
bool r;
|
||||
bool succp;
|
||||
skygw_message_t* mes;
|
||||
simple_mutex_t* mtx;
|
||||
size_t nactive;
|
||||
thread_t* thr[NTHR];
|
||||
thread_t** thr = NULL;
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
char c;
|
||||
int nthr = 0;
|
||||
int log_argc = 0;
|
||||
char** log_argv = NULL;
|
||||
|
||||
while ((c = getopt(argc, argv, "t:")) != -1)
|
||||
{
|
||||
switch (c) {
|
||||
case 't':
|
||||
nthr = atoi(optarg);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nthr <= 0)
|
||||
{
|
||||
fprintf(stderr, "Thread count argument is zero or "
|
||||
"negative. Exiting.\n");
|
||||
err = 1;
|
||||
goto return_err;
|
||||
}
|
||||
|
||||
thr = (thread_t*)calloc(1, nthr*sizeof(thread_t*));
|
||||
|
||||
if (thr == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to allocate memory for thread "
|
||||
"structure. Exiting.\n");
|
||||
err = 1;
|
||||
goto return_err;
|
||||
|
||||
}
|
||||
i = atexit(skygw_logmanager_exit);
|
||||
|
||||
if (i != 0) {
|
||||
fprintf(stderr, "Couldn't register exit function.\n");
|
||||
}
|
||||
|
||||
r = skygw_logmanager_init( argc, argv);
|
||||
ss_dassert(r);
|
||||
succp = skygw_logmanager_init( log_argc, log_argv);
|
||||
ss_dassert(succp);
|
||||
|
||||
t = time(NULL);
|
||||
tm = *(localtime(&t));
|
||||
@ -85,7 +119,7 @@ int main(int argc, char* argv[])
|
||||
tm.tm_min,
|
||||
tm.tm_sec);
|
||||
|
||||
skygw_logmanager_init( argc, argv);
|
||||
skygw_logmanager_init( log_argc, log_argv);
|
||||
logstr = ("First write with flush.");
|
||||
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
|
||||
|
||||
@ -133,7 +167,7 @@ int main(int argc, char* argv[])
|
||||
logstr = "Ph%dlip.";
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr, 1);
|
||||
|
||||
skygw_logmanager_init( argc, argv);
|
||||
skygw_logmanager_init( log_argc, log_argv);
|
||||
logstr = ("A terrible error has occurred!");
|
||||
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
|
||||
|
||||
@ -159,15 +193,15 @@ int main(int argc, char* argv[])
|
||||
fprintf(stderr, "\nStarting test #1 \n");
|
||||
|
||||
/** 1 */
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
thr[i] = (thread_t*)calloc(1, sizeof(thread_t));
|
||||
thr[i]->mes = mes;
|
||||
thr[i]->mtx = mtx;
|
||||
thr[i]->nactive = &nactive;
|
||||
}
|
||||
nactive = NTHR;
|
||||
nactive = nthr;
|
||||
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
pthread_t p;
|
||||
pthread_create(&p, NULL, thr_run, thr[i]);
|
||||
thr[i]->tid = p;
|
||||
@ -183,7 +217,7 @@ int main(int argc, char* argv[])
|
||||
break;
|
||||
} while(true);
|
||||
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
pthread_join(thr[i]->tid, NULL);
|
||||
}
|
||||
/** This is to release memory */
|
||||
@ -191,7 +225,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
simple_mutex_unlock(mtx);
|
||||
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
free(thr[i]);
|
||||
}
|
||||
#endif
|
||||
@ -201,20 +235,20 @@ int main(int argc, char* argv[])
|
||||
fprintf(stderr, "\nStarting test #2 \n");
|
||||
|
||||
/** 2 */
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
thr[i] = (thread_t*)calloc(1, sizeof(thread_t));
|
||||
thr[i]->mes = mes;
|
||||
thr[i]->mtx = mtx;
|
||||
thr[i]->nactive = &nactive;
|
||||
}
|
||||
nactive = NTHR;
|
||||
nactive = nthr;
|
||||
|
||||
fprintf(stderr,
|
||||
"\nLaunching %d threads, each iterating %d times.",
|
||||
NTHR,
|
||||
nthr,
|
||||
NITER);
|
||||
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
pthread_t p;
|
||||
pthread_create(&p, NULL, thr_run_morelog, thr[i]);
|
||||
thr[i]->tid = p;
|
||||
@ -234,7 +268,7 @@ int main(int argc, char* argv[])
|
||||
break;
|
||||
} while(true);
|
||||
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
pthread_join(thr[i]->tid, NULL);
|
||||
}
|
||||
/** This is to release memory */
|
||||
@ -244,7 +278,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
fprintf(stderr, "\nFreeing thread memory.");
|
||||
|
||||
for (i=0; i<NTHR; i++) {
|
||||
for (i=0; i<nthr; i++) {
|
||||
free(thr[i]);
|
||||
}
|
||||
|
||||
@ -265,8 +299,8 @@ int main(int argc, char* argv[])
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
r = skygw_logmanager_init(argc, argv);
|
||||
ss_dassert(r);
|
||||
succp = skygw_logmanager_init(log_argc, log_argv);
|
||||
ss_dassert(succp);
|
||||
|
||||
skygw_log_disable(LOGFILE_TRACE);
|
||||
|
||||
@ -326,8 +360,8 @@ int main(int argc, char* argv[])
|
||||
#endif /* TEST 3 */
|
||||
|
||||
#if defined(TEST4)
|
||||
r = skygw_logmanager_init(argc, argv);
|
||||
ss_dassert(r);
|
||||
succp = skygw_logmanager_init(log_argc, log_argv);
|
||||
ss_dassert(succp);
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
@ -361,8 +395,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
skygw_logmanager_done();
|
||||
|
||||
r = skygw_logmanager_init(argc, argv);
|
||||
ss_dassert(r);
|
||||
succp = skygw_logmanager_init(log_argc, log_argv);
|
||||
ss_dassert(succp);
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
@ -421,6 +455,11 @@ int main(int argc, char* argv[])
|
||||
|
||||
#endif /* TEST 4 */
|
||||
fprintf(stderr, ".. done.\n");
|
||||
return_err:
|
||||
if (thr != NULL)
|
||||
{
|
||||
free(thr);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
|
||||
#ifdef UNIX
|
||||
DEL := rm -f
|
||||
DEL := rm -fr
|
||||
LINK := ln -s
|
||||
COPY := cp
|
||||
NOHUP := nohup
|
||||
|
@ -4,33 +4,45 @@ include ../makefile.inc
|
||||
CC = gcc
|
||||
CPP = g++
|
||||
|
||||
SRCS = query_classifier.cc
|
||||
|
||||
QUERY_CLASSIFIER_PATH := $(shell pwd)
|
||||
SRCS := query_classifier.cc
|
||||
UTILS_PATH := $(ROOT_PATH)/utils
|
||||
QUERY_CLASSIFIER_PATH := $(ROOT_PATH)/query_classifier
|
||||
LOG_MANAGER_PATH := $(ROOT_PATH)/log_manager
|
||||
|
||||
makeall: clean all
|
||||
|
||||
clean:
|
||||
make -C ../utils clean
|
||||
$(MAKE) -C $(UTILS_PATH) clean
|
||||
- $(DEL) query_classifier.o
|
||||
- $(DEL) libquery_classifier.so
|
||||
- $(DEL) libquery_classifier.so.1.0.1
|
||||
- $(DEL) skygw_utils.o
|
||||
- $(DEL) *~
|
||||
- $(DEL) depend
|
||||
|
||||
all: utils lib
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test DEBUG=Y DYNLIB=Y buildtests
|
||||
|
||||
runtests:
|
||||
$(MAKE) -C test runtests
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test testall
|
||||
|
||||
|
||||
utils:
|
||||
make -C $(ROOT_PATH)/utils clean all
|
||||
$(COPY) $(ROOT_PATH)/utils/skygw_utils.o ./
|
||||
$(MAKE) -C $(UTILS_PATH) clean all
|
||||
|
||||
lib: libcomp liblink
|
||||
|
||||
libcomp:
|
||||
$(CPP) -c $(CFLAGS) \
|
||||
$(MYSQL_HEADERS) \
|
||||
-I$(ROOT_PATH)/log_manager/ \
|
||||
-I$(LOG_MANAGER_PATH) \
|
||||
-I./ \
|
||||
-fPIC ./query_classifier.cc -o query_classifier.o
|
||||
|
||||
@ -53,7 +65,7 @@ depend:
|
||||
@rm -f depend
|
||||
$(CPP) -M $(CFLAGS) \
|
||||
$(MYSQL_HEADERS) \
|
||||
-I$(ROOT_PATH)/log_manager/ \
|
||||
-I$(LOG_MANAGER_PATH) \
|
||||
-I./ \
|
||||
$(SRCS) > depend
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../build_gateway.inc
|
||||
include ../../makefile.inc
|
||||
|
||||
@ -5,32 +10,52 @@ CC = gcc
|
||||
CPP = g++
|
||||
|
||||
TESTPATH := $(shell pwd)
|
||||
QUERY_CLASSIFIER_PATH := $(ROOT_PATH)/query_classifier/
|
||||
TESTLOG := $(TESTPATH)/testqclass.log
|
||||
QUERY_CLASSIFIER_PATH := $(ROOT_PATH)/query_classifier
|
||||
LOG_MANAGER_PATH := $(ROOT_PATH)/log_manager
|
||||
UTILS_PATH := $(ROOT_PATH)/utils
|
||||
TESTAPP = $(TESTPATH)/testmain
|
||||
|
||||
runtest: makeall testall
|
||||
testall:
|
||||
$(MAKE) cleantests
|
||||
$(MAKE) DEBUG=Y DYNLIB=Y buildtests
|
||||
$(MAKE) runtests
|
||||
|
||||
makeall: clean all
|
||||
|
||||
clean:
|
||||
cleantests:
|
||||
- $(DEL) testmain.o
|
||||
- $(DEL) testmain
|
||||
- $(DEL) data
|
||||
- $(DEL) *~
|
||||
|
||||
all: testcomp testall
|
||||
|
||||
testcomp:
|
||||
buildtests:
|
||||
$(CC) $(CFLAGS) \
|
||||
-L$(QUERY_CLASSIFIER_PATH) \
|
||||
-L$(MARIADB_SRC_PATH)/libmysqld \
|
||||
-L$(LOG_MANAGER_PATH) \
|
||||
-L$(EMBEDDED_LIB) \
|
||||
-Wl,-rpath,$(DEST)/lib \
|
||||
-Wl,-rpath,$(MARIADB_SRC_PATH)/libmysqld \
|
||||
-Wl,-rpath,$(QUERY_CLASSIFIER_PATH)/ \
|
||||
-Wl,-rpath,$(EMBEDDED_LIB) \
|
||||
-Wl,-rpath,$(LOG_MANAGER_PATH) \
|
||||
-Wl,-rpath,$(QUERY_CLASSIFIER_PATH) \
|
||||
-o testmain -DSS_DEBUG \
|
||||
-I$(MARIADB_SRC_PATH)/include testmain.c \
|
||||
-lquery_classifier $(LDLIBS) $(LDMYSQL) \
|
||||
$(QUERY_CLASSIFIER_PATH)/skygw_utils.o
|
||||
$(MYSQL_HEADERS) \
|
||||
-I$(QUERY_CLASSIFIER_PATH) \
|
||||
-I./ \
|
||||
-I$(UTILS_PATH) \
|
||||
testmain.c \
|
||||
$(UTILS_PATH)/skygw_utils.o \
|
||||
-lquery_classifier -lz -ldl -lssl -laio -lcrypt \
|
||||
-llog_manager \
|
||||
$(LDLIBS) $(LDMYSQL)
|
||||
|
||||
|
||||
testall:
|
||||
- $(LAUNCH_DEBUGGER) $(TESTAPP) $(BACKGR)
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Query Classifier" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@ -$(LAUNCH_DEBUGGER) $(TESTAPP) $(BACKGR) 2>> $(TESTLOG)
|
||||
ifeq ($?, 0)
|
||||
@echo "Query Classifier PASSED" >> $(TESTLOG)
|
||||
else
|
||||
@echo "Query Classifier FAILED" >> $(TESTLOG)
|
||||
endif
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
@ -5,8 +7,6 @@
|
||||
#include <mysql.h>
|
||||
|
||||
#include "../../utils/skygw_utils.h"
|
||||
//#include "skygw_debug.h"
|
||||
//#include "skygw_types.h"
|
||||
#include "../query_classifier.h"
|
||||
|
||||
static char datadir[1024] = "";
|
||||
@ -117,12 +117,12 @@ int main(int argc, char** argv)
|
||||
slist_cursor_t* c;
|
||||
const char* q;
|
||||
query_test_t* qtest;
|
||||
skygw_query_type_t qtype;
|
||||
bool succp;
|
||||
bool failp = true;
|
||||
unsigned int f = 0;
|
||||
int nsucc = 0;
|
||||
int nfail = 0;
|
||||
int rc = 0;
|
||||
MYSQL* mysql;
|
||||
char* workingdir;
|
||||
char ddoption[1024];
|
||||
@ -356,13 +356,13 @@ int main(int argc, char** argv)
|
||||
fprintf(stderr,
|
||||
"Failed to resolve the working directory, $PWD is not "
|
||||
"set.\n");
|
||||
goto return_without_server;
|
||||
ss_dassert(workingdir != NULL);
|
||||
} else if (access(workingdir, R_OK) != 0) {
|
||||
fprintf(stderr,
|
||||
"Failed to access the working directory due %d, %s\n",
|
||||
errno,
|
||||
strerror(errno));
|
||||
goto return_without_server;
|
||||
ss_dassert(false);
|
||||
} else {
|
||||
char** so = server_options;
|
||||
snprintf(datadir, 1023, "%s/data", workingdir);
|
||||
@ -373,7 +373,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (*so == NULL) {
|
||||
fprintf(stderr, "Failed to find datadir option.\n");
|
||||
goto return_without_server;
|
||||
ss_dassert(*so != NULL);
|
||||
}
|
||||
*so = ddoption;
|
||||
|
||||
@ -389,7 +389,7 @@ int main(int argc, char** argv)
|
||||
"mysql_init failed, %d : %s\n",
|
||||
mysql_errno(mysql),
|
||||
mysql_error(mysql));
|
||||
goto return_without_server;
|
||||
ss_dassert(!failp);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
@ -449,7 +449,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (mysql == NULL) {
|
||||
fprintf(stderr, "mysql_init failed\n");
|
||||
goto return_without_server;
|
||||
ss_dassert(mysql != NULL);
|
||||
}
|
||||
|
||||
mysql_options(mysql,
|
||||
@ -469,7 +469,7 @@ int main(int argc, char** argv)
|
||||
|
||||
if (mysql == NULL) {
|
||||
fprintf(stderr, "mysql_real_connect failed\n");
|
||||
goto return_with_handle;
|
||||
ss_dassert(mysql != NULL);
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
@ -525,5 +525,5 @@ return_with_handle:
|
||||
return_without_server:
|
||||
ss_dfprintf(stderr, "\n<< testmain\n");
|
||||
fflush(stderr);
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
@ -34,6 +34,15 @@ all:
|
||||
(cd modules/protocol; touch depend.mk ;make)
|
||||
(cd modules/monitor; touch depend.mk ;make)
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test HAVE_SRV=$(HAVE_SRV) buildtests
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test HAVE_SRV=$(HAVE_SRV) testall
|
||||
|
||||
clean:
|
||||
(cd Documentation; rm -rf html)
|
||||
(cd core; touch depend.mk ; make clean)
|
||||
|
@ -77,6 +77,18 @@ LIBS=-L../inih/extra -linih -lssl -lstdc++ \
|
||||
|
||||
all: maxscale maxkeys maxpasswd
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test buildtests
|
||||
|
||||
runtests:
|
||||
$(MAKE) -C test runtests
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test testall
|
||||
|
||||
maxscale: $(OBJ)
|
||||
$(CC) $(LDFLAGS) $(OBJ) $(UTILSPATH)/skygw_utils.o $(LIBS) -o $@
|
||||
|
||||
|
@ -1,32 +1,44 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../../build_gateway.inc
|
||||
include ../../../makefile.inc
|
||||
|
||||
CC=cc
|
||||
TESTLOG := $(shell pwd)/testhash.log
|
||||
|
||||
clean:
|
||||
cleantests:
|
||||
- $(DEL) *.o
|
||||
- $(DEL) testhash
|
||||
- $(DEL) *~
|
||||
|
||||
all:
|
||||
$(MAKE) clean
|
||||
$(MAKE) buildall
|
||||
$(MAKE) runall
|
||||
testall:
|
||||
$(MAKE) cleantests
|
||||
$(MAKE) DEBUG=Y buildtests
|
||||
$(MAKE) runtests
|
||||
|
||||
buildall :
|
||||
buildtests :
|
||||
$(CC) $(CFLAGS) \
|
||||
-I$(ROOT_PATH)/server/include \
|
||||
-I$(ROOT_PATH)/utils \
|
||||
testhash.c ../hashtable.o ../atomic.o ../spinlock.o -o testhash \
|
||||
|
||||
runall:
|
||||
- @./testhash 0 1
|
||||
- @./testhash 10 1
|
||||
- @./testhash 1000 10
|
||||
- @./testhash 10 0
|
||||
- @./testhash 1500 17
|
||||
- @./testhash 1 1
|
||||
- @./testhash 10000 133
|
||||
- @./testhash 1000 1000
|
||||
- @./testhash 1000 100000
|
||||
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test MaxScale core" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@./testhash 0 1 2>> $(TESTLOG)
|
||||
@./testhash 10 1 2>> $(TESTLOG)
|
||||
@./testhash 1000 10 2>> $(TESTLOG)
|
||||
@./testhash 10 0 2>> $(TESTLOG)
|
||||
@./testhash 1500 17 2>> $(TESTLOG)
|
||||
@./testhash 1 1 2>> $(TESTLOG)
|
||||
@./testhash 10000 133 2>> $(TESTLOG)
|
||||
@./testhash 1000 1000 2>> $(TESTLOG)
|
||||
@./testhash 1000 100000 2>> $(TESTLOG)
|
||||
@echo "MaxScale core PASSED" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
|
117
server/test/MaxScale_test.cnf
Normal file
117
server/test/MaxScale_test.cnf
Normal file
@ -0,0 +1,117 @@
|
||||
#
|
||||
# Example MaxScale.cnf configuration file
|
||||
#
|
||||
#
|
||||
#
|
||||
# Number of server threads
|
||||
# Valid options are:
|
||||
# threads=<number of threads>
|
||||
|
||||
[maxscale]
|
||||
threads=1
|
||||
|
||||
# Define a monitor that can be used to determine the state and role of
|
||||
# the servers.
|
||||
#
|
||||
# Valid options are:
|
||||
#
|
||||
# module=<name of module to load>
|
||||
# servers=<server name>,<server name>,...
|
||||
# user =<user name - must have slave replication and
|
||||
# slave client privileges>
|
||||
# passwd=<password of the above user, plain text currently>
|
||||
|
||||
[MySQL Monitor]
|
||||
type=monitor
|
||||
module=mysqlmon
|
||||
servers=server1,server2,server3
|
||||
user=maxuser
|
||||
passwd=maxpwd
|
||||
|
||||
# A series of service definition
|
||||
#
|
||||
# Valid options are:
|
||||
#
|
||||
# router=<name of router module>
|
||||
# servers=<server name>,<server name>,...
|
||||
# user=<User to fetch password inforamtion with>
|
||||
# passwd=<Password of the user, plain text currently>
|
||||
#
|
||||
# Valid router modules currently are:
|
||||
# readwritesplit, readconnroute and debugcli
|
||||
|
||||
[RW Split Router]
|
||||
type=service
|
||||
router=readwritesplit
|
||||
servers=server1,server2,server3
|
||||
user=maxuser
|
||||
passwd=maxpwd
|
||||
|
||||
[Read Connection Router]
|
||||
type=service
|
||||
router=readconnroute
|
||||
router_options=slave
|
||||
servers=server1,server2,server3
|
||||
user=maxuser
|
||||
passwd=maxpwd
|
||||
|
||||
[HTTPD Router]
|
||||
type=service
|
||||
router=testroute
|
||||
servers=server1,server2,server3
|
||||
|
||||
[Debug Interface]
|
||||
type=service
|
||||
router=debugcli
|
||||
|
||||
# Listener definitions for the services
|
||||
#
|
||||
# Valid options are:
|
||||
#
|
||||
# service=<name of service defined elsewhere>
|
||||
# protocol=<name of protocol module with which to listen>
|
||||
# port=<Listening port>
|
||||
|
||||
[RW Split Listener]
|
||||
type=listener
|
||||
service=RW Split Router
|
||||
protocol=MySQLClient
|
||||
port=4006
|
||||
|
||||
[Read Connection Listener]
|
||||
type=listener
|
||||
service=Read Connection Router
|
||||
protocol=MySQLClient
|
||||
port=4008
|
||||
|
||||
[Debug Listener]
|
||||
type=listener
|
||||
service=Debug Interface
|
||||
protocol=telnetd
|
||||
port=4442
|
||||
|
||||
[HTTPD Listener]
|
||||
type=listener
|
||||
service=HTTPD Router
|
||||
protocol=HTTPD
|
||||
port=6444
|
||||
|
||||
# Definition of the servers
|
||||
|
||||
[server1]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=3000
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server2]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=3001
|
||||
protocol=MySQLBackend
|
||||
|
||||
[server3]
|
||||
type=server
|
||||
address=127.0.0.1
|
||||
port=3002
|
||||
protocol=MySQLBackend
|
67
server/test/makefile
Normal file
67
server/test/makefile
Normal file
@ -0,0 +1,67 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../build_gateway.inc
|
||||
include ../../makefile.inc
|
||||
|
||||
TEST_ROOT := $(ROOT_PATH)/test
|
||||
PARENT_DIR := $(ROOT_PATH)/server
|
||||
CUR_DIR := $(PARENT_DIR)/test
|
||||
export MAXSCALE_HOME=$(CUR_DIR)/MaxScale
|
||||
|
||||
CC=cc
|
||||
TESTLOG := $(CUR_DIR)/testserver.log
|
||||
|
||||
ifndef $(HAVE_SRV)
|
||||
HAVE_SRV := N
|
||||
endif
|
||||
|
||||
cleantests:
|
||||
- $(DEL) *.o
|
||||
- $(DEL) *~
|
||||
ifeq ($(HAVE_SRV), N)
|
||||
- $(DEL) Documentation
|
||||
- $(DEL) bin
|
||||
- $(DEL) lib
|
||||
- $(DEL) MaxScale/etc
|
||||
- $(DEL) MaxScale/modules
|
||||
- $(DEL) MaxScale/mysql
|
||||
endif
|
||||
$(MAKE) -C $(PARENT_DIR)/core cleantests
|
||||
|
||||
testall:
|
||||
$(MAKE) HAVE_SRV=$(HAVE_SRV) cleantests
|
||||
$(MAKE) HAVE_SRV=$(HAVE_SRV) buildtests
|
||||
$(MAKE) runtests
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Server Core" >> $(TESTLOG)
|
||||
$(MAKE) -C $(ROOT_PATH)/server/core testall
|
||||
@echo "Query Classifier PASSED" >> $(TESTLOG)
|
||||
|
||||
|
||||
buildtests:
|
||||
ifeq ($(HAVE_SRV), Y)
|
||||
@echo "Test server already built"
|
||||
else
|
||||
$(MAKE) -C $(ROOT_PATH) buildtestserver
|
||||
endif
|
||||
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test MaxScale server" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo "MAXSCALE_HOME="$(MAXSCALE_HOME) >> $(TESTLOG)
|
||||
cp $(CUR_DIR)/MaxScale_test.cnf $(MAXSCALE_HOME)/etc/MaxScale.cnf
|
||||
bin/maxscale 2>> $(TESTLOG)
|
||||
@echo "Put your tests here"
|
||||
@sleep 5
|
||||
@echo "MaxScale server PASSED" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@killall maxscale
|
||||
|
65
test/README
Normal file
65
test/README
Normal file
@ -0,0 +1,65 @@
|
||||
Source tree structure and test targets for make. In a given source directory,
|
||||
MAXSCALE_HOME/server, for example, there is a test directory which includes
|
||||
tests for that directory ('local tests') and targets for every subdirectory
|
||||
of MAXSCALE_HOME/server.
|
||||
|
||||
In the outline below, target, such as 'cleantest' includes instructions for
|
||||
executing tests or make command pointing to subdirectories. If target is
|
||||
followed by colon and a list of directory names ('cleantest:log_manager,
|
||||
query_classifier'), the target is executed locally and in the listed
|
||||
directories.
|
||||
|
||||
Note : add new tests for any component as close to the actual implementation
|
||||
as possible. For example, DCB tests in MAXSCALE_HOME/server/core/test instead
|
||||
of MAXSCALE_HOME/server/test etc.
|
||||
|
||||
MAXSCALE_HOME
|
||||
|
|
||||
|- log_manager cleantests, buildtests, runtests, testall
|
||||
| |
|
||||
| |- test cleantests, buildtests, runtests, testall
|
||||
|
|
||||
|- query_classifier cleantests, buildtests, runtests, testall
|
||||
| |
|
||||
| |- test cleantests, buildtests, runtests, testall
|
||||
|
|
||||
|- server cleantests, buildtests, testall
|
||||
| |
|
||||
| |- core cleantests, buildtests, runtests, testall
|
||||
| | |
|
||||
| | |- test cleantests, buildtests, runtests, testall
|
||||
| |
|
||||
| |- inih
|
||||
| | |
|
||||
| | |- test
|
||||
| |
|
||||
| |- modules
|
||||
| | |
|
||||
| | |- monitor
|
||||
| | |
|
||||
| | |- protocol
|
||||
| | |
|
||||
| | |- routing
|
||||
| | | |
|
||||
| | | |- readwritesplit
|
||||
| |
|
||||
| |- test cleantests:server/core,
|
||||
| | buildtests,
|
||||
| | runtests,
|
||||
| | testall:server/core
|
||||
|
|
||||
|- test cleantests:log_manager, query_classifier, server, utils
|
||||
buildtests:buildtestserver, log_manager, query_classifier, server, utils
|
||||
runtests:<empty>
|
||||
testall:cleantests,
|
||||
buildtests,
|
||||
runtests,
|
||||
log_manager,
|
||||
query_classifier,
|
||||
server,
|
||||
utils
|
||||
|
|
||||
|- utils cleantests, buildtests, runtests, testall
|
||||
| |
|
||||
| |- test cleantests, buildtests, runtests, testall
|
||||
|
|
63
test/makefile
Normal file
63
test/makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../build_gateway.inc
|
||||
include ../makefile.inc
|
||||
|
||||
export MAXSCALE_HOME=$(shell pwd)/MaxScale
|
||||
|
||||
CC=cc
|
||||
TESTLOG := $(shell pwd)/testmaxscale.log
|
||||
|
||||
testall:
|
||||
$(MAKE) cleantests
|
||||
$(MAKE) buildtests
|
||||
$(MAKE) runtests
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Log Manager" >> $(TESTLOG)
|
||||
$(MAKE) -C $(ROOT_PATH)/log_manager testall
|
||||
@echo "Log Manager PASSED" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Query Classifier" >> $(TESTLOG)
|
||||
$(MAKE) -C $(ROOT_PATH)/query_classifier testall
|
||||
@echo "Query Classifier PASSED" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test MaxScale server" >> $(TESTLOG)
|
||||
$(MAKE) -C $(ROOT_PATH)/server HAVE_SRV=$(HAVE_SRV) testall
|
||||
@echo "MaxScale server PASSED" >> $(TESTLOG)
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test utils" >> $(TESTLOG)
|
||||
$(MAKE) -C $(ROOT_PATH)/utils testall
|
||||
@echo "Utils PASSED" >> $(TESTLOG)
|
||||
|
||||
cleantests:
|
||||
$(DEL) *~
|
||||
$(MAKE) -C $(ROOT_PATH)/log_manager cleantests
|
||||
$(MAKE) -C $(ROOT_PATH)/query_classifier cleantests
|
||||
$(MAKE) -C $(ROOT_PATH)/server cleantests
|
||||
$(MAKE) -C $(ROOT_PATH)/utils cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C $(ROOT_PATH) buildtestserver
|
||||
$(MAKE) -C $(ROOT_PATH)/log_manager buildtests
|
||||
$(MAKE) -C $(ROOT_PATH)/query_classifier buildtests
|
||||
$(MAKE) -C $(ROOT_PATH)/server HAVE_SRV=$(HAVE_SRV) buildtests
|
||||
$(MAKE) -C $(ROOT_PATH)/utils buildtests
|
||||
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test MaxScale root" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo "Nothing to run here so far" >> $(TESTLOG)
|
@ -16,3 +16,14 @@ all:
|
||||
$(CPP) -c $(CFLAGS) \
|
||||
-fPIC skygw_utils.cc -o skygw_utils.o
|
||||
|
||||
cleantests:
|
||||
$(MAKE) -C test cleantests
|
||||
|
||||
buildtests:
|
||||
$(MAKE) -C test DEBUG=Y buildtests
|
||||
|
||||
runtests:
|
||||
$(MAKE) -C test runtests
|
||||
|
||||
testall:
|
||||
$(MAKE) -C test testall
|
||||
|
30
utils/test/makefile
Normal file
30
utils/test/makefile
Normal file
@ -0,0 +1,30 @@
|
||||
# cleantests - clean local and subdirectories' tests
|
||||
# buildtests - build all local and subdirectories' tests
|
||||
# runtests - run all local tests
|
||||
# testall - clean, build and run local and subdirectories' tests
|
||||
|
||||
include ../../build_gateway.inc
|
||||
include ../../makefile.inc
|
||||
|
||||
CC=cc
|
||||
TESTLOG := $(shell pwd)/testutils.log
|
||||
|
||||
testall:
|
||||
$(MAKE) cleantests
|
||||
$(MAKE) buildtests
|
||||
$(MAKE) runtests
|
||||
@echo "No subdirectories to test" >> $(TESTLOG)
|
||||
|
||||
cleantests:
|
||||
$(DEL) *~
|
||||
|
||||
buildtests:
|
||||
@echo "Nothing to build here so far" >> $(TESTLOG)
|
||||
|
||||
runtests:
|
||||
@echo "" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo $(shell date) >> $(TESTLOG)
|
||||
@echo "Test Utils" >> $(TESTLOG)
|
||||
@echo "-------------------------------" >> $(TESTLOG)
|
||||
@echo "Nothing to run here so far" >> $(TESTLOG)
|
Reference in New Issue
Block a user