def _make_sum_rows(table, idx_str): """Populate the summary table This method inserts rows into the compare table from the original table then forms the summary table by combining a prefix of the primary key hash (group by). table[in] Table instance idx_str[in] string representation of primary key columns Returns result from """ from mysql.utilities.common.lock import Lock col_str = ", ".join(table.get_col_names()) # Lock table first tbl_lock_list = [(table.table, "READ"), ("%s.compare_%s" % (table.db_name, table.tbl_name), "WRITE")] my_lock = Lock(table.server, tbl_lock_list) table.server.exec_query( _COMPARE_INSERT.format( db=table.db_name, table=table.tbl_name, colstr=col_str.strip(", "), pkstr=idx_str.strip(", ") ) ) res = table.server.exec_query(_COMPARE_SUM.format(db=table.db_name, table=table.tbl_name)) # Unlock table my_lock.unlock() return res
def run(self): from mysql.utilities.common.lock import Lock self.server1 = self.servers.get_server(0) test_num = 1 # Here we test the locking and unlocking of tables (if applicable) # for the locking types. comment = "Test case {0} - test locking type '{1}'" for lock_test in _LOCKTESTS: lock = None comment_str = comment.format(test_num, lock_test[0]) res_entry = { 'test_case': comment_str, 'lock_res': (0, ""), 'unlock_res': (0, ""), 'lock_fail': lock_test[2], 'unlock_fail': lock_test[3], } if lock_test[0] == 'SKIP_UNLOCK': self.options['locking'] = 'lock-all' else: self.options['locking'] = lock_test[0] try: lock = Lock(self.server1, lock_test[1], self.options) except UtilError as err: res_entry['lock_res'] = (1, err.errmsg) if lock is not None: if lock_test[0] != 'SKIP_UNLOCK': try: lock.unlock() except UtilError as err: res_entry['unlock_res'] = (1, err.errmsg) else: res = lock.__del__() if res[0:7] == 'WARNING': res_entry['unlock_res'] = (1, res) else: res_entry['unlock_res'] = (1, "Wrong result: " "{0}".format(res)) else: res_entry['unlock_res'] = (1, "Unlock() skipped.") self.results.append(res_entry) if self.debug: print(comment_str) print(" expected to fail:", res_entry['lock_fail'], res_entry['unlock_fail']) print(" locking step:", res_entry['lock_res'][0], res_entry['lock_res'][1]) print(" unlocking step:", res_entry['unlock_res'][0], res_entry['unlock_res'][1]) test_num += 1 return True
def run(self): from mysql.utilities.common.lock import Lock self.server1 = self.servers.get_server(0) test_num = 1 # Here we test the locking and unlocking of tables (if applicable) # for the locking types. comment = "Test case {0} - test locking type '{1}'" for lock_test in _LOCKTESTS: lock = None comment_str = comment.format(test_num, lock_test[0]) res_entry = {'test_case': comment_str, 'lock_res': (0, ""), 'unlock_res': (0, ""), 'lock_fail': lock_test[2], 'unlock_fail': lock_test[3], } if lock_test[0] == 'SKIP_UNLOCK': self.options['locking'] = 'lock-all' else: self.options['locking'] = lock_test[0] try: lock = Lock(self.server1, lock_test[1], self.options) except UtilError as err: res_entry['lock_res'] = (1, err.errmsg) if lock is not None: if lock_test[0] != 'SKIP_UNLOCK': try: lock.unlock() except UtilError as err: res_entry['unlock_res'] = (1, err.errmsg) else: res = lock.__del__() if res[0:7] == 'WARNING': res_entry['unlock_res'] = (1, res) else: res_entry['unlock_res'] = (1, "Wrong result: " "{0}".format(res)) else: res_entry['unlock_res'] = (1, "Unlock() skipped.") self.results.append(res_entry) if self.debug: print(comment_str) print(" expected to fail:", res_entry['lock_fail'], res_entry['unlock_fail']) print(" locking step:", res_entry['lock_res'][0], res_entry['lock_res'][1]) print (" unlocking step:", res_entry['unlock_res'][0], res_entry['unlock_res'][1]) test_num += 1 return True
def run(self): from mysql.utilities.common.lock import Lock self.server1 = self.servers.get_server(0) test_num = 1 # Here we test the locking and unlocking of tables (if applicable) # for the locking types. comment = "Test case %s - test locking type '%s'" for lock_test in _LOCKTESTS: lock = None comment_str = comment % (test_num, lock_test[0]) res_entry = { 'test_case' : comment_str, 'lock_res' : (0,""), 'unlock_res' : (0,""), 'lock_fail' : lock_test[2], 'unlock_fail' : lock_test[3], } if lock_test[0] == 'SKIP_UNLOCK': self.options['locking'] = 'lock-all' else: self.options['locking'] = lock_test[0] try: lock = Lock(self.server1, lock_test[1], self.options) except UtilError, e: res_entry['lock_res'] = (1, e.errmsg) if lock is not None: if lock_test[0] != 'SKIP_UNLOCK': try: lock.unlock() except UtilError, e: res_entry['unlock_res'] = (1, e.errmsg) else: res = lock.__del__() if res[0:7] == 'WARNING': res_entry['unlock_res'] = (1, res) else: res_entry['unlock_res'] = (1, "Wrong result: %s" % res)
def _make_sum_rows(table, idx_str): """Populate the summary table This method inserts rows into the compare table from the original table then forms the summary table by combining a prefix of the primary key hash (group by). table[in] Table instance idx_str[in] string representation of primary key columns Returns result from """ from mysql.utilities.common.lock import Lock col_str = ", ".join(table.get_col_names(True)) # Lock table first tbl_lock_list = [(table.table, 'READ'), ("%s.compare_%s" % (table.db_name, table.tbl_name), 'WRITE')] my_lock = Lock(table.server, tbl_lock_list) # Quote compare table appropriately with backticks q_tbl_name = quote_with_backticks( _COMPARE_TABLE_NAME.format(tbl=table.tbl_name)) table.server.exec_query( _COMPARE_INSERT.format(db=table.q_db_name, compare_tbl=q_tbl_name, colstr=col_str.strip(", "), pkstr=idx_str.strip(", "), table=table.q_tbl_name)) res = table.server.exec_query( _COMPARE_SUM.format(db=table.q_db_name, compare_tbl=q_tbl_name)) # Unlock table my_lock.unlock() return res