| 1 |
let $MYSQLD_DATADIR= `select @@datadir`; |
| 2 |
let MYSQLDDATADIR= `select @@datadir`; |
| 3 |
|
| 4 |
--echo ########################################## |
| 5 |
--echo # Run plugin |
| 6 |
--echo ########################################## |
| 7 |
--replace_result $TEST_SQL_SHUTDOWN TEST_SQL_SHUTDOWN |
| 8 |
eval INSTALL PLUGIN test_sql_shutdown SONAME '$TEST_SQL_SHUTDOWN'; |
| 9 |
# Wait until the plugin thread has opened a session. |
| 10 |
# That's for the deterministic result also on slow machines. |
| 11 |
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE info LIKE 'PLUGIN%'; |
| 12 |
--source include/wait_condition.inc |
| 13 |
SELECT count(*) FROM information_schema.processlist WHERE info LIKE 'PLUGIN%'; |
| 14 |
--echo ########################################## |
| 15 |
--echo # Shutdown |
| 16 |
--echo ########################################## |
| 17 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 18 |
--shutdown_server |
| 19 |
--source include/wait_until_disconnected.inc |
| 20 |
# Give implicitly called deinit of plugin time to write 'SERVER SHUTDOWN' to file |
| 21 |
# The following perl snippet is waiting until the test plugin will be ready |
| 22 |
# to write into the log. The last line must contain "SERVER SHUTDOWN". |
| 23 |
# Then the test can cat the file content into the result file. |
| 24 |
perl; |
| 25 |
use strict; |
| 26 |
my $max_trials= 300; |
| 27 |
my $fc_count= 0; |
| 28 |
my $p_found= 1; |
| 29 |
my $fn= "$ENV{'MYSQLDDATADIR'}/test_sql_shutdown.log"; |
| 30 |
my $search_pattern="SERVER SHUTDOWN"; |
| 31 |
while ($p_found and $fc_count < $max_trials) { |
| 32 |
open(FILE, "<", $fn); |
| 33 |
while (<FILE>) { |
| 34 |
if (m{$search_pattern}) { |
| 35 |
$p_found= 0; |
| 36 |
close(FILE); |
| 37 |
exit; |
| 38 |
} |
| 39 |
} |
| 40 |
sleep(1); |
| 41 |
$fc_count++; |
| 42 |
close(FILE); |
| 43 |
} |
| 44 |
print "Pattern \"$search_pattern\" not found\n"; |
| 45 |
EOF |
| 46 |
cat_file $MYSQLD_DATADIR/test_sql_shutdown.log; |
| 47 |
|
| 48 |
|
| 49 |
--echo ########################################## |
| 50 |
--echo # Restart |
| 51 |
--echo ########################################## |
| 52 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 53 |
--enable_reconnect |
| 54 |
--source include/wait_until_connected_again.inc |
| 55 |
cat_file $MYSQLD_DATADIR/test_sql_shutdown.log; |
| 56 |
|
| 57 |
SELECT plugin_name, plugin_status, plugin_type, |
| 58 |
plugin_description, load_option |
| 59 |
FROM information_schema.plugins |
| 60 |
WHERE plugin_name LIKE "test_sql_shutdown"; |
| 61 |
|
| 62 |
--echo ########################################## |
| 63 |
--echo # Stop plugin |
| 64 |
--echo ########################################## |
| 65 |
UNINSTALL PLUGIN test_sql_shutdown; |
| 66 |
remove_file $MYSQLD_DATADIR/test_sql_shutdown.log; |