Skip to content

Commit

Permalink
Merge pull request #4330 from sysown/v2.x-tap_dyn
Browse files Browse the repository at this point in the history
Dynamically linking on TAP tests
  • Loading branch information
renecannao authored Aug 31, 2023
2 parents bb0d291 + 4108348 commit 7d81a23
Show file tree
Hide file tree
Showing 18 changed files with 141 additions and 69 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ heaptrack.*

#tap tests
test/tap/tap/cpp-dotenv/cpp-dotenv-*
test/tap/tap/cpp-dotenv/static/cpp-dotenv-*
test/tap/tap/cpp-dotenv/dynamic/cpp-dotenv-*
*-t
test/tap/tests/galera_1_timeout_count
test/tap/tests/galera_2_timeout_no_count
Expand Down
2 changes: 1 addition & 1 deletion deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ curl/curl/lib/.libs/libcurl.a: libssl/openssl/libssl.a
ifeq ($(UNAME_S),Darwin)
cd curl/curl && patch configure < ../configure.patch
endif
cd curl/curl && CFLAGS=-fPIC ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-ssl=$(shell pwd)/libssl/openssl/ --enable-shared=no && CC=${CC} CXX=${CXX} ${MAKE}
cd curl/curl && CFLAGS=-fPIC ./configure --disable-debug --disable-ftp --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --disable-manual --disable-ipv6 --disable-sspi --disable-ntlm-wb --disable-tls-srp --without-nghttp2 --without-libidn2 --without-libssh2 --without-brotli --without-librtmp --without-libpsl --without-zstd --with-ssl=$(shell pwd)/libssl/openssl/ --enable-shared=yes && LD_LIBRARY_PATH=$(shell pwd)/libssl/openssl CC=${CC} CXX=${CXX} ${MAKE}

curl: curl/curl/lib/.libs/libcurl.a

Expand Down
67 changes: 49 additions & 18 deletions test/tap/tap/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SQLITE3_DIR=$(DEPS_PATH)/sqlite3/sqlite3
SQLITE3_IDIR=$(SQLITE3_DIR)
SQLITE3_LDIR=$(SQLITE3_DIR)

DOTENV_DIR=./cpp-dotenv/cpp-dotenv
DOTENV_DIR=./cpp-dotenv/static/cpp-dotenv
DOTENV_IDIR=$(DOTENV_DIR)/include
DOTENV_LDIR=$(DOTENV_DIR)

Expand All @@ -25,27 +25,58 @@ LIBPROXYSQLAR=$(LDIR)/libproxysql.a
INCLUDEDIRS=-I$(IDIR) -I$(JSON_IDIR) -I$(MARIADB_IDIR) -I${CURL_IDIR} -I${SQLITE3_IDIR} -I$(DOTENV_IDIR)

.PHONY: all
all: libtap.a
all: libtap.a libtap.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so

.PHONY: clean
clean:
rm -f *.o libtap.a || true
find cpp-dotenv/cpp-dotenv/ -name '*.o' -or -name '*.a' -delete || true
rm -f *.o libtap.a libtap.so || true
find cpp-dotenv/dynamic -name '*.o' -or -name '*.a' -delete || true
find cpp-dotenv/static -name '*.o' -or -name '*.a' -delete || true

OPT=-O2

debug: OPT = -O0 -DDEBUG -ggdb
debug: libtap.a

libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h cpp-dotenv
g++ -c tap.cpp command_line.cpp utils.cpp -std=c++11 $(INCLUDEDIRS) $(OPT)
ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o $$(find $(DOTENV_DIR)/ -name '*.o')

cpp-dotenv/cpp-dotenv/libcpp_dotenv.a:
cd cpp-dotenv && rm -rf cpp-dotenv-*/ || true
cd cpp-dotenv && tar -zxf cpp-dotenv-*.tar.gz
cd cpp-dotenv/cpp-dotenv && patch src/dotenv.cpp < ../dotenv.cpp.patch
cd cpp-dotenv/cpp-dotenv && patch include/dotenv.h < ../dotenv.h.patch
cd cpp-dotenv/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug
cd cpp-dotenv/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE}
cpp-dotenv: cpp-dotenv/cpp-dotenv/libcpp_dotenv.a
debug: libtap.a libtap.so

command_line.o: command_line.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so
g++ -fPIC -c command_line.cpp -std=c++11 $(INCLUDEDIRS) $(OPT)

utils.o: utils.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so
g++ -fPIC -c utils.cpp -std=c++11 $(INCLUDEDIRS) $(OPT)

tap.o: tap.cpp cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a libcurl.so libssl.so.3 libcrypto.so.3 libcpp_dotenv.so
g++ -fPIC -c tap.cpp -std=c++11 $(INCLUDEDIRS) $(OPT)

libtap.a: tap.cpp tap.h command_line.cpp command_line.h utils.cpp utils.h tap.o command_line.o utils.o cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a
ar rcs libtap.a tap.o command_line.o utils.o $(SQLITE3_LDIR)/sqlite3.o

libtap.so: libtap.a cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so
gcc -shared -o libtap.so -Wl,--whole-archive libtap.a ../../../deps/curl/curl/lib/.libs/libcurl.a ../../../deps/libssl/openssl/libcrypto.a ../../../deps/libssl/openssl/libssl.a -Wl,--no-whole-archive

libssl.so.3: $(DEPS_PATH)/libssl/openssl/libssl.so.3
cp -a $(DEPS_PATH)/libssl/openssl/libssl.so* .

libcrypto.so.3: $(DEPS_PATH)/libssl/openssl/libcrypto.so.3
cp -a $(DEPS_PATH)/libssl/openssl/libcrypto.so* .

libcpp_dotenv.so: cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so
find cpp-dotenv/dynamic/cpp-dotenv/ -name '*.so' -exec cp -a {} . \;

libcurl.so: $(DEPS_PATH)/curl/curl/lib/.libs/libcurl.so
cp -a $(DEPS_PATH)/curl/curl/lib/.libs/libcurl.so* .

cpp-dotenv/static/cpp-dotenv/libcpp_dotenv.a:
cd cpp-dotenv/static && rm -rf cpp-dotenv-*/ || true
cd cpp-dotenv/static && tar -zxf ../cpp-dotenv-*.tar.gz
cd cpp-dotenv/static/cpp-dotenv && patch src/dotenv.cpp < ../../dotenv.cpp.patch
cd cpp-dotenv/static/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch
cd cpp-dotenv/static/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_BUILD_TYPE=Debug
cd cpp-dotenv/static/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE}

cpp-dotenv/dynamic/cpp-dotenv/libcpp_dotenv.so:
cd cpp-dotenv/dynamic && rm -rf cpp-dotenv-*/ || true
cd cpp-dotenv/dynamic && tar -zxf ../cpp-dotenv-*.tar.gz
cd cpp-dotenv/dynamic/cpp-dotenv && patch src/dotenv.cpp < ../../dotenv.cpp.patch
cd cpp-dotenv/dynamic/cpp-dotenv && patch include/dotenv.h < ../../dotenv.h.patch
cd cpp-dotenv/dynamic/cpp-dotenv && cmake . -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug
cd cpp-dotenv/dynamic/cpp-dotenv && CC=${CC} CXX=${CXX} ${MAKE}
File renamed without changes.
1 change: 1 addition & 0 deletions test/tap/tap/cpp-dotenv/static/cpp-dotenv
11 changes: 0 additions & 11 deletions test/tap/tap/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,17 +595,6 @@ int wait_for_replication(
return result;
}

MARIADB_CHARSET_INFO * proxysqlTap_find_charset_collate(const char *collatename) {
MARIADB_CHARSET_INFO *c = (MARIADB_CHARSET_INFO *)mariadb_compiled_charsets;
do {
if (!strcasecmp(c->name, collatename)) {
return c;
}
++c;
} while (c[0].nr != 0);
return NULL;
}

int create_proxysql_user(
MYSQL* proxysql_admin,
const string& user,
Expand Down
2 changes: 2 additions & 0 deletions test/tap/tap/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,13 @@ int wait_for_replication(
* NOTE: This is a duplicate of 'proxysql_find_charset_collate' in 'MySQL_Variables.h'. Including
* 'MySQL_Variables' is not a easy task due to its interdependeces with other ProxySQL modules.
*/
/*
#ifdef LIBMYSQL_HELPER
MY_CHARSET_INFO * proxysqlTap_find_charset_collate(const char *collatename);
#else
MARIADB_CHARSET_INFO * proxysqlTap_find_charset_collate(const char *collatename);
#endif
*/
/**
* @brief Creates the new supplied user in ProxySQL with the provided
* attributes.
Expand Down
2 changes: 2 additions & 0 deletions test/tap/tests/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
TAP_ENV_VAR1=.env

# suppress env load messages
TAP_QUIET_ENVLOAD=1
# override the default for this PR
TAP_USERNAME=testuser
TAP_PASSWORD=testuser
37 changes: 21 additions & 16 deletions test/tap/tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ COREDUMPER_DIR=$(DEPS_PATH)/coredumper/coredumper
COREDUMPER_IDIR=$(COREDUMPER_DIR)/include
COREDUMPER_LDIR=$(COREDUMPER_DIR)/src

DOTENV_DIR=../tap/cpp-dotenv/cpp-dotenv
DOTENV_IDIR=$(DOTENV_DIR)/include
DOTENV_LDIR=$(DOTENV_DIR)

IDIR=../../../include
LDIR=../../../lib
TAP_LIBDIR=../tap

DOTENV_DYN_DIR=../tap/cpp-dotenv/dynamic/cpp-dotenv
DOTENV_DYN_IDIR=$(DOTENV_DYN_DIR)/include
#DOTENV_DYN_LDIR=$(DOTENV_DYN_DIR)
DOTENV_DYN_LDIR=$(TAP_LIBDIR)

LIBPROXYSQLAR=$(LDIR)/libproxysql.a

ODIR=../../../obj
Expand All @@ -81,18 +82,20 @@ EXECUTABLE=proxysql

OBJ=../../../src/obj/proxysql_global.o ../../../src/obj/main.o ../../../src/obj/proxy_tls.o

INCLUDEDIRS=-I../tap -I$(RE2_PATH) -I$(IDIR) -I$(JEMALLOC_IDIR) -I$(SQLITE3_DIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(DAEMONPATH_IDIR) -I$(MARIADB_IDIR) -I$(SSL_IDIR) -I$(JSON_IDIR) -I$(LIBCONFIG_IDIR) -I$(PROMETHEUS_IDIR) -I$(EV_IDIR) -I$(DOTENV_IDIR)
LDIRS=-L$(TAP_LIBDIR) -L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(SSL_LDIR) -L$(PROMETHEUS_LDIR)
INCLUDEDIRS=-I../tap -I$(RE2_PATH) -I$(IDIR) -I$(JEMALLOC_IDIR) -I$(SQLITE3_DIR) -I$(MICROHTTPD_IDIR) -I$(LIBHTTPSERVER_IDIR) -I$(CURL_IDIR) -I$(DAEMONPATH_IDIR) -I$(MARIADB_IDIR) -I$(SSL_IDIR) -I$(JSON_IDIR) -I$(LIBCONFIG_IDIR) -I$(PROMETHEUS_IDIR) -I$(EV_IDIR) -I$(DOTENV_DYN_IDIR)
LDIRS=-L$(TAP_LIBDIR) -L$(DOTENV_DYN_LDIR) -L$(LDIR) -L$(JEMALLOC_LDIR) $(LIBCONFIG_LDIR) -L$(RE2_PATH)/obj -L$(MARIADB_LDIR) -L$(DAEMONPATH_LDIR) -L$(PCRE_LDIR) -L$(MICROHTTPD_LDIR) -L$(LIBHTTPSERVER_LDIR) -L$(LIBINJECTION_LDIR) -L$(CURL_LDIR) -L$(EV_LDIR) -L$(PROMETHEUS_LDIR)

UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
LDIRS+= -L$(COREDUMPER_LDIR)
endif

MYLIBS=-Wl,--export-dynamic -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -ltap -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lssl -lcrypto -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lgnutls -lpthread -lm -lz -lrt -ldl $(EXTRALINK)
MYLIBS=-Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lcurl -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK)
#MYLIBS=-Wl,--export-dynamic -Wl,-Bdynamic -lssl -lcrypto -lgnutls -ltap -lcpp_dotenv -Wl,-Bstatic -lconfig -lproxysql -ldaemon -lconfig++ -lre2 -lpcrecpp -lpcre -lmariadbclient -lhttpserver -lmicrohttpd -linjection -lev -lprometheus-cpp-pull -lprometheus-cpp-core -luuid -Wl,-Bdynamic -lpthread -lm -lz -lrt -ldl $(EXTRALINK)
MYLIBSJEMALLOC=-Wl,-Bstatic -ljemalloc
STATIC_LIBS= $(SSL_LDIR)/libssl.a $(SSL_LDIR)/libcrypto.a $(CITYHASH_LDIR)/libcityhash.a
STATIC_LIBS= $(CITYHASH_LDIR)/libcityhash.a
#STATIC_LIBS= $(SSL_LDIR)/libssl.a $(SSL_LDIR)/libcrypto.a $(CITYHASH_LDIR)/libcityhash.a

LIBCOREDUMPERAR=

Expand Down Expand Up @@ -150,7 +153,7 @@ py-%:
cp $(patsubst py-%,%,$@) $(patsubst py-%.py,%,$@)
chmod +x $(patsubst py-%.py,%,$@)

%-t: %-t.cpp $(TAP_LIBDIR)/libtap.a
%-t: %-t.cpp $(TAP_LIBDIR)/libtap.so
$(CXX) -std=c++11 $< $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) $(STATIC_LIBS) -o $@
# $(CXX) -std=c++11 $< $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl $(STATIC_LIBS) $(TAP_LIBDIR)/libtap.a -o $@

Expand Down Expand Up @@ -201,26 +204,28 @@ setparser_test3-t: setparser_test3
setparser_test3: setparser_test3.cpp $(TAP_LIBDIR)/libtap.a $(LDIR)/set_parser.cpp setparser_test_common.h $(LIBCOREDUMPERAR)
g++ -DDEBUG -DPARSERDEBUG setparser_test3.cpp $(LDIR)/set_parser.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) -std=c++11 $(MYLIBS) $(WASAN) $(LIBCOREDUMPERAR) -o setparser_test3 -DGITVERSION=\"$(GIT_VERSION)\"

reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cpp
CUSTOMARGS=-DGITVERSION=\"$(GIT_VERSION)\" -I$(SQLITE3_DIR) -I$(IDIR) -I$(CURL_IDIR) -I$(JSON_IDIR) -I../tap -L$(TAP_LIBDIR) -L$(CURL_LDIR) -Wl,-Bstatic -lcurl -Wl,-Bdynamic -ltap -lcpp_dotenv -lpthread -std=c++11 -lz -ldl

reg_test_3504-change_user_libmariadb_helper: reg_test_3504-change_user_helper.cpp $(TAP_LIBDIR)/libtap.so
$(CXX) -DDEBUG reg_test_3504-change_user_helper.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -std=c++11 $(STATIC_LIBS) -o reg_test_3504-change_user_libmariadb_helper -DGITVERSION=\"$(GIT_VERSION)\"

reg_test_3504-change_user_libmysql_helper: reg_test_3504-change_user_helper.cpp
$(CXX) -DLIBMYSQL_HELPER -DDEBUG reg_test_3504-change_user_helper.cpp -I/usr/include/mysql -I$(CURL_IDIR) -I$(SQLITE3_DIR) -I$(IDIR) -I$(JSON_IDIR) -I../tap -L$(TAP_LIBDIR) -lpthread -ldl -std=c++11 -ltap -lmysqlclient -o reg_test_3504-change_user_libmysql_helper -DGITVERSION=\"$(GIT_VERSION)\"
$(CXX) -DLIBMYSQL_HELPER reg_test_3504-change_user_helper.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_3504-change_user_libmysql_helper

test_clickhouse_server_libmysql-t: test_clickhouse_server-t.cpp
$(CXX) -DLIBMYSQL_HELPER -DDEBUG test_clickhouse_server-t.cpp -I/usr/include/mysql -I$(CURL_IDIR) -I$(SQLITE3_DIR) -I$(IDIR) -I$(JSON_IDIR) -I../tap -L$(TAP_LIBDIR) -lpthread -ldl -std=c++11 -ltap -lmysqlclient -o test_clickhouse_server_libmysql-t -DGITVERSION=\"$(GIT_VERSION)\"
$(CXX) -DLIBMYSQL_HELPER -DDEBUG test_clickhouse_server-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o test_clickhouse_server_libmysql-t

reg_test_stmt_resultset_err_no_rows_libmysql-t: reg_test_stmt_resultset_err_no_rows-t.cpp
$(CXX) -DLIBMYSQL_HELPER reg_test_stmt_resultset_err_no_rows-t.cpp -I/usr/include/mysql -I$(CURL_IDIR) -I$(SQLITE3_DIR) -I$(IDIR) -I$(JSON_IDIR) -I../tap $(OPT) -L$(TAP_LIBDIR) -lpthread -ldl -std=c++11 -ltap -lmysqlclient -o reg_test_stmt_resultset_err_no_rows_libmysql-t -DGITVERSION=\"$(GIT_VERSION)\"
$(CXX) -DLIBMYSQL_HELPER reg_test_stmt_resultset_err_no_rows-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_stmt_resultset_err_no_rows_libmysql-t

reg_test_mariadb_stmt_store_result_libmysql-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LIBDIR)/libtap.a
$(CXX) -DLIBMYSQL_HELPER reg_test_mariadb_stmt_store_result-t.cpp -I/usr/include/mysql -I$(CURL_IDIR) -I$(SQLITE3_DIR) -I$(IDIR) -I$(JSON_IDIR) -I../tap $(OPT) -L$(TAP_LIBDIR) -lpthread -ldl -std=c++11 -ltap -lmysqlclient -o reg_test_mariadb_stmt_store_result_libmysql-t -DGITVERSION=\"$(GIT_VERSION)\"
$(CXX) -DLIBMYSQL_HELPER reg_test_mariadb_stmt_store_result-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o reg_test_mariadb_stmt_store_result_libmysql-t

reg_test_mariadb_stmt_store_result_async-t: reg_test_mariadb_stmt_store_result-t.cpp $(TAP_LIBDIR)/libtap.a
$(CXX) -DASYNC_API reg_test_mariadb_stmt_store_result-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o reg_test_mariadb_stmt_store_result_async-t -DGITVERSION=\"$(GIT_VERSION)\"
$(CXX) -DASYNC_API reg_test_mariadb_stmt_store_result-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o reg_test_mariadb_stmt_store_result_async-t

prepare_statement_err3024_libmysql-t: prepare_statement_err3024-t.cpp $(TAP_LIBDIR)/libtap.a
$(CXX) -DLIBMYSQL_HELPER prepare_statement_err3024-t.cpp -I/usr/include/mysql -I$(CURL_IDIR) -I$(SQLITE3_DIR) -I$(IDIR) -I$(JSON_IDIR) -I../tap $(OPT) -L$(TAP_LIBDIR) -lpthread -ldl -std=c++11 -ltap -lmysqlclient -o prepare_statement_err3024_libmysql-t -DGITVERSION=\"$(GIT_VERSION)\"
$(CXX) -DLIBMYSQL_HELPER prepare_statement_err3024-t.cpp -I/usr/include/mysql $(CUSTOMARGS) -lmysqlclient -o prepare_statement_err3024_libmysql-t

prepare_statement_err3024_async-t: prepare_statement_err3024-t.cpp $(TAP_LIBDIR)/libtap.a
$(CXX) -DASYNC_API prepare_statement_err3024-t.cpp $(INCLUDEDIRS) $(LDIRS) $(OPT) $(MYLIBS) -lpthread -ldl -std=c++11 -ltap $(STATIC_LIBS) -o prepare_statement_err3024_async-t -DGITVERSION=\"$(GIT_VERSION)\"
Expand Down
2 changes: 1 addition & 1 deletion test/tap/tests/kill_connection3-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int main(int argc, char** argv) {
rc = run_q(proxysql_admin, s.c_str());
ok(rc == 0 , "%s" , s.c_str());
}

sleep(1);
for (int i = 0; i < NUM_CONNS ; i++) {
MYSQL * mysql = conns[i];
int rc = run_q(mysql, "DO 1");
Expand Down
2 changes: 1 addition & 1 deletion test/tap/tests/mysql-test_ssl_CA-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char** argv) {

{
// const char *q = "SELECT DISTINCT hostgroup_id FROM runtime_mysql_servers WHERE status='ONLINE' AND hostgroup_id IN (0,1,10,11,20,30,31,50,60,1710,1711)";
const char *q = "SELECT DISTINCT hostgroup_id FROM runtime_mysql_servers WHERE status='ONLINE'";
const char *q = "SELECT DISTINCT hostgroup_id FROM runtime_mysql_servers WHERE status='ONLINE' AND comment LIKE '%mysql%'";
diag("Running query: %s", q);
MYSQL_QUERY(mysqladmin, q);
res = mysql_store_result(mysqladmin);
Expand Down
6 changes: 3 additions & 3 deletions test/tap/tests/reg_test_3765_ssl_pollout-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int create_connections(const conn_opts_t& conn_opts, uint32_t cons_num, std::vec
const uint32_t ADMIN_CONN_NUM = 100;
const uint32_t MYSQL_CONN_NUM = 100;
const uint32_t REPORT_INTV_SEC = 5;
const double MAX_ALLOWED_CPU_USAGE = 10.0;
const double MAX_ALLOWED_CPU_USAGE = 13.0;

int get_idle_conns_cpu_usage(CommandLine& cl, uint64_t mode, double& idle_cpu_ms, double& final_cpu_ms) {
// get ProxySQL idle cpu usage
Expand All @@ -69,8 +69,8 @@ int get_idle_conns_cpu_usage(CommandLine& cl, uint64_t mode, double& idle_cpu_ms
return idle_err;
}

conn_opts_t proxy_conns_opts { "127.0.0.1", cl.username, cl.password, cl.port, mode };
conn_opts_t admin_conns_opts { "127.0.0.1", cl.admin_username, cl.admin_password, cl.admin_port, mode };
conn_opts_t proxy_conns_opts { cl.host, cl.username, cl.password, cl.port, mode };
conn_opts_t admin_conns_opts { cl.admin_host, cl.admin_username, cl.admin_password, cl.admin_port, mode };

// Create 'N' admin and mysql connections without SSL
vector<MYSQL*> v_admin_conns {};
Expand Down
3 changes: 1 addition & 2 deletions test/tap/tests/test_backend_conn_ping-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ int check_backend_conns(
uint64_t act_proxy_used_conn_count = 0;

uint32_t total_wait_time = 40;
uint32_t intv = 5;
uint32_t intv = 10;
uint32_t total_checks = total_wait_time / intv;

for (uint32_t check_num = 0; check_num < total_checks; check_num++) {
Expand Down Expand Up @@ -297,7 +297,6 @@ int check_backend_conns(
" AND schema='backend_conn_ping_test'"
" AND srv_port IN (" + srv_ports + ")"
};

q_res = get_query_result(admin, proxy_query, act_proxy_free_conn_count);
if (q_res != EXIT_SUCCESS) {
fprintf(stderr, "File %s, line %d, Error: %s\n", __FILE__, __LINE__, "get_query_result() failed");
Expand Down
23 changes: 19 additions & 4 deletions test/tap/tests/test_clickhouse_server-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ std::vector<std::pair<std::string,std::string>> credentials = {
{"cliuser4", "clipass4"}
};

int set_clickhouse_host(MYSQL *pa, const char *h) {
std::string query = "SET clickhouse-host=" + std::string(h);
diag("Line: %d . Setting clickhouse-host to '%s'", __LINE__ , h);
MYSQL_QUERY(pa, query.c_str());
MYSQL_QUERY(pa, "LOAD CLICKHOUSE VARIABLES TO RUNTIME");
return 0;
}

int set_clickhouse_port(MYSQL *pa, int p) {
std::string query = "SET clickhouse-port=" + std::to_string(p);
diag("Line: %d . Setting clickhouse-port to %d", __LINE__ , p);
diag("Line: %d . Setting clickhouse-port to '%d'", __LINE__ , p);
MYSQL_QUERY(pa, query.c_str());
MYSQL_QUERY(pa, "LOAD CLICKHOUSE VARIABLES TO RUNTIME");
return 0;
Expand Down Expand Up @@ -403,10 +411,17 @@ int main(int argc, char** argv) {
goto cleanup;
}

set_clickhouse_port(proxysql_admin,8000);
set_clickhouse_port(proxysql_admin, 8000);
test_crash(host_port.first.c_str(), host_port.second);
set_clickhouse_port(proxysql_admin,19000);
// set_clickhouse_port(proxysql_admin,9000);

const std::string docker_mode = getenv("DOCKER_MODE");
if (docker_mode.find("dns") == docker_mode.size() - 3) {
set_clickhouse_host(proxysql_admin, "clickhouse");
set_clickhouse_port(proxysql_admin, 9000);
} else {
set_clickhouse_host(proxysql_admin, "127.0.0.1");
set_clickhouse_port(proxysql_admin, 19000);
}

MYSQL* proxysql_clickhouse = mysql_init(NULL);

Expand Down
11 changes: 11 additions & 0 deletions test/tap/tests/test_com_reset_connection_com_change_user-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ const std::vector<std::string> tracked_variables {
"wsrep_sync_wait"
};

MARIADB_CHARSET_INFO * proxysqlTap_find_charset_collate(const char *collatename) {
MARIADB_CHARSET_INFO *c = (MARIADB_CHARSET_INFO *)mariadb_compiled_charsets;
do {
if (!strcasecmp(c->name, collatename)) {
return c;
}
++c;
} while (c[0].nr != 0);
return NULL;
}

void variable_rows_to_json(MYSQL_RES *result, json& j) {
if(!result) return;
MYSQL_ROW row;
Expand Down
4 changes: 2 additions & 2 deletions test/tap/tests/test_query_rules_fast_routing_algorithm-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int test_fast_routing_algorithm(
if (c_err) { return EXIT_FAILURE; }
MYSQL_QUERY_T(admin, "LOAD MYSQL QUERY RULES TO RUNTIME");

usleep(100*1000);
usleep(1000*1000);

// Seek end of file for error log
errlog.seekg(0, std::ios::end);
Expand Down Expand Up @@ -289,7 +289,7 @@ int test_fast_routing_algorithm(
MYSQL_QUERY_T(admin, ("SET mysql-query_rules_fast_routing_algorithm=" + std::to_string(new_algo)).c_str());
MYSQL_QUERY_T(admin, "LOAD MYSQL VARIABLES TO RUNTIME");

usleep(100*1000);
usleep(1000*1000);

// Seek end of file for error log
errlog.seekg(0, std::ios::end);
Expand Down
Loading

0 comments on commit 7d81a23

Please sign in to comment.