diff --git a/keep/api/core/db_utils.py b/keep/api/core/db_utils.py index 6d0841e7db..2b3745d98f 100644 --- a/keep/api/core/db_utils.py +++ b/keep/api/core/db_utils.py @@ -113,6 +113,12 @@ def __get_conn_impersonate() -> pymysql.connections.Connection: KEEP_DB_PRE_PING_ENABLED = config( "KEEP_DB_PRE_PING_ENABLED", default=False, cast=bool ) # pylint: disable=invalid-name +DB_POOL_RECYCLE = config( + "DATABASE_POOL_RECYCLE", default=3600, cast=int +) # pylint: disable=invalid-name +DB_POOL_TIMEOUT = config( + "DATABASE_POOL_TIMEOUT", default=30, cast=int +) # pylint: disable=invalid-name def dumps(_json) -> str: @@ -160,6 +166,8 @@ def create_db_engine(): json_serializer=dumps, echo=DB_ECHO, pool_pre_ping=True if KEEP_DB_PRE_PING_ENABLED else False, + pool_recycle=DB_POOL_RECYCLE, + pool_timeout=DB_POOL_TIMEOUT, ) # SQLite does not support pool_size except TypeError: diff --git a/tests/conftest.py b/tests/conftest.py index b971dfcb6c..b9731d970f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -96,6 +96,14 @@ def context_manager(): return ContextManager(tenant_id=SINGLE_TENANT_UUID, workflow_id="1234") +@pytest.fixture +def tenant_id(): + """ + Provides the default single tenant UUID for tests. + """ + return SINGLE_TENANT_UUID + + @pytest.fixture(scope="session") def docker_services( docker_compose_command,