Documentation Home
The MySQL Test Framework, Version 2.0
Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb

The MySQL Test Framework, Version 2.0  /  Writing Test Cases  /  Stopping a Server During a Test

4.17 Stopping a Server During a Test

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 restart or wait to the file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect. The 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/
# Do something while server is down
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/

For your convenience, there is a file include/ which you can "source" in your own test case to do what's shown in this code example.

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.