| 1 |
# |
| 2 |
# The purpose of this test is to demonstrate the capabilities of the |
| 3 |
# Replication Observers example plugin and to assess its correct functionality |
| 4 |
# |
| 5 |
# The plugin is only loaded on slave server to capture relay log notifications. |
| 6 |
# |
| 7 |
# Since one wants to test only the hook execution in place, a test |
| 8 |
# plugin was created to serve those needs. The plugin will print once |
| 9 |
# if the hook method is executed and the test will verify if the hook |
| 10 |
# was called. |
| 11 |
# |
| 12 |
# This test will use the hooks related with Event control and SQL/IO |
| 13 |
# thread handling. |
| 14 |
# - after_reset_slave: Called after a RESET SLAVE is invoked |
| 15 |
# - thread_start: Called when the IO Thread starts |
| 16 |
# - before_request_transmit: Called before the slave requests the events |
| 17 |
# from a master. |
| 18 |
# - after_read_event: Called after an event is received. |
| 19 |
# - after_queue_event: Called after an event is queued. |
| 20 |
# - applier_stop: Called after the SQL Thread is stopped |
| 21 |
# - thread_stop: Called after the IO Thread is stopped. |
| 22 |
# |
| 23 |
|
| 24 |
--source include/have_replication_observers_example_plugin.inc |
| 25 |
--source include/not_group_replication_plugin.inc |
| 26 |
--source include/have_binlog_format_mixed.inc |
| 27 |
--source include/master-slave.inc |
| 28 |
|
| 29 |
--connection slave |
| 30 |
--echo # |
| 31 |
--echo # Stop slave and install plugin. |
| 32 |
--echo # |
| 33 |
--source include/stop_slave.inc |
| 34 |
--source include/install_replication_observers_example.inc |
| 35 |
|
| 36 |
--echo # |
| 37 |
--echo # Cause a reset slave notification. |
| 38 |
--echo # |
| 39 |
RESET SLAVE; |
| 40 |
|
| 41 |
--echo # |
| 42 |
--echo # Cause a connect notification. |
| 43 |
--echo # |
| 44 |
--source include/start_slave.inc |
| 45 |
|
| 46 |
--echo # |
| 47 |
--echo # Execute some transactions on master to cause the other notifications. |
| 48 |
--echo # |
| 49 |
--connection master |
| 50 |
|
| 51 |
CREATE TABLE t1 (c1 INT) Engine=InnoDB; |
| 52 |
INSERT t1 VALUES(1); |
| 53 |
DROP TABLE t1; |
| 54 |
--source include/sync_slave_sql_with_master.inc |
| 55 |
|
| 56 |
--echo # |
| 57 |
--echo # Stop slave and uninstall plugin. |
| 58 |
--echo # |
| 59 |
--source include/stop_slave.inc |
| 60 |
--source include/uninstall_replication_observers_example.inc |
| 61 |
|
| 62 |
--echo # |
| 63 |
--echo # Verify that all relay hooks were called. |
| 64 |
--echo # |
| 65 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 66 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_after_reset_slave |
| 67 |
--replace_regex /.* reported: \' // |
| 68 |
--source include/grep_pattern.inc |
| 69 |
|
| 70 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 71 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_thread_start |
| 72 |
--replace_regex /.* reported: \' // |
| 73 |
--source include/grep_pattern.inc |
| 74 |
|
| 75 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 76 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_before_request_transmit |
| 77 |
--replace_regex /.* reported: \' // |
| 78 |
--source include/grep_pattern.inc |
| 79 |
|
| 80 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 81 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_after_read_event |
| 82 |
--replace_regex /.* reported: \' // |
| 83 |
--source include/grep_pattern.inc |
| 84 |
|
| 85 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 86 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_after_queue_event |
| 87 |
--replace_regex /.* reported: \' // |
| 88 |
--source include/grep_pattern.inc |
| 89 |
|
| 90 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 91 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_applier_start |
| 92 |
--replace_regex /.* reported: \' // |
| 93 |
--source include/grep_pattern.inc |
| 94 |
|
| 95 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 96 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_applier_stop |
| 97 |
--replace_regex /.* reported: \' // |
| 98 |
--source include/grep_pattern.inc |
| 99 |
|
| 100 |
--let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin_io.err |
| 101 |
--let $grep_pattern=replication_observers_example_plugin:binlog_relay_thread_stop |
| 102 |
--replace_regex /.* reported: \' // |
| 103 |
--source include/grep_pattern.inc |
| 104 |
|
| 105 |
--let $rpl_only_running_threads= 1 |
| 106 |
--source include/rpl_end.inc |