If a server dies during execution of a test case, this will be interpreted as a failure. However, there may be cases where you actually want to stop and possibly restart a server intentionally. It is possible to let the system know you expect a server to terminate, and to either wait or have it restarted immediately:
Before you initiate the action that will stop the server, the test
case should write either
wait to the file
easiest way to do this is using the exec echo
construct like in the following example.
If you write
restart into this file, the server
will be immediately restarted. If you write
wait instead, the server will remain down, but
can be restarted at a later time by writing
restart to the file.
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server 10 --source include/wait_until_disconnected.inc # Do something while server is down --enable_reconnect --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc
For your convenience, there is a file
include/restart_mysqld.inc which you can
"source" in your own test case to do what's shown in this code
The file name to write the command to will be
mysqld.2.expect for the slave server in
replication tests. Note that you have to use
$MYSQLTEST_VARDIR/tmp for the directory here;
if you use
$MYSQL_TMP_DIR instead, it will
not work when running tests in parallel.
It is also possible to provide additional command line options to
the restarted server, by writing a line with
restart: (with a colon) followed by one or more
options into the expect file. These extra options will be dropped
if the same server is restarted again, unless they are repeated.