diff --git a/tarantool/connection_pool.py b/tarantool/connection_pool.py index f1e675b3..ae07069a 100644 --- a/tarantool/connection_pool.py +++ b/tarantool/connection_pool.py @@ -22,8 +22,8 @@ ) from tarantool.error import ( ClusterConnectWarning, - PoolTolopogyError, - PoolTolopogyWarning, + PoolTopologyError, + PoolTopologyWarning, ConfigurationError, NetworkError, warn @@ -294,14 +294,14 @@ def _getnext_by_mode(self, *iters, err_msg="Can't find healthy instance in pool" :rtype: :class:`~tarantool.connection_pool.PoolUnit` - :raise: :exc:`~tarantool.error.PoolTolopogyError` + :raise: :exc:`~tarantool.error.PoolTopologyError` :meta private: """ for itr in iters: if itr is not None: return next(itr) - raise PoolTolopogyError(err_msg) + raise PoolTopologyError(err_msg) def getnext(self, mode): """ @@ -312,7 +312,7 @@ def getnext(self, mode): :rtype: :class:`~tarantool.connection_pool.PoolUnit` - :raise: :exc:`~tarantool.error.PoolTolopogyError` + :raise: :exc:`~tarantool.error.PoolTopologyError` """ if self.rebuild_needed: @@ -578,7 +578,7 @@ def _get_new_state(self, unit): except NetworkError as exc: msg = (f"Failed to get box.info for {unit.get_address()}, " f"reason: {repr(exc)}") - warn(msg, PoolTolopogyWarning) + warn(msg, PoolTopologyWarning) return InstanceState(Status.UNHEALTHY) try: @@ -586,7 +586,7 @@ def _get_new_state(self, unit): except (IndexError, KeyError) as exc: msg = (f"Incorrect box.info response from {unit.get_address()}" f"reason: {repr(exc)}") - warn(msg, PoolTolopogyWarning) + warn(msg, PoolTopologyWarning) return InstanceState(Status.UNHEALTHY) try: @@ -594,12 +594,12 @@ def _get_new_state(self, unit): if status != 'running': msg = f"{unit.get_address()} instance status is not 'running'" - warn(msg, PoolTolopogyWarning) + warn(msg, PoolTopologyWarning) return InstanceState(Status.UNHEALTHY) except (IndexError, KeyError) as exc: msg = (f"Incorrect box.info response from {unit.get_address()}" f"reason: {repr(exc)}") - warn(msg, PoolTolopogyWarning) + warn(msg, PoolTopologyWarning) return InstanceState(Status.UNHEALTHY) return InstanceState(Status.HEALTHY, read_only) diff --git a/tarantool/error.py b/tarantool/error.py index 85e30c03..fd6d88f9 100644 --- a/tarantool/error.py +++ b/tarantool/error.py @@ -309,14 +309,14 @@ class ClusterConnectWarning(UserWarning): """ -class PoolTolopogyWarning(UserWarning): +class PoolTopologyWarning(UserWarning): """ Warning related to unsatisfying `box.info.ro`_ state of pool instances. """ -class PoolTolopogyError(DatabaseError): +class PoolTopologyError(DatabaseError): """ Exception raised due to unsatisfying `box.info.ro`_ state of pool instances. @@ -325,6 +325,11 @@ class PoolTolopogyError(DatabaseError): """ +# Backward-compatible aliases for the previously exposed misspelled names. +PoolTolopogyWarning = PoolTopologyWarning +PoolTolopogyError = PoolTopologyError + + class CrudModuleError(DatabaseError): """ Exception raised for errors that are related to diff --git a/test/suites/test_pool.py b/test/suites/test_pool.py index e15bcbbf..7e5fe0bf 100644 --- a/test/suites/test_pool.py +++ b/test/suites/test_pool.py @@ -14,6 +14,8 @@ ClusterConnectWarning, DatabaseError, NetworkWarning, + PoolTopologyError, + PoolTopologyWarning, PoolTolopogyError, PoolTolopogyWarning, ) @@ -23,6 +25,12 @@ from .utils import assert_admin_success +class TestSuitePoolErrorAliases(unittest.TestCase): # pylint: disable=too-few-public-methods + def test_pool_topology_error_aliases(self): + self.assertIs(PoolTolopogyError, PoolTopologyError) + self.assertIs(PoolTolopogyWarning, PoolTopologyWarning) + + def create_server(_id): srv = TarantoolServer() srv.script = 'test/suites/box.lua' @@ -188,7 +196,7 @@ def get_port(self, mode): # Expect RW to fail if there are no RW. def expect_rw_to_fail_if_there_are_no_rw(): - with self.assertRaises(PoolTolopogyError): + with self.assertRaises(PoolTopologyError): self.pool.eval('return box.cfg.listen', mode=tarantool.Mode.RW) self.retry(func=expect_rw_to_fail_if_there_are_no_rw) @@ -208,7 +216,7 @@ def expect_prefer_rw_iterate_through_all_instances_if_there_are_no_rw(): # Expect RO to fail if there are no RO. def expect_ro_to_fail_if_there_are_no_ro(): - with self.assertRaises(PoolTolopogyError): + with self.assertRaises(PoolTopologyError): self.pool.eval('return box.cfg.listen', mode=tarantool.Mode.RO) self.retry(func=expect_ro_to_fail_if_there_are_no_ro) @@ -514,7 +522,7 @@ def test_12_execute(self): def test_13_failover(self): warnings.simplefilter('ignore', category=NetworkWarning) - warnings.simplefilter('ignore', category=PoolTolopogyWarning) + warnings.simplefilter('ignore', category=PoolTopologyWarning) self.set_cluster_ro([False, True, True, True, True]) self.pool = tarantool.ConnectionPool(