Skip to content

Commit

Permalink
Add connection poll loop to es test as well
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Mar 9, 2023
1 parent 56940bd commit a70960e
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions tests/test_databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

from typing import AsyncContextManager

from elasticsearch import Elasticsearch
from elasticsearch import (
Elasticsearch,
ConnectionError,
)
from piker.service import marketstore


Expand Down Expand Up @@ -45,8 +48,8 @@ async def main():
if cs.cancelled_caught:
continue


# should be an empty db?
# should be an empty db (for now) since we spawn
# marketstore in a ephemeral test-harness dir.
assert not syms
print(f'RX syms resp: {syms}')

Expand All @@ -72,12 +75,25 @@ def test_elasticsearch_startup_and_version(
async def main():
port = 19200

async with open_test_pikerd(
loglevel=loglevel,
es=True
) as (s, i, pikerd_portal, services):
async with (
open_test_pikerd(
loglevel=loglevel,
es=True
) as (
_, # host
_, # port
pikerd_portal,
services,
),
):

for _ in range(240):
try:
es = Elasticsearch(hosts=[f'http://localhost:{port}'])
except ConnectionError:
await trio.sleep(1)
continue

es = Elasticsearch(hosts=[f'http://localhost:{port}'])
assert es.info()['version']['number'] == '7.17.4'
assert es.info()['version']['number'] == '7.17.4'

trio.run(main)

0 comments on commit a70960e

Please sign in to comment.