Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
gravel/tests: fake up /var/lib/aquarium for KV store
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Serong <tserong@suse.com>
  • Loading branch information
tserong committed Aug 24, 2021
1 parent 955575c commit d6e1339
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/gravel/controllers/kv.py
Expand Up @@ -57,7 +57,12 @@ def __init__(self):
# Or, do we only open it when reading/writing in individual methods?
# That would probably be better... (but would still have problems due to
# simultaneous access, but we can always raise an exception in that case I guess?)
self._db = dbm.open(f"{var_lib_aquarium}/kvstore", "c")
try:
self._db = dbm.open(f"{var_lib_aquarium}/kvstore", "c")
except Exception as e:
# Only raise exceptions opening db file when *not* running unit tests
if "pytest" not in sys.modules:
raise e
self._cluster: Optional[rados.Rados] = None
self._connector_thread = threading.Thread(target=self._cluster_connect)
self._run = True
Expand Down
6 changes: 5 additions & 1 deletion src/gravel/tests/conftest.py
Expand Up @@ -169,9 +169,13 @@ async def cancel_watch(self, watch_id: int) -> None:
@pytest.fixture()
@pytest.mark.asyncio
async def aquarium_startup(
get_data_contents: Callable[[str, str], str], mocker: MockerFixture
get_data_contents: Callable[[str, str], str],
mocker: MockerFixture,
fs: fake_filesystem.FakeFilesystem,
):
# Need the following to fake up KV
mock_ceph_modules(mocker)
fs.create_dir("/var/lib/aquarium")

async def startup(aquarium_app: FastAPI, aquarium_api: FastAPI):
from fastapi.logger import logger as fastapi_logger
Expand Down

0 comments on commit d6e1339

Please sign in to comment.