Commit 01cf43c9 authored by unknown's avatar unknown

Add testing of extra port for pool-of-threads.

The additional test uses up all threads in the pool with SELECT
SLEEP(), and tests that this makes normal connections block, but
connections on the extra port still work.

Also test connection limit on extra port with and without
pool-of-threads enabled.

Add --connect-timeout option to mysqltest program.

Add facility for --extra-port option to ConfigFactory.

Fix regexp typo in ConfigFactory.pm
parent 9d29ed5d
......@@ -76,7 +76,7 @@ enum {
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
OPT_MAX_CONNECT_RETRIES, OPT_MARK_PROGRESS, OPT_LOG_DIR, OPT_TAIL_LINES,
OPT_GLOBAL_SUBST
OPT_GLOBAL_SUBST, OPT_MY_CONNECT_TIMEOUT
};
static int record= 0, opt_sleep= -1;
......@@ -87,6 +87,7 @@ const char *opt_include= 0, *opt_charsets_dir;
static int opt_port= 0;
static int opt_max_connect_retries;
static my_bool opt_compress= 0, silent= 0, verbose= 0;
static int opt_connect_timeout= -1;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static my_bool tty_password= 0;
static my_bool opt_mark_progress= 0;
......@@ -4952,6 +4953,9 @@ void do_connect(struct st_command *command)
if (opt_charsets_dir)
mysql_options(&con_slot->mysql, MYSQL_SET_CHARSET_DIR,
opt_charsets_dir);
if (opt_connect_timeout >= 0)
mysql_options(&con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
&opt_connect_timeout);
#ifdef HAVE_OPENSSL
if (opt_use_ssl || con_ssl)
......@@ -5692,6 +5696,9 @@ static struct my_option my_long_options[] =
#include "sslopt-longopts.h"
{"test-file", 'x', "Read test from/in this file (default stdin).",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"connect-timeout", OPT_MY_CONNECT_TIMEOUT, "Client connection timeout",
(uchar**) &opt_connect_timeout, (uchar**) &opt_connect_timeout, 0,
GET_INT, REQUIRED_ARG, -1, -1, 0, 0, 0, 0},
{"timer-file", 'm', "File where the timing in micro seconds is stored.",
0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 't', "Temporary directory where sockets are put.",
......
......@@ -202,6 +202,7 @@ my @mysqld_rules=
{ 'pid-file' => \&fix_pidfile },
{ '#host' => \&fix_host },
{ 'port' => \&fix_port },
{ '#extra-port' => \&fix_port },
{ 'socket' => \&fix_socket },
{ 'log-error' => \&fix_log_error },
{ 'general-log' => sub { return 1; } },
......@@ -353,7 +354,7 @@ sub post_check_client_group {
sub post_check_client_groups {
my ($self, $config)= @_;
my $first_mysqld= $config->first_like('mysqld.');
my $first_mysqld= $config->first_like('mysqld\.');
return unless $first_mysqld;
......
......@@ -215,6 +215,13 @@ SET GLOBAL event_scheduler = OFF;
# -- End of Bug#35074.
SELECT 'Connection on extra port ok';
Connection on extra port ok
Connection on extra port ok
SELECT 'Connection on extra port 2 ok';
Connection on extra port 2 ok
Connection on extra port 2 ok
# -- Success: more than --extra-max-connections + 1 normal connections not possible
# ------------------------------------------------------------------
# -- End of 5.1 tests
# ------------------------------------------------------------------
......@@ -2151,3 +2151,23 @@ Privat (Private Nutzung) Mobilfunk
Warnings:
Warning 1052 Column 'kundentyp' in group statement is ambiguous
drop table t1;
SELECT sleep(5);
SELECT sleep(5);
# -- Success: more than --thread-pool-size normal connections not possible
sleep(5)
0
sleep(5)
0
SELECT sleep(5);
SELECT sleep(5);
SELECT 'Connection on extra port ok';
Connection on extra port ok
Connection on extra port ok
SELECT 'Connection on extra port 2 ok';
Connection on extra port 2 ok
Connection on extra port 2 ok
# -- Success: more than --extra-max-connections + 1 normal connections not possible
sleep(5)
0
sleep(5)
0
!include include/default_my.cnf
[mysqld.1]
extra-port= @mysqld.1.#extra-port
extra-max-connections=1
[ENV]
MASTER_EXTRA_PORT= @mysqld.1.extra-port
......@@ -288,6 +288,33 @@ let $wait_condition =
--echo # -- End of Bug#35074.
--echo
# Test connections to the extra port.
connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connection extracon;
SELECT 'Connection on extra port ok';
connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connection extracon2;
SELECT 'Connection on extra port 2 ok';
--disable_abort_on_error
--disable_result_log
--disable_query_log
connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
--enable_query_log
--enable_result_log
--enable_abort_on_error
let $error = $mysql_errno;
if (!$error)
{
--echo # -- Error: managed to establish more than --extra-max-connections + 1 connections
}
if ($error)
{
--echo # -- Success: more than --extra-max-connections + 1 normal connections not possible
}
--echo # ------------------------------------------------------------------
--echo # -- End of 5.1 tests
--echo # ------------------------------------------------------------------
--test-ignore-wrong-options --thread-handling=pool-of-threads
!include include/default_my.cnf
[mysqld.1]
test-ignore-wrong-options
thread-handling= pool-of-threads
thread_pool_size= 2
extra-port= @mysqld.1.#extra-port
extra-max-connections=1
[client]
connect-timeout= 2
[ENV]
MASTER_EXTRA_PORT= @mysqld.1.extra-port
......@@ -5,3 +5,78 @@
-- source include/common-tests.inc
# Test that we cannot have more simultaneous connections than
# --thread-pool-size on the standard port, but _can_ have additional
# connections on the extra port.
# First set two connections running, and check that extra connection
# on normal port fails due to--thread-pool-size=2
connection default;
send SELECT sleep(5);
connect(con2,localhost,root,,);
connection con2;
send SELECT sleep(5);
--sleep 1
--disable_abort_on_error
--disable_result_log
--disable_query_log
connect(con3,localhost,root,,);
--enable_query_log
--enable_result_log
--enable_abort_on_error
let $error = $mysql_errno;
if (!$error)
{
--echo # -- Error: managed to establish more than --thread-pool-size connections
}
if ($error)
{
--echo # -- Success: more than --thread-pool-size normal connections not possible
}
connection default;
--reap
connection con2;
--reap
# Now try again, but this time use the extra port to successfully connect.
connection default;
send SELECT sleep(5);
connection con2;
send SELECT sleep(5);
--sleep 1
connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connection extracon;
SELECT 'Connection on extra port ok';
connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
connection extracon2;
SELECT 'Connection on extra port 2 ok';
--disable_abort_on_error
--disable_result_log
--disable_query_log
connect(extracon3,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
--enable_query_log
--enable_result_log
--enable_abort_on_error
let $error = $mysql_errno;
if (!$error)
{
--echo # -- Error: managed to establish more than --extra-max-connections + 1 connections
}
if ($error)
{
--echo # -- Success: more than --extra-max-connections + 1 normal connections not possible
}
connection default;
--reap
connection con2;
--reap
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment