Ensure PostgreSQL connection errors are wrapped
Currently PostgreSQL connection errors are not wrapped with our custom DBConnectionError and engine.connect() will raise OperationalError instead. Change-Id: Iefdb9a99ca0cbe982bf12cb7e1ac47996fc5a025
This commit is contained in:
parent
44c9c574bd
commit
30433383c7
@ -270,6 +270,7 @@ def _raise_operational_errors_directly_filter(operational_error,
|
||||
|
||||
|
||||
@filters("mysql", sqla_exc.OperationalError, r".*\(.*(?:2002|2003|2006|2013)")
|
||||
@filters("postgresql", sqla_exc.OperationalError, r".*could not connect to server") # noqa
|
||||
@filters("ibm_db_sa", sqla_exc.OperationalError, r".*(?:30081)")
|
||||
def _is_db_connection_error(operational_error, match, engine_name,
|
||||
is_disconnect):
|
||||
|
@ -745,6 +745,21 @@ class TestDBDisconnected(TestsExceptionFilter):
|
||||
is_disconnect=False
|
||||
)
|
||||
|
||||
def test_postgresql_ping_listener_disconnected(self):
|
||||
self._test_ping_listener_disconnected(
|
||||
"postgresql",
|
||||
self.OperationalError(
|
||||
"could not connect to server: Connection refused"),
|
||||
)
|
||||
|
||||
def test_postgresql_ping_listener_disconnected_regex_only(self):
|
||||
self._test_ping_listener_disconnected(
|
||||
"postgresql",
|
||||
self.OperationalError(
|
||||
"could not connect to server: Connection refused"),
|
||||
is_disconnect=False
|
||||
)
|
||||
|
||||
|
||||
class TestDBConnectRetry(TestsExceptionFilter):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user