diff --git a/CHANGELOG.md b/CHANGELOG.md index 181ef7a2..373a691b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 queued requests (PR #336). - Recover `ConnectionPool` instances after a cluster restart (PR #343). +- Fix typo in the name: PoolTolopogy -> PoolTopology. Ensured + backward compatibility using aliases (PR #345). ## 1.2.0 - 2024-03-27 diff --git a/tarantool/connection_pool.py b/tarantool/connection_pool.py index 9e335c37..ef02433c 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, DatabaseError, NetworkError, @@ -295,14 +295,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): """ @@ -313,7 +313,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: @@ -579,7 +579,7 @@ def _get_new_state(self, unit): except DatabaseError 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: @@ -587,7 +587,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: @@ -595,12 +595,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 a8a421db..49c37e87 100644 --- a/test/suites/test_pool.py +++ b/test/suites/test_pool.py @@ -15,6 +15,8 @@ ClusterConnectWarning, DatabaseError, NetworkWarning, + PoolTopologyError, + PoolTopologyWarning, PoolTolopogyError, PoolTolopogyWarning, ) @@ -24,6 +26,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' @@ -189,7 +197,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) @@ -209,7 +217,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) @@ -515,7 +523,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(