From 1f4f66b22cdbd34fb2fece735fbce0ad507084e4 Mon Sep 17 00:00:00 2001 From: Marten Wijnja Date: Fri, 30 Jan 2026 14:38:03 +0100 Subject: [PATCH] In tests on CI, store the test DBs in memory to fix self-hosted Semaphore runners sometimes hanging --- libs/opsqueue_python/tests/conftest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/opsqueue_python/tests/conftest.py b/libs/opsqueue_python/tests/conftest.py index b4b10bf..c0c9d37 100644 --- a/libs/opsqueue_python/tests/conftest.py +++ b/libs/opsqueue_python/tests/conftest.py @@ -4,7 +4,6 @@ from typing import Generator, Callable, Any, Iterable import multiprocessing import subprocess -import uuid import os import pytest from dataclasses import dataclass @@ -59,7 +58,14 @@ def opsqueue_service( if port is None: port = random_free_port() - temp_dbname = f"/tmp/opsqueue_tests-{uuid.uuid4()}.db" + # This will create a SQLite database in memory. + # We need the `cache=shared` to allow sharing this DB between all threads within the same OS process. + temp_dbname = "file::memory:?cache=shared" + + # Switch this for the following if debugging a particular test locally. + # This is not the default because specifically Semaphore backed with Butterfs + # will from time to time hang for **many minutes** on initializing SQLite for some reason. + # temp_dbname = f"/tmp/opsqueue_tests-{uuid.uuid4()}.db" command = [ str(opsqueue_bin_location()),