Add connection poll loop to es test as well
parent
79b0db4449
commit
7cc9911565
|
@ -2,7 +2,10 @@ import trio
|
||||||
|
|
||||||
from typing import AsyncContextManager
|
from typing import AsyncContextManager
|
||||||
|
|
||||||
from elasticsearch import Elasticsearch
|
from elasticsearch import (
|
||||||
|
Elasticsearch,
|
||||||
|
ConnectionError,
|
||||||
|
)
|
||||||
from piker.service import marketstore
|
from piker.service import marketstore
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +48,8 @@ def test_marketstore_startup_and_version(
|
||||||
if cs.cancelled_caught:
|
if cs.cancelled_caught:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# should be an empty db (for now) since we spawn
|
||||||
# should be an empty db?
|
# marketstore in a ephemeral test-harness dir.
|
||||||
assert not syms
|
assert not syms
|
||||||
print(f'RX syms resp: {syms}')
|
print(f'RX syms resp: {syms}')
|
||||||
|
|
||||||
|
@ -72,12 +75,25 @@ def test_elasticsearch_startup_and_version(
|
||||||
async def main():
|
async def main():
|
||||||
port = 19200
|
port = 19200
|
||||||
|
|
||||||
async with open_test_pikerd(
|
async with (
|
||||||
loglevel=loglevel,
|
open_test_pikerd(
|
||||||
es=True
|
loglevel=loglevel,
|
||||||
) as (s, i, pikerd_portal, services):
|
es=True
|
||||||
|
) as (
|
||||||
|
_, # host
|
||||||
|
_, # port
|
||||||
|
pikerd_portal,
|
||||||
|
services,
|
||||||
|
),
|
||||||
|
):
|
||||||
|
|
||||||
es = Elasticsearch(hosts=[f'http://localhost:{port}'])
|
for _ in range(240):
|
||||||
assert es.info()['version']['number'] == '7.17.4'
|
try:
|
||||||
|
es = Elasticsearch(hosts=[f'http://localhost:{port}'])
|
||||||
|
except ConnectionError:
|
||||||
|
await trio.sleep(1)
|
||||||
|
continue
|
||||||
|
|
||||||
|
assert es.info()['version']['number'] == '7.17.4'
|
||||||
|
|
||||||
trio.run(main)
|
trio.run(main)
|
||||||
|
|
Loading…
Reference in New Issue