2023-02-21 16:29:35 +00:00
|
|
|
import pytest
|
|
|
|
import trio
|
|
|
|
|
|
|
|
from typing import AsyncContextManager
|
|
|
|
|
|
|
|
from piker._daemon import Services
|
|
|
|
from piker.log import get_logger
|
|
|
|
|
2023-02-21 16:58:04 +00:00
|
|
|
from elasticsearch import Elasticsearch
|
2023-02-22 16:28:07 +00:00
|
|
|
from piker.data import marketstore
|
2023-02-21 16:58:04 +00:00
|
|
|
|
2023-02-22 16:28:07 +00:00
|
|
|
def test_marketstore(
|
|
|
|
open_test_pikerd: AsyncContextManager,
|
|
|
|
):
|
|
|
|
|
|
|
|
'''
|
|
|
|
Verify marketstore starts correctly
|
|
|
|
|
|
|
|
'''
|
|
|
|
log = get_logger(__name__)
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
# port = 5995
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-22 16:28:07 +00:00
|
|
|
async with (
|
|
|
|
open_test_pikerd(
|
|
|
|
loglevel='info',
|
|
|
|
tsdb=True
|
|
|
|
) as (s, i, pikerd_portal, services),
|
|
|
|
marketstore.get_client() as client
|
|
|
|
):
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-22 16:28:07 +00:00
|
|
|
assert (
|
|
|
|
len(await client.server_version()) ==
|
|
|
|
len('3862e9973da36cfc6004b88172c08f09269aaf01')
|
|
|
|
)
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-22 16:28:07 +00:00
|
|
|
|
|
|
|
trio.run(main)
|
2023-02-21 16:29:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_elasticsearch(
|
2023-02-21 16:58:04 +00:00
|
|
|
open_test_pikerd: AsyncContextManager,
|
2023-02-21 16:29:35 +00:00
|
|
|
):
|
2023-02-21 16:58:04 +00:00
|
|
|
'''
|
2023-02-22 16:28:07 +00:00
|
|
|
Verify elasticsearch starts correctly
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-21 16:58:04 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
log = get_logger(__name__)
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-21 16:58:04 +00:00
|
|
|
async def main():
|
|
|
|
port = 19200
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-21 16:58:04 +00:00
|
|
|
async with open_test_pikerd(
|
|
|
|
loglevel='info',
|
|
|
|
es=True
|
|
|
|
) as (s, i, pikerd_portal, services):
|
2023-02-21 16:29:35 +00:00
|
|
|
|
2023-02-21 16:58:04 +00:00
|
|
|
es = Elasticsearch(hosts=[f'http://localhost:{port}'])
|
|
|
|
assert es.info()['version']['number'] == '7.17.4'
|
2023-02-21 16:29:35 +00:00
|
|
|
|
|
|
|
|
2023-02-21 16:58:04 +00:00
|
|
|
trio.run(main)
|