Re-implement db tests using new ahab daemons
Avoids the really sloppy flag passing to `open_pikerd()` and allows for separation of the individual docker daemon starts. Also add a new `root_conf() -> Path` fixture which will open and load the `dict` for the new root `conf.toml` file.master
parent
d094625bd6
commit
cd55d027c4
|
@ -120,12 +120,7 @@ async def _open_test_pikerd(
|
||||||
'piker_test_dir': tmpconfdir,
|
'piker_test_dir': tmpconfdir,
|
||||||
},
|
},
|
||||||
|
|
||||||
# tests may need to spawn containers dynamically
|
|
||||||
# or just in sequence per test, so we keep root.
|
|
||||||
drop_root_perms_for_ahab=False,
|
|
||||||
|
|
||||||
debug_mode=debug_mode,
|
debug_mode=debug_mode,
|
||||||
|
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
||||||
) as service_manager,
|
) as service_manager,
|
||||||
|
@ -182,6 +177,14 @@ def tmpconfdir(
|
||||||
# rmtree(str(tmp_path))
|
# rmtree(str(tmp_path))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def root_conf(tmpconfdir) -> dict:
|
||||||
|
return config.load(
|
||||||
|
'conf',
|
||||||
|
touch_if_dne=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def open_test_pikerd(
|
def open_test_pikerd(
|
||||||
request: pytest.FixtureRequest,
|
request: pytest.FixtureRequest,
|
||||||
|
|
|
@ -14,6 +14,7 @@ from piker.service import elastic
|
||||||
def test_marketstore_startup_and_version(
|
def test_marketstore_startup_and_version(
|
||||||
open_test_pikerd: AsyncContextManager,
|
open_test_pikerd: AsyncContextManager,
|
||||||
loglevel: str,
|
loglevel: str,
|
||||||
|
root_conf: dict,
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Verify marketstore tsdb starts up and we can
|
Verify marketstore tsdb starts up and we can
|
||||||
|
@ -21,18 +22,39 @@ def test_marketstore_startup_and_version(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
async def main():
|
async def main():
|
||||||
|
user_conf: dict = {
|
||||||
|
'grpc_listen_port': 5995 + 6,
|
||||||
|
'ws_listen_port': 5993 + 6,
|
||||||
|
}
|
||||||
|
|
||||||
|
dname: str # service name
|
||||||
|
config: dict # service name
|
||||||
|
|
||||||
async with (
|
async with (
|
||||||
open_test_pikerd(
|
open_test_pikerd(
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
tsdb=True
|
# tsdb=True
|
||||||
) as (
|
) as (
|
||||||
_, # host
|
_, # host
|
||||||
_, # port
|
_, # port
|
||||||
pikerd_portal,
|
pikerd_portal,
|
||||||
services,
|
services,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
marketstore.start_ahab_daemon(
|
||||||
|
services,
|
||||||
|
user_conf,
|
||||||
|
loglevel=loglevel,
|
||||||
|
|
||||||
|
) as (dname, config)
|
||||||
):
|
):
|
||||||
|
# ensure user config was applied
|
||||||
|
for k, v in user_conf.items():
|
||||||
|
assert config[k] == v
|
||||||
|
|
||||||
|
# netconf: dict = root_conf['network']
|
||||||
|
# tsdbconf = netconf['tsdb']
|
||||||
|
|
||||||
# TODO: we should probably make this connection poll
|
# TODO: we should probably make this connection poll
|
||||||
# loop part of the `get_client()` implementation no?
|
# loop part of the `get_client()` implementation no?
|
||||||
|
|
||||||
|
@ -45,7 +67,12 @@ def test_marketstore_startup_and_version(
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
|
|
||||||
# NOTE: default sockaddr is embedded within
|
# NOTE: default sockaddr is embedded within
|
||||||
async with marketstore.get_client() as client:
|
async with marketstore.get_client(
|
||||||
|
host='localhost',
|
||||||
|
port=user_conf['grpc_listen_port'],
|
||||||
|
|
||||||
|
) as client:
|
||||||
|
print(f'Client is up @ {user_conf}!')
|
||||||
|
|
||||||
with trio.move_on_after(1) as cs:
|
with trio.move_on_after(1) as cs:
|
||||||
syms = await client.list_symbols()
|
syms = await client.list_symbols()
|
||||||
|
@ -64,7 +91,13 @@ def test_marketstore_startup_and_version(
|
||||||
)
|
)
|
||||||
print('VERSION CHECKED')
|
print('VERSION CHECKED')
|
||||||
|
|
||||||
|
|
||||||
break # get out of retry-connect loop
|
break # get out of retry-connect loop
|
||||||
|
else:
|
||||||
|
raise RuntimeError('Failed to connect to {conf}!')
|
||||||
|
|
||||||
|
# gracefully teardown docker-daemon-service
|
||||||
|
print(f'Cancelling docker service {dname}')
|
||||||
|
|
||||||
trio.run(main)
|
trio.run(main)
|
||||||
|
|
||||||
|
@ -80,18 +113,29 @@ def test_elasticsearch_startup_and_version(
|
||||||
|
|
||||||
'''
|
'''
|
||||||
async def main():
|
async def main():
|
||||||
port = 19200
|
port: int = 19200
|
||||||
|
user_conf: dict = {
|
||||||
|
'port': port,
|
||||||
|
}
|
||||||
|
|
||||||
|
dname: str # service name
|
||||||
|
config: dict # service name
|
||||||
|
|
||||||
async with (
|
async with (
|
||||||
open_test_pikerd(
|
open_test_pikerd(
|
||||||
loglevel=loglevel,
|
loglevel=loglevel,
|
||||||
es=True
|
|
||||||
) as (
|
) as (
|
||||||
_, # host
|
_, # host
|
||||||
_, # port
|
_, # port
|
||||||
pikerd_portal,
|
pikerd_portal,
|
||||||
services,
|
services,
|
||||||
),
|
),
|
||||||
|
elastic.start_ahab_daemon(
|
||||||
|
services,
|
||||||
|
user_conf,
|
||||||
|
loglevel=loglevel,
|
||||||
|
|
||||||
|
) as (dname, config)
|
||||||
):
|
):
|
||||||
# TODO: much like the above connect loop for mkts, we should
|
# TODO: much like the above connect loop for mkts, we should
|
||||||
# probably make this sync start part of the
|
# probably make this sync start part of the
|
||||||
|
|
Loading…
Reference in New Issue