Skip to content

Commit 5836445

Browse files
committed
Add test for rows_query_log_event
1 parent bc43e43 commit 5836445

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

docker-compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ services:
1515
ports:
1616
- 3307:3307
1717
command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3307
18+
19+
percona-5.7-binlog-rows-query-events:
20+
image: percona:5.7
21+
environment:
22+
MYSQL_ALLOW_EMPTY_PASSWORD: true
23+
ports:
24+
- 3308:3308
25+
command: mysqld --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --binlog-rows-query-log-events=on --gtid_mode=on --enforce-gtid-consistency=on --log_slave_updates -P 3308

pymysqlreplication/tests/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class PyMySQLReplicationTestCase(base):
1818
def ignoredEvents(self):
1919
return []
2020

21-
def setUp(self):
21+
def setUp(self, port=3306):
2222

2323
db = os.environ.get('DB')
2424
# default
2525
self.database = {
2626
"host": "localhost",
2727
"user": "root",
2828
"passwd": "",
29-
"port": 3306,
29+
"port": port,
3030
"use_unicode": True,
3131
"charset": "utf8",
3232
"db": "pymysqlreplication_test"

pymysqlreplication/tests/test_basic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,24 @@ def test_parsing(self):
10031003
gtid = Gtid("57b70f4e-20d3-11e5-a393-4a63946f7eac::1")
10041004

10051005

1006+
class TestRowsQueryLogEvents(base.PyMySQLReplicationTestCase):
1007+
def setUp(self):
1008+
super(TestRowsQueryLogEvents, self).setUp(port=3308)
1009+
1010+
def test_rows_query_log_event(self):
1011+
self.stream.close()
1012+
self.stream = BinLogStreamReader(
1013+
self.database,
1014+
server_id=1024,
1015+
only_events=[RowsQueryLogEvent],
1016+
)
1017+
self.execute("CREATE TABLE IF NOT EXISTS test (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))")
1018+
self.execute("INSERT INTO test (name) VALUES ('Soul Lee')")
1019+
self.execute("COMMIT")
1020+
event = self.stream.fetchone()
1021+
self.assertIsInstance(event, RowsQueryLogEvent)
1022+
1023+
10061024
if __name__ == "__main__":
10071025
import unittest
10081026
unittest.main()

0 commit comments

Comments
 (0)