summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2022-09-09 17:34:40 +0100
committerStephen Finucane <stephenfin@redhat.com>2022-09-09 17:34:40 +0100
commit437a19703d63801997f2ccece516a2790d438cee (patch)
treec724010db33e16428b3304c82e7ef1dcf09d1584
parent995a81d305e0e3819bb768666399b662d2bbc724 (diff)
downloadoslo-db-437a19703d63801997f2ccece516a2790d438cee.tar.gz
tests: Fix compatibility with PostgreSQL 14+
It seems postgres-client has changed the format of error messages. Previously we saw messages like: fatal: database "non_existent_database" does not exist These are now prefixed. For example: connection to server at "localhost" (::1), port 5432 failed: fatal: database "non_existent_database" does not exist You can see this in the docs. Compare the "Client Connection Problems" section for Postgres 13 [1] to Postgres 14 [2]. [1] https://www.postgresql.org/docs/13/server-start.html [2] https://www.postgresql.org/docs/14/server-start.html Change-Id: Id2c8eec202d128d142b8a8a8f904fcc14b6f52d7 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Closes-bug: #1989208
-rw-r--r--oslo_db/tests/sqlalchemy/test_exc_filters.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py
index 53789f5..7e03fce 100644
--- a/oslo_db/tests/sqlalchemy/test_exc_filters.py
+++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py
@@ -462,10 +462,20 @@ class TestNonExistentDatabasePostgreSQL(
self.url
)
self.assertEqual('non_existent_database', matched.database)
- self.assertInnerException(
- matched,
+ # NOTE(stephenfin): As above, we cannot use assertInnerException since
+ # the error messages vary depending on the version of PostgreSQL
+ self.assertIsInstance(
+ matched.inner_exception,
sqlalchemy.exc.OperationalError,
- 'fatal: database "non_existent_database" does not exist\n',
+ )
+ # On Postgres 13:
+ # fatal: database "non_existent_database" does not exist
+ # On Postgres 14 or later:
+ # connection to server at "localhost" (::1), port 5432 failed: fatal:
+ # database "non_existent_database" does not exist
+ self.assertIn(
+ 'fatal: database "non_existent_database" does not exist',
+ str(matched.inner_exception).lower(),
)