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:
Roman Podoliaka 2015-01-05 11:28:54 +02:00
parent 44c9c574bd
commit 30433383c7
2 changed files with 16 additions and 0 deletions

View File

@ -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):

View File

@ -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):