def test_gen_by_binlog(self):
     
     testBLDir = casedir + os.sep + "well_binlog_dir"
     agent = MySQLBinlogAgent()
     
     success, writeTo = agent.gen_sql_file_by_binlog(testBLDir, "mysql-bin", "mysql-bin.000164", 0, "group-test", "test-instance-id")
     self.assertTrue(success and writeTo, writeTo)
     
     expecteResultFile = testBLDir + os.sep + "testcase1.result"
     print writeTo, expecteResultFile
     srcMD5 = FileUtils.calc_file_md5sum(expecteResultFile)
     destMD5 = FileUtils.calc_file_md5sum(writeTo)
     self.assertTrue(srcMD5 == destMD5, (srcMD5, destMD5))
    def test_gen_by_relaylog(self):
        
        time.sleep(1)
        
        fakeLocalSlave = TestFailoverAgent.genSlaveStatus("mysql-bin.000003", 59804379, "mysql-bin.000003", 
                                               59804379, "relay-log.000018", 3051347, 19)
        slowerSlaveStatus = TestFailoverAgent.genSlaveStatus("mysql-bin.000003", 59194130, "mysql-bin.000003", 
                                               59194130, None, None, 19)
        
        relayDir = self._relayCaseDir + os.sep + "working_slave_relay_files"
        agent = MySQLBinlogAgent()
        
        success, diffSize, writeTo = agent.gen_sql_file_by_relaylog(fakeLocalSlave, 20, "relay-log", relayDir, slowerSlaveStatus, "group-test", "test-instance-id")
       
        self.assertTrue(success, success)
        self.assertTrue(diffSize > 0, diffSize)
        self.assertTrue(writeTo != None, writeTo)

        expecteResultFile = relayDir + os.sep + "testcase1.result"
        
        print writeTo, expecteResultFile
        tmpMD5 = FileUtils.calc_file_md5sum(writeTo)
        expMD5 = FileUtils.calc_file_md5sum(expecteResultFile)
        self.assertTrue(tmpMD5 == expMD5, (tmpMD5, expMD5))