-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return a ServiceUnavailable Error when a db is not reachable, and
retry connecting
- Loading branch information
Showing
12 changed files
with
170 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ dependencies: | |
- aiohttp | ||
- aiomysql | ||
- aiosqlite | ||
- asyncache | ||
- azure-core | ||
- cachetools | ||
######## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ install_requires = | |
aiohttp | ||
aiomysql | ||
aiosqlite | ||
asyncache | ||
azure-core | ||
cachetools | ||
m2crypto >=0.38.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from __future__ import annotations | ||
|
||
__all__ = ("sql", "os") | ||
__all__ = ("sql", "os", "exceptions") | ||
|
||
from . import os, sql | ||
from . import exceptions, os, sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class DBUnavailable(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
from diracx.core.exceptions import InvalidQueryError | ||
from diracx.db.sql.dummy.db import DummyDB | ||
from diracx.db.sql.utils import SQLDBUnavailable | ||
|
||
# Each DB test class must defined a fixture looking like this one | ||
# It allows to get an instance of an in memory DB, | ||
|
@@ -67,3 +68,11 @@ async def test_insert_and_summary(dummy_db: DummyDB): | |
} | ||
], | ||
) | ||
|
||
|
||
async def test_bad_connection(): | ||
dummy_db = DummyDB("mysql+aiomysql://tata:[email protected]:3306/name") | ||
async with dummy_db.engine_context(): | ||
with pytest.raises(SQLDBUnavailable): | ||
async with dummy_db: | ||
dummy_db.ping() |
Oops, something went wrong.