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

Commit

Permalink
gravel/tests: handle new KV correctly in conftest.py
Browse files Browse the repository at this point in the history
We need to make sure python3-rados is mocked out, and the connection thread
doesn't keep running when testing.

Signed-off-by: Tim Serong <tserong@suse.com>
  • Loading branch information
tserong committed Aug 23, 2021
1 parent 6ec4254 commit 955575c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gravel/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ async def cancel_watch(self, watch_id: int) -> None:
async def aquarium_startup(
get_data_contents: Callable[[str, str], str], mocker: MockerFixture
):
mock_ceph_modules(mocker)

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

Expand Down Expand Up @@ -280,6 +282,11 @@ class FakeStorage(Storage): # type: ignore
total = 2000 # type: ignore

gstate: GlobalState = GlobalState()
# gstate's KV store will start a thread to try to connect to the
# cluster. This can't work in a test environment, so tell it to
# close (otherwise the thread will spin forever and the tests will
# never complete)
await gstate._kvstore.close()
gstate._kvstore = FakeKV() # pyright: reportPrivateUsage=false

# init node mgr
Expand Down

0 comments on commit 955575c

Please sign in to comment.