|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
import MySQLdb
|
|
|
|
|
from MySQLdb import OperationalError
|
|
|
|
|
from nose.tools import raises
|
|
|
|
|
import random
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
from proxysql_base_test import ProxySQLBaseTest
|
|
|
|
|
|
|
|
|
|
@ -26,10 +28,35 @@ class ReplicationTopologyAwareness(ProxySQLBaseTest):
|
|
|
|
|
self.run_query_mysql_container(q, 'information_schema', slave_container_id)
|
|
|
|
|
self.run_query_mysql_container('START SLAVE', 'information_schema', slave_container_id)
|
|
|
|
|
|
|
|
|
|
def _test_promoting_slave_to_master_correctly_updates_admin_tables(self):
|
|
|
|
|
slave_caught_up = False
|
|
|
|
|
while not slave_caught_up:
|
|
|
|
|
slave_status = self.run_query_mysql_container(
|
|
|
|
|
'SHOW SLAVE STATUS',
|
|
|
|
|
'information_schema',
|
|
|
|
|
slave_container_id
|
|
|
|
|
)
|
|
|
|
|
slave_caught_up = slave_status[0][44].startswith(
|
|
|
|
|
'Slave has read all relay log')
|
|
|
|
|
|
|
|
|
|
def _test_insert_sent_through_proxysql_is_visible_in_slave_servers(self):
|
|
|
|
|
self._start_replication()
|
|
|
|
|
import pdb; pdb.set_trace()
|
|
|
|
|
|
|
|
|
|
def test_promoting_slave_to_master_correctly_updates_admin_tables(self):
|
|
|
|
|
self.run_in_docker_scenarios(self._test_promoting_slave_to_master_correctly_updates_admin_tables,
|
|
|
|
|
random_string = ''.join(random.choice(['a', 'b', 'c', 'd', 'e']) for _ in xrange(10))
|
|
|
|
|
q = "INSERT INTO strings(value) VALUES('%s')" % random_string
|
|
|
|
|
self.run_query_proxysql(q, "test")
|
|
|
|
|
|
|
|
|
|
# Give slaves the time to catch up
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
|
|
|
|
|
slave_containers = self.get_mysql_containers(hostgroup=1)
|
|
|
|
|
for slave_container_id in slave_containers:
|
|
|
|
|
q = "SELECT * FROM strings"
|
|
|
|
|
rows = self.run_query_mysql_container("SELECT * FROM strings",
|
|
|
|
|
"test",
|
|
|
|
|
slave_container_id)
|
|
|
|
|
self.assertEqual(set([row[0] for row in rows]),
|
|
|
|
|
set(['a', 'ab', 'abc', 'abcd', random_string]))
|
|
|
|
|
|
|
|
|
|
def test_insert_sent_through_proxysql_is_visible_in_slave_servers(self):
|
|
|
|
|
self.run_in_docker_scenarios(self._test_insert_sent_through_proxysql_is_visible_in_slave_servers,
|
|
|
|
|
scenarios=['5backends-replication'])
|