Debian Codegraph @

mysql-test/suite/rpl/t/rpl_replication_observers_example_plugin.test

raw
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 # Since one wants to test only the hook execution in place, a test
6 # plugin was created to serve those needs. The plugin will print once
7 # if the hook method is executed and the test will verify if the hook
8 # was called.
9 #
10 # This test will use two different groups of hooks/observers:
11 # - Server State
12 # - Transaction
13 #
14 # Server State uses hooks:
15 # - before_server_shutdown: Called before the server starts a shut down.
16 # - after_server_shutdown: Called after the server starts a shut down.
17 #
18 # Transaction hooks exist on binlog. As such, binlog must be enabled in
19 # order for them to be called. They are:
20 # - before_dml: Called before any dml instruction is issued.
21 # - before_commit: Called before a transaction is committed.
22 # - before_rollback: Called before a transaction is rollbacked.
23 # - after_commit: Called after a transaction is committed.
24 # - after_rollback: Called after a transaction is rollbacked.
25 #
26
27 --source include/have_binlog_format_mixed.inc
28 --source include/not_group_replication_plugin.inc
29 --source include/have_replication_observers_example_plugin.inc
30
31 --source include/install_replication_observers_example.inc
32
33 --echo #
34 --echo # Cause an explicit transaction in order to Trans Observer to be called
35 --echo #
36
37 CREATE TABLE t1 (c1 INT PRIMARY KEY) Engine=InnoDB;
38
39 INSERT t1 VALUES(1);
40
41 BEGIN;
42 INSERT t1 VALUES(2);
43 ROLLBACK;
44
45 DROP TABLE t1;
46
47 --echo #
48 --echo # Cause an explicit restart in order to Server Observer to be called
49 --echo #
50
51 --source include/restart_mysqld.inc
52
53 --echo #
54 --echo # Verify that all Server Listening hooks were called
55 --echo #
56
57 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
58 --let $grep_pattern=replication_observers_example_plugin:before_server_shutdown
59 --replace_regex /.* reported: \' //
60 --source include/grep_pattern.inc
61
62 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
63 --let $grep_pattern=replication_observers_example_plugin:after_server_shutdown
64 --replace_regex /.* reported: \' //
65 --source include/grep_pattern.inc
66
67 --echo #
68 --echo # Verify that all Trans Listening hooks were called
69 --echo #
70
71 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
72 --let $grep_pattern=replication_observers_example_plugin:trans_before_dml
73 --replace_regex /.* reported: \' //
74 --source include/grep_pattern.inc
75
76 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
77 --let $grep_pattern=replication_observers_example_plugin:trans_before_commit
78 --replace_regex /.* reported: \' //
79 --source include/grep_pattern.inc
80
81 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
82 --let $grep_pattern=replication_observers_example_plugin:trans_before_rollback
83 --replace_regex /.* reported: \' //
84 --source include/grep_pattern.inc
85
86 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
87 --let $grep_pattern=replication_observers_example_plugin:trans_after_commit
88 --replace_regex /.* reported: \' //
89 --source include/grep_pattern.inc
90
91 --let $grep_file=$MYSQLTEST_VARDIR/tmp/rpl_replication_observers_example_plugin.err
92 --let $grep_pattern=replication_observers_example_plugin:trans_after_rollback
93 --replace_regex /.* reported: \' //
94 --source include/grep_pattern.inc
95
96 # Cleanup
97 UNINSTALL PLUGIN replication_observers_example;
98 --echo End of test