summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2020-10-26 16:01:18 +1100
committerDaniel Black <daniel@mariadb.org>2021-01-15 08:46:19 +1100
commit38578ffd2a694fd67f3f55282948885e67ab285c (patch)
tree065f1b687035ffb9b90246291db5176a3f7b51b7
parentea9cd97f855fddf91f011434e8289ce5eba52528 (diff)
downloadmariadb-git-bb-10.2-danielblack-MDEV-24268-mtr-mysql_install_db.tar.gz
MDEV-24268: add MTR test for mysql_install_dbbb-10.2-danielblack-MDEV-24268-mtr-mysql_install_db
-rwxr-xr-xmysql-test/mysql-test-run.pl24
-rw-r--r--mysql-test/r/mysql_install_db.result110
-rw-r--r--mysql-test/t/mysql_install_db.test166
3 files changed, 300 insertions, 0 deletions
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 7b73782eedc..0b10fcabed1 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -2528,6 +2528,30 @@ sub environment_setup {
"--defaults-file=$path_config_file $extra_opts";
# ----------------------------------------------------
+ # mysql_install_db
+ # ----------------------------------------------------
+ if (!IS_WINDOWS)
+ {
+ my $exe_mysql_install_db=
+ mtr_exe_exists("$bindir/scripts/mysql_install_db",
+ "$path_client_bindir/mysql_install_db");
+ $ENV{'MYSQL_INSTALL_DB'}= native_path($exe_mysql_install_db) .
+ " --defaults-file=$path_config_file $extra_opts" .
+ " --defaults-group-suffix=.1 --cross-bootstrap";
+ }
+
+ if ( ! $source_dist )
+ {
+ $ENV{'MYSQL_INSTALL_DB'}.= " --basedir=$basedir";
+ }
+ else
+ {
+ $ENV{'MYSQL_INSTALL_DB'}.=
+ " --srcdir=" . cwd() . "/.." .
+ " --builddir=$bindir";
+ }
+
+ # ----------------------------------------------------
# bug25714 executable may _not_ exist in
# some versions, test using it should be skipped
# ----------------------------------------------------
diff --git a/mysql-test/r/mysql_install_db.result b/mysql-test/r/mysql_install_db.result
new file mode 100644
index 00000000000..6936224e19c
--- /dev/null
+++ b/mysql-test/r/mysql_install_db.result
@@ -0,0 +1,110 @@
+disconnect default;
+connect testcon,localhost,root,,mysql,,;
+connection testcon;
+#
+#
+# mysql_install_db (no args)
+#
+# Kill the server
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+user host plugin password
+ localhost
+root 127.0.0.1
+root ::1
+root localhost
+SHOW DATABASES;
+Database
+information_schema
+mysql
+performance_schema
+test
+SHOW GRANTS FOR root@localhost;
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
+SHOW GRANTS FOR ''@localhost;
+Grants for @localhost
+GRANT USAGE ON *.* TO ''@'localhost'
+#
+#
+# mysql_install_db --auth-root-authentication-method=normal
+#
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+user host plugin password
+ localhost
+root 127.0.0.1
+root ::1
+root localhost
+SHOW DATABASES;
+Database
+information_schema
+mysql
+performance_schema
+test
+SHOW GRANTS FOR root@localhost;
+Grants for root@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
+GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
+SHOW GRANTS FOR ''@localhost;
+Grants for @localhost
+GRANT USAGE ON *.* TO ''@'localhost'
+#
+#
+# mysql_install_db --auth-root-authentication-method=socket \
+# --auth-root-socket-user=$USER
+#
+use test;
+connect unix,localhost,$USER,,mysql;
+connection unix;
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+user host plugin password
+ localhost
+USER localhost unix_socket
+SHOW DATABASES;
+Database
+information_schema
+mysql
+performance_schema
+test
+SHOW GRANTS FOR USER@localhost;;
+Grants for USER@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'USER'@'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION
+SHOW GRANTS FOR ''@localhost;
+Grants for @localhost
+GRANT USAGE ON *.* TO ''@'localhost'
+#
+#
+# mysql_install_db --skip-auth-anonymous-user
+#
+disconnect unix;
+connection testcon;
+use mysql;
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+user host plugin password
+root 127.0.0.1
+root ::1
+root localhost
+SHOW DATABASES;
+Database
+information_schema
+mysql
+performance_schema
+test
+#
+#
+# mysql_install_db --skip-name-resolve
+#
+use mysql;
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+user host plugin password
+ localhost
+root 127.0.0.1
+root ::1
+root localhost
+SHOW DATABASES;
+Database
+information_schema
+mysql
+performance_schema
+test
+# End of 10.2 tests
diff --git a/mysql-test/t/mysql_install_db.test b/mysql-test/t/mysql_install_db.test
new file mode 100644
index 00000000000..93e189ff0b6
--- /dev/null
+++ b/mysql-test/t/mysql_install_db.test
@@ -0,0 +1,166 @@
+--source include/not_windows.inc
+--source include/not_embedded.inc
+--source include/have_unix_socket.inc
+
+# Remove this version check in 10.3
+if (`select @@version_compile_os LIKE 'debian-%'`) {
+ --skip Debian/Ubuntu patches mysql_install_db too much in MariaDB-10.2
+}
+
+--let MYSQLD_DATADIR= `select @@datadir`
+--let HOSTNAME= `select @@hostname`
+
+disconnect default;
+--connect(testcon,localhost,root,,mysql,,)
+connection testcon;
+
+--echo #
+--echo #
+--echo # mysql_install_db (no args)
+--echo #
+
+--source include/kill_mysqld.inc
+--rmdir $MYSQLD_DATADIR
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_INSTALL_DB --verbose
+
+--source include/start_mysqld.inc
+
+--sorted_result
+--replace_result $HOSTNAME HOSTNAME
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+
+--sorted_result
+SHOW DATABASES;
+
+--sorted_result
+SHOW GRANTS FOR root@localhost;
+
+--sorted_result
+SHOW GRANTS FOR ''@localhost;
+
+--echo #
+--echo #
+--echo # mysql_install_db --auth-root-authentication-method=normal
+--echo #
+
+--source include/shutdown_mysqld.inc
+--rmdir $MYSQLD_DATADIR
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_INSTALL_DB --auth-root-authentication-method=normal
+
+--source include/start_mysqld.inc
+
+--sorted_result
+--replace_result $HOSTNAME HOSTNAME
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+
+--sorted_result
+SHOW DATABASES;
+
+--sorted_result
+SHOW GRANTS FOR root@localhost;
+
+--sorted_result
+SHOW GRANTS FOR ''@localhost;
+
+--echo #
+--echo #
+--echo # mysql_install_db --auth-root-authentication-method=socket \\
+--echo # --auth-root-socket-user=\$USER
+--echo #
+
+use test;
+--source include/shutdown_mysqld.inc
+--rmdir $MYSQLD_DATADIR
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_INSTALL_DB --auth-root-authentication-method=socket --auth-root-socket-user=$USER
+
+--source include/start_mysqld.inc
+
+--connect(unix,localhost,$USER,,mysql)
+connection unix;
+
+--sorted_result
+--replace_result $HOSTNAME HOSTNAME $USER USER
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+
+--sorted_result
+SHOW DATABASES;
+
+--replace_result $USER USER
+--sorted_result
+--eval SHOW GRANTS FOR $USER@localhost;
+
+--sorted_result
+SHOW GRANTS FOR ''@localhost;
+
+
+--echo #
+--echo #
+--echo # mysql_install_db --skip-auth-anonymous-user
+--echo #
+
+--source include/shutdown_mysqld.inc
+--disconnect unix
+connection testcon;
+--rmdir $MYSQLD_DATADIR
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_INSTALL_DB --skip-auth-anonymous-user
+
+--source include/start_mysqld.inc
+
+use mysql;
+--sorted_result
+--replace_result $HOSTNAME HOSTNAME $USER USER
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+
+--sorted_result
+SHOW DATABASES;
+
+--echo #
+--echo #
+--echo # mysql_install_db --skip-name-resolve
+--echo #
+
+--source include/shutdown_mysqld.inc
+--rmdir $MYSQLD_DATADIR
+
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--exec $MYSQL_INSTALL_DB --skip-name-resolve
+
+--source include/start_mysqld.inc
+
+use mysql;
+--sorted_result
+--replace_result $HOSTNAME HOSTNAME $USER USER
+SELECT user,host,plugin,password FROM user ORDER BY user,host;
+
+--sorted_result
+SHOW DATABASES;
+
+--echo # End of 10.2 tests
+
+
+
+# Cleanup
+--source include/shutdown_mysqld.inc
+--rmdir $MYSQLD_DATADIR
+--mkdir $MYSQLD_DATADIR
+
+perl;
+use lib "lib";
+use My::Handles { suppress_init_messages => 1 };
+use My::File::Path;
+my $install_db_dir = ($ENV{MTR_PARALLEL} == 1) ?
+ "$ENV{'MYSQLTEST_VARDIR'}/install.db" :
+ "$ENV{'MYSQLTEST_VARDIR'}/../install.db";
+copytree($install_db_dir, $ENV{'MYSQLD_DATADIR'});
+EOF
+
+--source include/start_mysqld.inc
+