Skip to content

Commit 1b5f536

Browse files
Joan Fontanalshanxiao
andauthored
test: simplify post test (#201)
* test: simplify post test * style: fix black Co-authored-by: Han Xiao <[email protected]>
1 parent a6d11a1 commit 1b5f536

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

tests/unit/array/mixins/test_post.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,18 @@
2121
def test_post_to_a_flow(show_pbar, conn_config, batch_size):
2222
from jina import Flow
2323

24-
def start_flow(stop_event, **kwargs):
25-
"""start a blocking Flow."""
26-
with Flow(**kwargs) as f:
27-
f.block(stop_event=stop_event)
28-
print('bye')
29-
30-
e = multiprocessing.Event() # create new Event
31-
3224
p = random_port()
33-
t = multiprocessing.Process(
34-
name='Blocked-Flow',
35-
target=start_flow,
36-
args=(e,),
37-
kwargs={**conn_config[0], 'port': p},
38-
)
39-
t.start()
40-
41-
time.sleep(3)
42-
4325
da = DocumentArray.empty(100)
44-
try:
26+
with Flow(**{**conn_config[0], 'port': p}):
4527
da.post(conn_config[1].replace('$port', str(p)), batch_size=batch_size)
46-
except:
47-
raise
48-
finally:
49-
e.set()
50-
t.join()
51-
time.sleep(1)
5228

5329

5430
@pytest.mark.parametrize(
5531
'hub_uri',
5632
[
5733
'jinahub://Hello',
5834
'jinahub+sandbox://Hello',
59-
#'jinahub+docker://Hello', this somehow does not work on GH workflow
35+
# 'jinahub+docker://Hello', this somehow does not work on GH workflow
6036
],
6137
)
6238
def test_post_with_jinahub(hub_uri):
@@ -95,7 +71,7 @@ def start_flow(stop_event, **kwargs):
9571
)
9672
t.start()
9773

98-
time.sleep(1)
74+
time.sleep(5)
9975
N = 100
10076
da = DocumentArray.empty(N)
10177
try:

0 commit comments

Comments
 (0)