コード例 #1
0
    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
コード例 #2
0
ファイル: locking.py プロジェクト: abooitt/mysql-utilities
    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
コード例 #3
0
ファイル: locking.py プロジェクト: dzhibas/mysql-utilities
    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)
コード例 #4
0
ファイル: locking.py プロジェクト: 1newstar/OPS-Tools
    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)