1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-07 02:42:49 +03:00

Test and travis modification for testing against SkySQL

This commit is contained in:
Georg Richter
2020-09-02 14:08:19 +02:00
parent c1c5a73199
commit 9637689e5e
9 changed files with 117 additions and 41 deletions

View File

@@ -37,6 +37,8 @@ static int test_conc75(MYSQL *my)
int i;
my_bool reconnect= 1;
SKIP_SKYSQL;
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
@@ -144,6 +146,8 @@ static int test_conc70(MYSQL *my)
SKIP_CONNECTION_HANDLER;
SKIP_SKYSQL;
mysql= mysql_init(NULL);
rc= mysql_query(my, "SET @a:=@@max_allowed_packet");
@@ -205,6 +209,8 @@ static int test_conc68(MYSQL *my)
MYSQL *mysql;
SKIP_CONNECTION_HANDLER;
SKIP_SKYSQL;
mysql= mysql_init(NULL);
@@ -259,8 +265,9 @@ static int basic_connect(MYSQL *unused __attribute__((unused)))
MYSQL_RES *res;
MYSQL_FIELD *field;
int rc;
MYSQL *my;
MYSQL *my= mysql_init(NULL);
my= mysql_init(NULL);
FAIL_IF(!my, "mysql_init() failed");
FAIL_IF(!my_test_connect(my, hostname, username, password, schema,

View File

@@ -12,6 +12,11 @@ int main(int argc, char *argv[]) {
get_envvars();
if (IS_SKYSQL(hostname))
return 0;
diag("hostname: %s", hostname);
for (i = 0; i < MAX_COUNT; ++i) {
if (mysql_library_init(-1, NULL, NULL) != 0) {
@@ -25,6 +30,9 @@ int main(int argc, char *argv[]) {
return 1;
}
if (force_tls)
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &force_tls);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0)) {
diag("mysql_real_connect failed: %s", mysql_error(mysql));
return 1;

View File

@@ -34,6 +34,8 @@ static int test_conc66(MYSQL *my)
FILE *fp;
char query[1024];
SKIP_SKYSQL;
if (!(fp= fopen("./my-conc66-test.cnf", "w")))
return FAIL;
@@ -85,6 +87,8 @@ static int test_bug20023(MYSQL *mysql)
int sql_big_selects_5;
int rc;
SKIP_SKYSQL;
if (!is_mariadb)
return SKIP;
@@ -669,7 +673,11 @@ int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
{
unsigned int timeout= 5;
time_t start, elapsed;
MYSQL *mysql= mysql_init(NULL);
MYSQL *mysql;
SKIP_SKYSQL;
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (unsigned int *)&timeout);
mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=SLEEP(6)");
start= time(NULL);
@@ -791,6 +799,8 @@ static int test_bind_address(MYSQL *my)
char query[128];
int rc;
SKIP_SKYSQL;
if (!hostname || !strcmp(hostname, "localhost"))
{
diag("test doesn't work with unix sockets");
@@ -994,6 +1004,8 @@ static int test_unix_socket_close(MYSQL *unused __attribute__((unused)))
FILE *fp;
int i;
SKIP_SKYSQL;
if (!(fp= fopen("./dummy_sock", "w")))
{
diag("couldn't create dummy socket");
@@ -1003,7 +1015,7 @@ static int test_unix_socket_close(MYSQL *unused __attribute__((unused)))
for (i=0; i < 10000; i++)
{
mysql_real_connect(mysql, "localhost", "user", "passwd", NULL, 0, "./dummy_sock", 0);
my_test_connect(mysql, "localhost", "user", "passwd", NULL, 0, "./dummy_sock", 0);
/* check if we run out of sockets */
if (mysql_errno(mysql) == 2001)
{
@@ -1081,6 +1093,9 @@ static int test_auth256(MYSQL *my)
my_ulonglong num_rows= 0;
char query[1024];
if (IS_SKYSQL(hostname))
return SKIP;
if (!mysql_client_find_plugin(mysql, "sha256_password", MYSQL_CLIENT_AUTHENTICATION_PLUGIN))
{
diag("sha256_password plugin not available");
@@ -1109,7 +1124,7 @@ static int test_auth256(MYSQL *my)
rc= mysql_query(my, query);
check_mysql_rc(rc, my);
if (!mysql_real_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
if (!my_test_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
{
diag("error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -1119,7 +1134,7 @@ static int test_auth256(MYSQL *my)
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_SERVER_PUBLIC_KEY, "rsa_public_key.pem");
if (!mysql_real_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
if (!my_test_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
{
diag("error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -1283,7 +1298,7 @@ static int test_conc276(MYSQL *unused __attribute__((unused)))
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &val);
mysql_options(mysql, MYSQL_OPT_RECONNECT, &val);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, 0))
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, 0))
{
diag("Connection failed. Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -1389,6 +1404,8 @@ static int test_conc317(MYSQL *unused __attribute__((unused)))
const char *env= getenv("MYSQL_TMP_DIR");
char cnf_file1[FN_REFLEN + 1];
SKIP_SKYSQL;
if (travis_test)
return SKIP;
@@ -1430,6 +1447,8 @@ static int test_conc327(MYSQL *unused __attribute__((unused)))
char cnf_file1[FN_REFLEN + 1];
char cnf_file2[FN_REFLEN + 1];
SKIP_SKYSQL;
if (travis_test)
return SKIP;
@@ -1587,7 +1606,7 @@ static int test_conc312(MYSQL *my)
check_mysql_rc(rc, my);
mysql= mysql_init(NULL);
if (!mysql_real_connect(mysql, hostname, "foo", "foo", schema, port, socketname, 0))
if (!my_test_connect(mysql, hostname, "foo", "foo", schema, port, socketname, 0))
{
diag("Error: %s", mysql_error(mysql));
return FAIL;
@@ -1608,6 +1627,8 @@ static int test_conc366(MYSQL *mysql)
int rc;
MYSQL *my;
SKIP_SKYSQL;
if (!is_mariadb)
{
diag("feature not supported by MySQL server");
@@ -1640,7 +1661,7 @@ static int test_conc366(MYSQL *mysql)
my= mysql_init(NULL);
if (plugindir)
mysql_options(my, MYSQL_PLUGIN_DIR, plugindir);
if (!mysql_real_connect(my, hostname, "ede", "foo", schema, port, socketname, 0))
if (!my_test_connect(my, hostname, "ede", "foo", schema, port, socketname, 0))
{
diag("Error: %s", mysql_error(my));
return FAIL;
@@ -1697,7 +1718,7 @@ static int test_conc443(MYSQL *my __attribute__((unused)))
mysql_options(mysql, MYSQL_INIT_COMMAND, "set @a:=3");
mysql_options(mysql, MYSQL_OPT_RECONNECT, &x);
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
{
diag("Connection failed. Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -1740,7 +1761,7 @@ static int test_default_auth(MYSQL *my __attribute__((unused)))
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_DEFAULT_AUTH, "mysql_clear_password");
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
{
diag("Connection failed. Error: %s", mysql_error(mysql));
mysql_close(mysql);
@@ -1751,7 +1772,7 @@ static int test_default_auth(MYSQL *my __attribute__((unused)))
mysql= mysql_init(NULL);
mysql_options(mysql, MYSQL_DEFAULT_AUTH, "caching_sha2_password");
if (!mysql_real_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
if (!my_test_connect(mysql, hostname, username, password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
{
diag("Connection failed. Error: %s", mysql_error(mysql));
mysql_close(mysql);

View File

@@ -38,6 +38,8 @@ static int test_bug28075(MYSQL *mysql)
{
int rc;
SKIP_SKYSQL;
rc= mysql_dump_debug_info(mysql);
check_mysql_rc(rc, mysql);
@@ -768,6 +770,8 @@ static int test_bug49694(MYSQL *mysql)
int i;
FILE *fp;
SKIP_SKYSQL;
rc= mysql_query(mysql, "DROP TABLE IF EXISTS enclist");
check_mysql_rc(rc, mysql);
@@ -805,7 +809,10 @@ static int test_conc49(MYSQL *mysql)
int rc;
MYSQL_RES *res;
int i;
FILE *fp= fopen("./sample.csv", "w");
FILE *fp;
SKIP_SKYSQL;
fp= fopen("./sample.csv", "w");
for (i=1; i < 4; i++)
fprintf(fp, "\"%d\", \"%d\", \"%d\"\r\n", i, i, i);
fclose(fp);
@@ -1014,6 +1021,7 @@ void *remote_plugin;
static int test_remote1(MYSQL *mysql)
{
int rc;
SKIP_SKYSQL;
remote_plugin= (void *)mysql_client_find_plugin(mysql, "remote_io", MARIADB_CLIENT_REMOTEIO_PLUGIN);
if (!remote_plugin)
@@ -1069,6 +1077,7 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused)))
const char *env= getenv("MYSQL_TMP_DIR");
char cnf_file1[FN_REFLEN + 1];
SKIP_SKYSQL;
if (travis_test)
return SKIP;
@@ -1353,6 +1362,7 @@ static int test_conc395(MYSQL *unused __attribute__((unused)))
const char *env= getenv("MYSQL_TMP_DIR");
char cnf_file1[FN_REFLEN + 1];
SKIP_SKYSQL;
if (travis_test)
return SKIP;
@@ -1391,6 +1401,8 @@ static int test_sslenforce(MYSQL *unused __attribute__((unused)))
const char *env= getenv("MYSQL_TMP_DIR");
char cnf_file1[FN_REFLEN + 1];
SKIP_SKYSQL;
if (travis_test)
return SKIP;
@@ -1400,10 +1412,6 @@ static int test_sslenforce(MYSQL *unused __attribute__((unused)))
snprintf(cnf_file1, FN_REFLEN, "%s%c.my.cnf", env, FN_LIBCHAR);
if (travis_test)
return SKIP;
FAIL_IF(!access(cnf_file1, R_OK), "access");
mysql= mysql_init(NULL);

View File

@@ -55,6 +55,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
# define TRUE 1
#endif
#define IS_SKYSQL(a) ((a) && strstr((a), "db.skysql.net"))
#define SKIP_SKYSQL \
if (IS_SKYSQL(hostname)) \
{ \
diag("Not supported by SkySQL"); \
return SKIP; \
}
#define MAX_KEY MAX_INDEXES
#define MAX_KEY_LENGTH_DECIMAL_WIDTH 4 /* strlen("4096") */
@@ -524,6 +532,8 @@ void get_envvars() {
if (!hostname && (envvar= getenv("MYSQL_TEST_HOST")))
hostname= envvar;
if (!username)
{
if ((envvar= getenv("MYSQL_TEST_USER")))

View File

@@ -3729,6 +3729,8 @@ static int test_nstmts(MYSQL *mysql)
static uint i, total_stmts= 2000;
MYSQL_BIND my_bind[1];
SKIP_SKYSQL;
mysql_autocommit(mysql, TRUE);
rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_nstmts");

View File

@@ -2928,6 +2928,8 @@ static int test_bug6059(MYSQL *mysql)
const char *stmt_text;
int rc;
SKIP_SKYSQL;
stmt_text= "SELECT 'foo' INTO OUTFILE 'x.3'";
stmt= mysql_stmt_init(mysql);