|
1 |
| -import copy |
2 | 1 | import io
|
3 |
| -import os |
4 | 2 | import time
|
5 |
| -import pymysql |
6 | 3 | import unittest
|
7 | 4 |
|
8 | 5 | from pymysqlreplication.tests import base
|
|
13 | 10 | from pymysqlreplication.row_event import *
|
14 | 11 | from pymysqlreplication.packet import BinLogPacketWrapper
|
15 | 12 | from pymysql.protocol import MysqlPacket
|
| 13 | +import pytest |
16 | 14 |
|
17 | 15 | __all__ = [
|
18 | 16 | "TestBasicBinLogStreamReader",
|
@@ -826,42 +824,22 @@ def test_alter_column(self):
|
826 | 824 |
|
827 | 825 |
|
828 | 826 | class TestCTLConnectionSettings(base.PyMySQLReplicationTestCase):
|
829 |
| - def setUp(self): |
| 827 | + def setUp(self, charset="utf8"): |
830 | 828 | super().setUp()
|
831 |
| - self.stream.close() |
832 |
| - ctl_db = copy.copy(self.database) |
833 |
| - ctl_db["db"] = None |
834 |
| - ctl_db["port"] = int(os.environ.get("MYSQL_5_7_CTL_PORT") or 3307) |
835 |
| - ctl_db["host"] = os.environ.get("MYSQL_5_7_CTL") or "localhost" |
836 |
| - self.ctl_conn_control = pymysql.connect(**ctl_db) |
837 |
| - self.ctl_conn_control.cursor().execute( |
838 |
| - "DROP DATABASE IF EXISTS pymysqlreplication_test" |
839 |
| - ) |
840 |
| - self.ctl_conn_control.cursor().execute( |
841 |
| - "CREATE DATABASE pymysqlreplication_test" |
842 |
| - ) |
843 |
| - self.ctl_conn_control.close() |
844 |
| - ctl_db["db"] = "pymysqlreplication_test" |
845 |
| - self.ctl_conn_control = pymysql.connect(**ctl_db) |
846 | 829 | self.stream = BinLogStreamReader(
|
847 | 830 | self.database,
|
848 |
| - ctl_connection_settings=ctl_db, |
849 | 831 | server_id=1024,
|
850 | 832 | only_events=(WriteRowsEvent,),
|
851 | 833 | )
|
852 | 834 |
|
853 |
| - def tearDown(self): |
854 |
| - super().tearDown() |
855 |
| - self.ctl_conn_control.close() |
856 |
| - |
857 | 835 | def test_separate_ctl_settings_no_error(self):
|
858 | 836 | self.execute("CREATE TABLE test (id INTEGER(11))")
|
859 | 837 | self.execute("INSERT INTO test VALUES (1)")
|
860 | 838 | self.execute("DROP TABLE test")
|
861 | 839 | self.execute("COMMIT")
|
862 |
| - self.ctl_conn_control.cursor().execute("CREATE TABLE test (id INTEGER(11))") |
863 |
| - self.ctl_conn_control.cursor().execute("INSERT INTO test VALUES (1)") |
864 |
| - self.ctl_conn_control.cursor().execute("COMMIT") |
| 840 | + self.conn_control.cursor().execute("CREATE TABLE test (id INTEGER(11))") |
| 841 | + self.conn_control.cursor().execute("INSERT INTO test VALUES (1)") |
| 842 | + self.conn_control.cursor().execute("COMMIT") |
865 | 843 | try:
|
866 | 844 | self.stream.fetchone()
|
867 | 845 | except Exception as e:
|
@@ -1322,7 +1300,13 @@ def tearDown(self):
|
1322 | 1300 | super(TestStatementConnectionSetting, self).tearDown()
|
1323 | 1301 |
|
1324 | 1302 |
|
1325 |
| -class TestMariadbBinlogStreamReader(base.PyMySQLReplicationMariaDbTestCase): |
| 1303 | +@pytest.mark.mariadb |
| 1304 | +class TestMariadbBinlogStreamReader(base.PyMySQLReplicationTestCase): |
| 1305 | + def setUp(self): |
| 1306 | + super().setUp() |
| 1307 | + if not self.isMariaDB(): |
| 1308 | + self.skipTest("Skipping the entire class for MariaDB") |
| 1309 | + |
1326 | 1310 | def test_binlog_checkpoint_event(self):
|
1327 | 1311 | self.stream.close()
|
1328 | 1312 | self.stream = BinLogStreamReader(
|
@@ -1353,7 +1337,13 @@ def test_binlog_checkpoint_event(self):
|
1353 | 1337 | self.assertEqual(event.filename, self.bin_log_basename() + ".000001")
|
1354 | 1338 |
|
1355 | 1339 |
|
1356 |
| -class TestMariadbBinlogStreamReader2(base.PyMySQLReplicationMariaDbTestCase): |
| 1340 | +@pytest.mark.mariadb |
| 1341 | +class TestMariadbBinlogStreamReader2(base.PyMySQLReplicationTestCase): |
| 1342 | + def setUp(self): |
| 1343 | + super().setUp() |
| 1344 | + if not self.isMariaDB(): |
| 1345 | + self.skipTest("Skipping the entire class for MariaDB") |
| 1346 | + |
1357 | 1347 | def test_annotate_rows_event(self):
|
1358 | 1348 | query = "CREATE TABLE test (id INT NOT NULL AUTO_INCREMENT, data VARCHAR (50) NOT NULL, PRIMARY KEY (id))"
|
1359 | 1349 | self.execute(query)
|
@@ -1498,7 +1488,8 @@ def test_query_event_latin1(self):
|
1498 | 1488 | assert event.query == r"CREATE TABLE test_latin1_\xd6\xc6\xdb (a INT)"
|
1499 | 1489 |
|
1500 | 1490 |
|
1501 |
| -class TestOptionalMetaData(base.PyMySQLReplicationVersion8TestCase): |
| 1491 | +@pytest.mark.mariadb |
| 1492 | +class TestOptionalMetaData(base.PyMySQLReplicationTestCase): |
1502 | 1493 | def setUp(self):
|
1503 | 1494 | super(TestOptionalMetaData, self).setUp()
|
1504 | 1495 | self.stream.close()
|
|
0 commit comments