mariadb/mysql-test/main/mysql_install_db_win.test
Vladislav Vaintroub f97c8f7ece MDEV-26715 Fix mysql_install_db_win tests.
It looks like  C/C reconnect retains the database. It is correct behavior
However there is a problem that mysql_install_db.exe does not create
'test' database, thus using mysql_install_db to create datadir,
then restarting server and reconnecting does not succeed, if 'test' was
current db before reconnect.

The problem became apparent with MDEV-26715. Why it worked before,
with a simpler 'root' definition is a mystery.

Fix is to switch current connection to 'mysql' database, prior to
reconnect to the instance created via mysql_install_db.exe
2022-11-08 14:58:48 +01:00

93 lines
2.5 KiB
Text

--source include/windows.inc
select database();
use mysql;
# Create database in tmp directory using mysql_install_db.exe,
# and start server from this directory.
let $ddir= $MYSQLTEST_VARDIR/tmp/ddir;
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R;
--source include/kill_mysqld.inc
let $restart_parameters=--datadir=$ddir --loose-innodb;
--source include/start_mysqld.inc
connect (root,localhost,root,foo,mysql);
# Smoke test - check that we're actually using datadir
# we've created (i.e restart_parameters worked)
--replace_result $ddir DATADIR
SELECT @@datadir;
# restart in the original datadir again
--source include/kill_mysqld.inc
rmdir $ddir;
# MDEV-23052
# 1. mysql_install_db works on existing, empty directory
mkdir $ddir;
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R > /dev/null;
rmdir $ddir;
# 2. mysql_install_db rejects existing, non-empty directory, and does not
# remove it.
mkdir $ddir;
write_file $ddir/1;
EOF
error 1;
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R > $MYSQLTEST_VARDIR/tmp/install.log 2>&1;
list_files $ddir;
let $log=$MYSQLTEST_VARDIR/tmp/install.log;
let SEARCH_FILE=$log;
let SEARCH_PATTERN=is not empty. Only new or empty existing directories are accepted for --datadir;
--source include/search_pattern_in_file.inc
remove_file $log;
rmdir $ddir;
# MDEV-28471 - mysql_install_db.exe fails with --innodb-page-size=64K
--disable_result_log
exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R --innodb-page-size=64K --verbose
--enable_result_log
rmdir $ddir;
# Tests with config file
let $restart_parameters=;
connection default;
# Test --template option
let _BASEDIR = $MYSQLTEST_VARDIR/tmp/basedir;
perl;
use autodie;
open(IN, '<', "std_data/mysql_install_db_win.ini");
open(OUT, '>', "$ENV{MYSQLTEST_VARDIR}/tmp/mysql_install_db_win.ini");
while (<IN>) {
s/BASEDIR/$ENV{_BASEDIR}/g;
print OUT $_;
}
close IN;
close OUT
EOF
mkdir $_BASEDIR;
mkdir $_BASEDIR/temp;
# Run mysql_install_db.exe with config parameter
--disable_result_log
exec $MYSQL_INSTALL_DB_EXE -o --port=3307 --config=$MYSQLTEST_VARDIR/tmp/mysql_install_db_win.ini;
--enable_result_log
# dump the modified config in data directory
perl;
use autodie;
open(IN, '<', "$ENV{_BASEDIR}/data/my.ini");
while (<IN>) {
s/$ENV{_BASEDIR}/BASEDIR/g;
# when testing on installation layout, client's plugin
# dir is added, but when testing in build dir.
print unless $_ =~ /plugin-dir/;
}
close IN;
EOF
rmdir $_BASEDIR;
--source include/start_mysqld.inc
use test;