summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnel Husakovic <anel@mariadb.org>2020-12-01 21:38:22 +0100
committerAnel Husakovic <anel@mariadb.org>2020-12-07 10:21:38 +0100
commitbc2dc83cb56851144a8c15e73a83c7817dc705a2 (patch)
tree637e9cb85aa44616c6f6a4928608c34650c412ce
parent47c4caf1bfe1a2edc475aad6bba945a60e9cc754 (diff)
downloadmariadb-git-bc2dc83cb56851144a8c15e73a83c7817dc705a2.tar.gz
MDEV-22485: add the test casebb-10.3-anel-MDEV-22485-mysqlslap
Closes PR #1649
-rw-r--r--mysql-test/main/mysqlslap.opt1
-rw-r--r--mysql-test/main/mysqlslap.result100
-rw-r--r--mysql-test/main/mysqlslap.test51
3 files changed, 152 insertions, 0 deletions
diff --git a/mysql-test/main/mysqlslap.opt b/mysql-test/main/mysqlslap.opt
index 632f5b4c069..da7672849bb 100644
--- a/mysql-test/main/mysqlslap.opt
+++ b/mysql-test/main/mysqlslap.opt
@@ -1 +1,2 @@
--sql_mode='NO_ENGINE_SUBSTITUTION'
+--log-output=TABLE,FILE --general-log=0 --slow-query-log=0
diff --git a/mysql-test/main/mysqlslap.result b/mysql-test/main/mysqlslap.result
index 791cb5ac6b3..a83d4d38a16 100644
--- a/mysql-test/main/mysqlslap.result
+++ b/mysql-test/main/mysqlslap.result
@@ -258,3 +258,103 @@ DROP TABLE t1;
#
# Bug MDEV-15789 (Upstream: #80329): MYSQLSLAP OPTIONS --AUTO-GENERATE-SQL-GUID-PRIMARY and --AUTO-GENERATE-SQL-SECONDARY-INDEXES DONT WORK
#
+#
+# MDEV-22485: mysqlslap does not use current user as default for connecting to server
+#
+set @old_general_log=@@global.general_log;
+set @old_general_log_file=@@global.general_log_file;
+select @old_general_log;
+@old_general_log
+0
+show global variables
+where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+Variable_name Value
+general_log OFF
+slow_query_log OFF
+truncate table mysql.general_log;
+select * from mysql.general_log;
+event_time user_host thread_id server_id command_type argument
+set global general_log=ON;
+current_user.log;
+@@current_user.log
+current_user.log
+SET GLOBAL general_log_file=general_log.log;
+show global variables
+where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+Variable_name Value
+general_log ON
+slow_query_log OFF
+flush logs;
+create user anel@localhost;
+grant all on *.* to anel@localhost;
+connect con1,localhost,anel,,;
+connection con1;
+create table t(t int);
+# Run mysqlslap user anel
+Benchmark
+ Average number of seconds to run all queries: X seconds
+ Minimum number of seconds to run all queries: X seconds
+ Maximum number of seconds to run all queries: X seconds
+ Number of clients running queries: 1
+ Average number of queries per client: 1
+
+flush tables;
+select user_host, command_type, argument from mysql.general_log;
+user_host command_type argument
+root[root] @ localhost [] Query select @@general_log_file
+root[root] @ localhost [] Query SET GLOBAL general_log_file=current_user.log
+root[root] @ localhost [] Query show global variables
+where Variable_name = 'general_log' or Variable_name = 'slow_query_log'
+root[root] @ localhost [] Query flush logs
+root[root] @ localhost [] Query create user anel@localhost
+root[root] @ localhost [] Query grant all on *.* to anel@localhost
+[anel] @ localhost [] Connect anel@localhost as anonymous on test
+anel[anel] @ localhost [] Query create table t(t int)
+[root] @ localhost [] Connect root@localhost as anonymous on
+[root] @ localhost [] Connect root@localhost as anonymous on test
+root[root] @ localhost [] Query SELECT current_user()
+root[root] @ localhost [] Quit
+root[root] @ localhost [] Quit
+anel[anel] @ localhost [] Query flush tables
+anel[anel] @ localhost [] Query select user_host, command_type, argument from mysql.general_log
+disconnect con1;
+connection default;
+# Run mysqlslap user root
+Benchmark
+ Average number of seconds to run all queries: X seconds
+ Minimum number of seconds to run all queries: X seconds
+ Maximum number of seconds to run all queries: X seconds
+ Number of clients running queries: 1
+ Average number of queries per client: 1
+
+flush tables;
+select user_host, command_type, argument from mysql.general_log;
+user_host command_type argument
+root[root] @ localhost [] Query select @@general_log_file
+root[root] @ localhost [] Query SET GLOBAL general_log_file=current_user.log
+root[root] @ localhost [] Query show global variables
+where Variable_name = 'general_log' or Variable_name = 'slow_query_log'
+root[root] @ localhost [] Query flush logs
+root[root] @ localhost [] Query create user anel@localhost
+root[root] @ localhost [] Query grant all on *.* to anel@localhost
+[anel] @ localhost [] Connect anel@localhost as anonymous on test
+anel[anel] @ localhost [] Query create table t(t int)
+[root] @ localhost [] Connect root@localhost as anonymous on
+[root] @ localhost [] Connect root@localhost as anonymous on test
+root[root] @ localhost [] Query SELECT current_user()
+root[root] @ localhost [] Quit
+root[root] @ localhost [] Quit
+anel[anel] @ localhost [] Query flush tables
+anel[anel] @ localhost [] Query select user_host, command_type, argument from mysql.general_log
+anel[anel] @ localhost [] Quit
+[root] @ localhost [] Connect root@localhost as anonymous on
+[root] @ localhost [] Connect root@localhost as anonymous on test
+root[root] @ localhost [] Query SELECT current_user()
+root[root] @ localhost [] Quit
+root[root] @ localhost [] Quit
+root[root] @ localhost [] Query flush tables
+root[root] @ localhost [] Query select user_host, command_type, argument from mysql.general_log
+drop user anel@localhost;
+drop table t;
+set global general_log= @old_general_log;
+set global general_log_file= @old_general_log_file;
diff --git a/mysql-test/main/mysqlslap.test b/mysql-test/main/mysqlslap.test
index 81115d59d09..4e99b8f2cd2 100644
--- a/mysql-test/main/mysqlslap.test
+++ b/mysql-test/main/mysqlslap.test
@@ -88,3 +88,54 @@ DROP TABLE t1;
--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --create-schema=slap
--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-secondary-indexes=1 --create-schema=slap
+
+--echo #
+--echo # MDEV-22485: mysqlslap does not use current user as default for connecting to server
+--echo #
+--disable_ps_protocol
+set @old_general_log=@@global.general_log;
+set @old_general_log_file=@@global.general_log_file;
+select @old_general_log;
+
+show global variables
+where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+truncate table mysql.general_log;
+# empty log at the beginning
+select * from mysql.general_log;
+
+set global general_log=ON;
+--replace_regex /[\/\w:](?!.log).*/current_user.log/
+select @@general_log_file;
+--replace_regex /=.+"/=general_log.log/
+--let $gen_log_file=$MYSQLTEST_VARDIR/tmp/general_log.log
+--replace_regex /".+"/general_log.log/
+--eval SET GLOBAL general_log_file="$gen_log_file"
+show global variables
+where Variable_name = 'general_log' or Variable_name = 'slow_query_log';
+flush logs;
+create user anel@localhost;
+grant all on *.* to anel@localhost;
+connect con1,localhost,anel,,;
+connection con1;
+create table t(t int);
+--echo # Run mysqlslap user anel
+--replace_regex /\d[.]\d+/X/
+--exec $MYSQL_SLAP --create-schema=test --query="SELECT current_user()" --concurrency=1 --iterations=1
+flush tables;
+--replace_regex /".+/current_user.log/ /[::1]//
+select user_host, command_type, argument from mysql.general_log;
+disconnect con1;
+
+connection default;
+--echo # Run mysqlslap user root
+--replace_regex /\d[.]\d+/X/
+--exec $MYSQL_SLAP --create-schema=test --query="SELECT current_user()" --concurrency=1 --iterations=1
+flush tables;
+#--exec $MYSQL_SLAP --concurrency=1 --silent --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-guid-primary --create-schema=slap
+--replace_regex /".+/current_user.log/ /[::1]//
+select user_host, command_type, argument from mysql.general_log;
+drop user anel@localhost;
+drop table t;
+set global general_log= @old_general_log;
+set global general_log_file= @old_general_log_file;
+--enable_ps_protocol