-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test with local flow and remote pods (#1583)
* fix: parse config source used to upload files in jinad * test: add test simple local remote to daemon tests
- Loading branch information
Showing
12 changed files
with
153 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/integration/daemon/distributed/test_simple_local_remote/.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
JINA_WORKSPACE=workspace |
Empty file.
35 changes: 35 additions & 0 deletions
35
tests/integration/daemon/distributed/test_simple_local_remote/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: "3.3" | ||
services: | ||
a: | ||
image: test_simple_local_remote | ||
build: | ||
context: . | ||
dockerfile: Dockerfiles/debianx.Dockerfile | ||
ports: | ||
- "8000:8000" | ||
- "45000:45000" | ||
- "45001:45001" | ||
- "45002:45002" | ||
env_file: | ||
- tests/integration/daemon/distributed/test_simple_local_remote/.env | ||
expose: | ||
- 10000-60000 | ||
networks: | ||
testing_net: | ||
ipv4_address: 172.28.1.1 | ||
b: | ||
image: test_simple_local_remote | ||
expose: | ||
- 8000 | ||
- 10000-60000 | ||
env_file: | ||
- tests/integration/daemon/distributed/test_simple_local_remote/.env | ||
networks: | ||
testing_net: | ||
ipv4_address: 172.28.1.2 | ||
networks: | ||
testing_net: | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 172.28.0.0/16 |
18 changes: 18 additions & 0 deletions
18
tests/integration/daemon/distributed/test_simple_local_remote/dummy-encoder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
__copyright__ = "Copyright (c) 2020 Jina AI Limited. All rights reserved." | ||
__license__ = "Apache-2.0" | ||
|
||
import numpy as np | ||
|
||
from jina.executors.encoders import BaseEncoder | ||
from jina.executors.decorators import batching | ||
|
||
|
||
class DummyEncoder(BaseEncoder): | ||
def __init__(self, | ||
*args, | ||
**kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
@batching(batch_size=1) | ||
def encode(self, data: 'np.ndarray', *args, **kwargs) -> 'np.ndarray': | ||
return np.random.random((1, 3)) |
5 changes: 5 additions & 0 deletions
5
tests/integration/daemon/distributed/test_simple_local_remote/encode.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
!DummyEncoder | ||
with: | ||
{} | ||
metas: | ||
py_modules: dummy-encoder.py |
20 changes: 20 additions & 0 deletions
20
tests/integration/daemon/distributed/test_simple_local_remote/flow.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
!Flow | ||
with: | ||
read_only: true | ||
pods: | ||
encoder: | ||
# for now all the uploaded files are stored in the same folder, so no subpaths allowed in remote | ||
uses: encode.yml | ||
host: $JINA_ENCODER_HOST | ||
port_in: 45000 | ||
port_ctrl: 45002 | ||
port_expose: 8000 | ||
indexer: | ||
# for now all the uploaded files are stored in the same folder, so no subpaths allowed in remote | ||
uses: index.yml | ||
read_only: False | ||
host: $JINA_INDEXER_HOST | ||
port_in: 45000 | ||
port_out: 45001 | ||
port_ctrl: 45002 | ||
port_expose: 8000 |
18 changes: 18 additions & 0 deletions
18
tests/integration/daemon/distributed/test_simple_local_remote/index.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
!CompoundIndexer | ||
components: | ||
- !NumpyIndexer | ||
with: | ||
index_filename: vec.gz | ||
metric: euclidean | ||
metas: | ||
name: vecidx | ||
workspace: $JINA_WORKSPACE | ||
- !BinaryPbIndexer | ||
with: | ||
index_filename: doc.gz | ||
metas: | ||
name: docidx | ||
workspace: $JINA_WORKSPACE | ||
metas: | ||
name: indexer | ||
workspace: $JINA_WORKSPACE |
32 changes: 32 additions & 0 deletions
32
tests/integration/daemon/distributed/test_simple_local_remote/test_integration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from jina import Document | ||
from jina.flow import Flow | ||
|
||
cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
compose_yml = os.path.join(cur_dir, 'docker-compose.yml') | ||
flow_yml = os.path.join(cur_dir, 'flow.yml') | ||
|
||
|
||
@pytest.mark.parametrize('docker_compose', [compose_yml], indirect=['docker_compose']) | ||
def test_flow(docker_compose, mocker): | ||
text = 'cats rules' | ||
m = mocker.Mock() | ||
|
||
def validate_output(resp): | ||
m() | ||
assert len(resp.index.docs) == 1 | ||
assert resp.index.docs[0].text == text | ||
|
||
os.environ['JINA_ENCODER_HOST'] = '172.28.1.1' | ||
os.environ['JINA_INDEXER_HOST'] = '172.28.1.2' | ||
|
||
with Document() as doc: | ||
doc.content = text | ||
|
||
with Flow.load_config(flow_yml) as f: | ||
f.index([doc], on_done=validate_output) | ||
|
||
m.assert_called_once() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters