Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix setting extra host_connect_in (#2973)
* feat: add local flow use remote executor test * test: add docker compose * test: add endpoint * test: assert with return results * feat: add static ip address * fix: fix setting extra host_connect_in * test: add tests to have remote pod working Co-authored-by: bwanglzu <bo.wang@jina.ai>
- Loading branch information
Showing
12 changed files
with
187 additions
and
68 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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Empty file.
25 changes: 25 additions & 0 deletions
25
tests/distributed/test_local_flow_use_remote_executor/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,25 @@ | ||
version: "3.3" | ||
services: | ||
external-executor: | ||
image: jinaai/jina:test-pip | ||
environment: | ||
JINA_LOG_LEVEL: DEBUG | ||
container_name: test_external_executor | ||
ports: | ||
- "8001:8000" | ||
- "45678:45678" | ||
expose: | ||
- 10000-60000 | ||
networks: | ||
test: | ||
ipv4_address: 10.1.0.100 | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
entrypoint: "jina pod --port-in 45678 --port-out 45679 --dynamic-routing-in --dynamic-routing-out --dynamic-routing" | ||
networks: | ||
test: | ||
driver: bridge | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 10.1.0.0/24 |
58 changes: 58 additions & 0 deletions
58
tests/distributed/test_local_flow_use_remote_executor/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,58 @@ | ||
import os | ||
|
||
import pytest | ||
import numpy as np | ||
|
||
from jina import Flow, Document | ||
from jina.parsers import set_pod_parser | ||
|
||
cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
compose_yml = os.path.join(cur_dir, 'docker-compose.yml') | ||
|
||
|
||
@pytest.fixture | ||
def external_pod_args(): | ||
args = ['--port-in', str(45678), '--port-out', str(45679)] | ||
args = vars(set_pod_parser().parse_args(args)) | ||
del args['external'] | ||
del args['pod_role'] | ||
del args['host'] | ||
return args | ||
|
||
|
||
@pytest.fixture | ||
def local_flow(external_pod_args): | ||
return Flow().add(**external_pod_args, host='10.1.0.100', external=True) | ||
|
||
|
||
@pytest.fixture | ||
def documents_to_index(): | ||
image = np.random.random((50, 50)) | ||
return [Document(content=image) for i in range(200)] | ||
|
||
|
||
@pytest.fixture | ||
def patched_remote_local_connection(monkeypatch): | ||
def alternative_remote_local_connection(first, second): | ||
if first == '10.1.0.100': | ||
return True | ||
else: | ||
return False | ||
|
||
monkeypatch.setattr( | ||
'jina.flow.base.is_remote_local_connection', | ||
lambda x, y: alternative_remote_local_connection(x, y), | ||
) | ||
|
||
|
||
@pytest.mark.parametrize('docker_compose', [compose_yml], indirect=['docker_compose']) | ||
def test_local_flow_use_external_executor( | ||
local_flow, documents_to_index, patched_remote_local_connection, docker_compose | ||
): | ||
with local_flow as f: | ||
responses = f.index( | ||
inputs=documents_to_index, return_results=True, request_size=100 | ||
) | ||
assert len(responses) == 2 | ||
for resp in responses: | ||
assert len(resp.docs) == 100 |
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