Skip to content

Commit a70960e

Browse files
committed
Add connection poll loop to es test as well
1 parent 56940bd commit a70960e

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

tests/test_databases.py

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from typing import AsyncContextManager
44

5-
from elasticsearch import Elasticsearch
5+
from elasticsearch import (
6+
Elasticsearch,
7+
ConnectionError,
8+
)
69
from piker.service import marketstore
710

811

@@ -45,8 +48,8 @@ async def main():
4548
if cs.cancelled_caught:
4649
continue
4750

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

@@ -72,12 +75,25 @@ def test_elasticsearch_startup_and_version(
7275
async def main():
7376
port = 19200
7477

75-
async with open_test_pikerd(
76-
loglevel=loglevel,
77-
es=True
78-
) as (s, i, pikerd_portal, services):
78+
async with (
79+
open_test_pikerd(
80+
loglevel=loglevel,
81+
es=True
82+
) as (
83+
_, # host
84+
_, # port
85+
pikerd_portal,
86+
services,
87+
),
88+
):
89+
90+
for _ in range(240):
91+
try:
92+
es = Elasticsearch(hosts=[f'http://localhost:{port}'])
93+
except ConnectionError:
94+
await trio.sleep(1)
95+
continue
7996

80-
es = Elasticsearch(hosts=[f'http://localhost:{port}'])
81-
assert es.info()['version']['number'] == '7.17.4'
97+
assert es.info()['version']['number'] == '7.17.4'
8298

8399
trio.run(main)

0 commit comments

Comments
 (0)