# Stariting the server with an --init-file which does shutdown does # not appear to be working on windows --source include/not_windows.inc --echo # --echo # Testing wl#10441: Add mysqld_safe-functionality to server --echo # let $MYSQLD_SOCKET= `SELECT @@socket`; let $MYSQLD_PORT= `SELECT @@port`; let $MTR_DATADIR= `SELECT @@datadir`; --echo # Shutdown mysqld which is started by mtr. --let $_server_id= `SELECT @@server_id` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect --exec echo "wait" > $_expect_file_name --shutdown_server --source include/wait_until_disconnected.inc let MYSQLD_LOG= $MYSQL_TMP_DIR/server.log; let MYSQLD_OUT= $MYSQL_TMP_DIR/server.out; let DDIR= $MYSQL_TMP_DIR/basedir_test; let SHUTDOWN_SQL= $MYSQL_TMP_DIR/shutdown.sql; # Need to save this as PWD env var is overriden when invoking perl let BDIR= $PWD; let DEFARGS= --no-defaults --innodb_dedicated_server=OFF --explicit_defaults_for_timestamp --socket=$MYSQLD_SOCKET --port=$MYSQLD_PORT --skip-ssl --secure-file-priv="" --datadir=$DDIR --skip-mysqlx; let INIT_FILE_ARGS= $DEFARGS --log-error=$MYSQLD_LOG --init-file=$SHUTDOWN_SQL; let INIT_FILE_ARGS_D= --no-defaults --innodb_dedicated_server=OFF --explicit_defaults_for_timestamp --socket=$MYSQLD_SOCKET --port=$MYSQLD_PORT --skip-mysqlx --skip-ssl --secure-file-priv="" --datadir=$MTR_DATADIR -D --log-error=$MYSQLD_LOG; write_file $SHUTDOWN_SQL; SHUTDOWN; EOF --echo # Run -I on a new datadir --exec $MYSQLD $DEFARGS -I --log-error=$MYSQLD_LOG --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:25200@1' --echo # --echo # Deduce --basedir when using full path to mysqld --exec $MYSQLD $INIT_FILE_ARGS --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:25200@1' #--exec $MYSQLD $INIT_FILE_ARGS --perl use strict; my $mysqld_log= $ENV{'MYSQLD_LOG'}; open(MYSQLD_LOG, $mysqld_log) || die "Failed to open '$mysqld_log': $!"; print "# Look for [ERROR] in error log (there should be none):\n"; while() { if (/ERROR/) { print; } } close(MYSQLD_LOG); EOF --remove_file $MYSQLD_LOG --echo # --echo # Deduce --basedir when using path relative to CWD --perl use strict; my $bdir= $ENV{'BDIR'}; my $mysqld_log= $ENV{'MYSQLD_LOG'}; chdir $bdir; my $binary= $ENV{'MYSQLD'}; $binary =~ s|$bdir/||; my $init_file_args= $ENV{'INIT_FILE_ARGS'}; (system("$binary $init_file_args") == 0) || die "system failed on '$binary $init_file_args': $!"; open(MYSQLD_LOG, $ENV{'MYSQLD_LOG'}) || die "Failed to open '$mysqld_log': $!"; print "# Look for [ERROR] in error log (there should be none):\n"; while() { if (/ERROR/) { print; } } close(MYSQLD_LOG); EOF --remove_file $MYSQLD_LOG --echo # --echo # Deduce --basedir when using bare executable name (PATH lookup) --perl use strict; use File::Basename; my $bdir= $ENV{'BDIR'}; chdir $bdir; my $bindir= dirname($ENV{'MYSQLD'}); $ENV{'PATH'}="$bindir:$ENV{'PATH'}"; my $init_file_args= $ENV{'INIT_FILE_ARGS'}; my $binary= $ENV{'MYSQLD'}; $binary =~ s|$bdir/||; (system("$binary $init_file_args") == 0) || die "system failed on 'mysqld $init_file_args': $!"; my $mysqld_log= $ENV{'MYSQLD_LOG'}; open(MYSQLD_LOG, $mysqld_log) || die "Failed to open '$mysqld_log': $!"; print "# Look for [ERROR] in error log (there should be none):\n"; while() { if (/ERROR/) { print; } } close(MYSQLD_LOG); EOF --remove_file $MYSQLD_LOG --echo # --echo # Try invalid --log-error --error 1 --exec $MYSQLD $DEFARGS --log-error=$MYSQL_TMP_DIR/no_such_dir/bad_err_log.err --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:28200@1' >$MYSQLD_OUT 2>&1 --echo # Look for expected error in output: --perl use strict; my $mysqld_out= $ENV{'MYSQLD_OUT'}; open(MYSQLD_OUT, $mysqld_out) || die "Failed to open '$mysqld_out': $!"; my $found_expected_error= 0; while() { if (/\[ERROR\] \[[^]]*\] \[[^]]*\] Could not open .+ for error logging/) { print "# Found expected error\n"; $found_expected_error= 1; } } if (!$found_expected_error) { seek(MYSQLD_OUT, 0, 0) || die "Failed to rewind FH for '$mysqld_out': $!"; while() { print; } } close(MYSQLD_OUT); EOF --echo # --echo # Try -D as shortcut for --daemonize option with invalid --log-error --error 1 --exec $MYSQLD $DEFARGS -D --log-error=$MYSQL_TMP_DIR/no_such_dir/bad_err_log.err --cluster-id=1 --cluster-start-index=1 --cluster-info='127.0.0.1:29200@1' >$MYSQLD_OUT 2>&1 --echo # Look for expected errors in output from launcher and daemon: --perl use strict; my $mysqld_out= $ENV{'MYSQLD_OUT'}; open(MYSQLD_OUT, $mysqld_out) || die "Failed to open '$mysqld_out': $!"; my $found_expected_errors= 0; while() { if (/\[ERROR\] \[[^]]*\] \[[^]]*\] Could not open .+ for error logging/) { print "# Found expected error from launcher process\n"; ++$found_expected_errors; } if (/\[ERROR\] \[[^]]*\] \[[^]]*\] Failed to start mysqld daemon\. Check mysqld error log\./) { print "# Found expected error from daemon process\n"; ++$found_expected_errors; } } if ($found_expected_errors < 2) { seek(MYSQLD_OUT, 0, 0) || die "Failed to rewind FH for '$mysqld_out': $!"; } close(MYSQLD_OUT); EOF --echo # --echo # Try using -D with relative path --perl use strict; use File::Basename; my $mysqld= $ENV{'MYSQLD'}; my $mysql_tmp_dir= $ENV{'MYSQL_TMP_DIR'}; my $init_file_args_d= $ENV{'INIT_FILE_ARGS_D'}; my $mysqld_out= $ENV{'MYSQLD_OUT'}; chdir($mysql_tmp_dir) || die "# Could not chdir to '$mysql_tmp_dir': $!"; (system("$mysqld $init_file_args_d >$mysqld_out 2>&1") == 0) || die "system failed on '$mysqld $init_file_args_d': $!"; my $mysqld_log= $ENV{'MYSQLD_LOG'}; open(MYSQLD_LOG, $mysqld_log) || die "Failed to open '$mysqld_log': $!"; print "# Look for [ERROR] in error log (there should be none):\n"; while() { if (/ERROR/) { print; } } close(MYSQLD_LOG); open(MYSQLD_OUT, $mysqld_out) || die "Failed to open '$mysqld_out': $!"; print "# Look for output (there should be none):\n"; print "# Supressing output for initialize:\n"; while() { if (!(/initializing of server has completed/)) { print; } } close(MYSQLD_OUT); EOF --echo # Wait for daemon server to start --enable_reconnect --source include/wait_until_connected_again.inc --disable_reconnect --echo # Execute a query to see that it is running OK SHOW DATABASES; --echo # Shutdown daemon --let $_daemon_id= `SELECT @@server_id` --let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_daemon_id.expect --exec echo "wait" > $_expect_file_name --shutdown_server --echo # Wait until daemon is gone --source include/wait_until_disconnected.inc --echo # --echo # Cleanup --echo # --remove_file $MYSQLD_OUT --remove_file $MYSQLD_LOG --remove_file $SHUTDOWN_SQL --force-rmdir $DDIR --echo # --echo # Restart mysqld of mtr --echo # --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --source include/wait_until_connected_again.inc --source include/xplugin_wait_for_interfaces.inc