WL#6446: Test of mysqld_safe missing in main test suite.

Status: Complete

The server test suite does not include any test to verify that mysqld_safe is
working properly.
For this reason, when an error occurs, it is not detected, unless someone
does a manual test. This WL has been created due to bug#11759353.

User Documentation
==================

None required.
Test of mysqld_safe (shell script)

The test should at least do the following:

1) Check if mysqld_safe is existing.
2) Set the variables to be used in mysqld_safe.
3) Shutdown mysqld started automaticly by mtr.
4) Run the mysqld_safe script with exec.
5) Reconnect to mysqld again.
6) Execute some SQL.
7) Kill mysqld, which must be restarted now automaticly by mysqld_safe.
8) Execute some SQL.
9) Shutdown mysqld with mysqladmin regularly (no Restart by mysqld_safe).
10) Restart mysqld of mtr (only if necessary to finish the test correctly).

Test of mysqld_safe (shell script)

Intended were the following steps executed by an mtr test:

1) Check if mysqld_safe is existing.
2) Set the variables to be used in mysqld_safe.
3) Shutdown mysqld started automaticly by mtr.
4) Run the mysqld_safe script with exec.
5) Reconnect to mysqld again.
6) Execute some SQL.
7) Kill mysqld, which must be restarted now automaticly by mysqld_safe.
8) Execute some SQL.
9) Shutdown mysqld with mysqladmin regularly (no Restart by mysqld_safe).
10) Restart mysqld of mtr (only if necessary to finish the test correctly).

There exist a mtr test called "mysqld_test.test" executing the steps 2 to 4.

Then the test is hanging with having mysqld_safe started which started a mysqld.
This can be seen by doing a "ps -ef|grep mysql" on another terminal.
If mysqld will be shutdown by mysqladmin with the right parameters then the test
is finishing.

The execution of mysqld_safe with exec is failing, means do not behave as
expected and start 
mysqld_safe and mysqld.

Do that all manually on commandline let mysqld_safe run in batch with the
expected behaviour.

It must be clarified why it is not possible to do the same with exec in a mtr test. 
All experiments have been done in mysql-trunk.

Tried exec variants:

Not as batch with the result thatr the test hangs until mysqld will stopped in
another terminal:
exec $MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR ;

Is starting mysqld_safe and mysqld, the test is hanging. After having killed
mysqld_safe the test finished:
exec $MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR & ;

Command as string is failing:
exec "$MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR &";

This command run or not without return code, but mysqld_safe has not been
started. Test come to end:
exec "$MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR" &;

Test ended, but mysqld_safe had not effect:
--exec "$MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR" &

Failed:
--exec "$MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR &"

Is starting mysqld_safe and mysqld, the test is hanging:
--exec $MYSQLD_SAFE --defaults-file=$MYSQLTEST_VARDIR/my.cnf
--log-error=$MYSQLTEST_VARDIR/log/err.log --basedir=$MYSQL_BASEDIR
--ledir=$MYSQL_BASEDIR/sql --datadir=$MYSQLD_DATADIR --socket=$MYSQL_SOCKET
--pid-file=$MYSQL_PIDFILE --port=$MYSQL_PORT --timezone=$MYSQL_TIMEZONE
--log-output=file --loose-debug-sync-timeout=600 --default-storage-engine=MyISAM
--default-tmp-storage-engine=MyISAM --loose-skip-log-bin --core-file
--lc-messages-dir=$MYSQL_MESSAGESDIR &

Looks like the "exec" statement of mysqltest has a problem with batch jobs.