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