def testSlaveWaitAndStop(self): "Test the slave_wait_and_stop function" slave = self.slaves[0] master = self.master slave.sql("STOP SLAVE") pos1 = fetch_master_position(master) change_master(slave, master, pos1) slave.sql("START SLAVE") master.sql("DROP TABLE IF EXISTS t1", db="test") master.sql("CREATE TABLE t1 (a INT)", db="test") master.sql("INSERT INTO t1 VALUES (1),(2)", db="test") pos2 = fetch_master_position(master) master.sql("INSERT INTO t1 VALUES (3),(4)", db="test") pos3 = fetch_master_position(master) slave_wait_and_stop(slave, pos2) pos4 = fetch_slave_position(slave) self.assertEqual(pos2, pos4) row = slave.sql("SELECT COUNT(*) AS count FROM t1", db="test") self.assertEqual(row['count'], 2) slave.sql("START SLAVE") slave_wait_and_stop(slave, pos3) row = slave.sql("SELECT COUNT(*) AS count FROM t1", db="test") self.assertEqual(row['count'], 4)
def testSlaveStatusWaitUntil(self): "Test slave_status_wait_until" slave = self.slaves[0] master = self.master slave.sql("STOP SLAVE") pos1 = fetch_master_position(master) change_master(slave, master, pos1) slave.sql("START SLAVE")
def testChangeMaster(self): "Test the change_master function" for slave in self.slaves: change_master(slave, self.master) self.master.sql("DROP TABLE IF EXISTS t1", db="test") self.master.sql("CREATE TABLE t1 (a INT)", db="test") self.master.disconnect() for slave in self.slaves: result = slave.sql("SHOW TABLES", db="test")
def testChangeMaster(self): "Test the change_master function" for slave in self.slaves: change_master(slave, self.master) self.master.sql("DROP TABLE IF EXISTS t1", db="test") self.master.sql("CREATE TABLE t1 (a INT)", db="test") self.master.disconnect() for slave in self.slaves: slave.sql("SHOW TABLES", db="test")
def testSlaveWaitForPos(self): "Test the slave_wait_for_pos function" slave = self.slaves[0] master = self.master slave.sql("STOP SLAVE") pos1 = fetch_master_position(master) change_master(slave, master, pos1) slave.sql("START SLAVE") master.sql("DROP TABLE IF EXISTS t1", db="test") master.sql("CREATE TABLE t1 (a INT)", db="test") master.sql("INSERT INTO t1 VALUES (1),(2)", db="test") pos2 = fetch_master_position(master) slave_wait_for_pos(slave, pos2) pos3 = fetch_slave_position(slave) self.assert_(pos3 >= pos2)