Skip to content

Commit

Permalink
test: add test with slow process
Browse files Browse the repository at this point in the history
Signed-off-by: Joan Fontanals Martinez <joan.martinez@jina.ai>
  • Loading branch information
JoanFM committed Nov 17, 2022
1 parent 32dcbc2 commit b82180b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ jobs:
export LINKERD2_VERSION=stable-2.11.4
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh
pytest -v -s --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml ./tests/k8s/test_k8s.py ./tests/k8s/test_graceful_request_handling.py
timeout-minutes: 30
timeout-minutes: 45
env:
JINA_K8S_USE_TEST_PIP: 1
- name: Check codecov file
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ jobs:
export LINKERD2_VERSION=stable-2.11.4
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install | sh
pytest -v -s --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml ./tests/k8s/test_k8s.py ./tests/k8s/test_graceful_request_handling.py
timeout-minutes: 30
timeout-minutes: 45
env:
JINA_K8S_USE_TEST_PIP: 1
- name: Check codecov file
Expand Down
8 changes: 3 additions & 5 deletions tests/k8s/slow-process-executor/debug_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@


class SlowProcessExecutor(Executor):
def __init__(self, *args, **kwargs):
def __init__(self, time_sleep=1.0, *args, **kwargs):
super().__init__(*args, **kwargs)
from jina.logging.logger import JinaLogger

self.logger = JinaLogger(self.__class__.__name__)
self.time_sleep = time_sleep

@requests
def process(self, docs: DocumentArray, *args, **kwargs):
time.sleep(1.0)
time.sleep(self.time_sleep)
for doc in docs:
doc.tags['replica_uid'] = os.environ['POD_UID']
doc.tags['time'] = time.time()
Expand Down
45 changes: 45 additions & 0 deletions tests/k8s/test_k8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,3 +1008,48 @@ async def test_flow_with_stateful_executor(

assert len(resp) == 1
assert resp[0].parameters == {'__results__': {'statefulexecutor': {'length': 10.0}}}


@pytest.mark.asyncio
@pytest.mark.parametrize(
'docker_images', [['slow-process-executor', 'jinaai/jina']], indirect=True
)
async def test_slow_executor_readinessProbe_works(docker_images, tmpdir, logger):
dump_path = os.path.join(str(tmpdir), 'test-flow-slow-process-executor')
namespace = f'test-flow-slow-process-executor'.lower()
flow = Flow(name='test-flow-slow-process-executor',).add(
name='slow_process_executor',
uses=f'docker://{docker_images[0]}',
uses_with={'time_sleep': 200},
replicas=3,
)

flow.to_kubernetes_yaml(dump_path, k8s_namespace=namespace)

from kubernetes import client

api_client = client.ApiClient()
core_client = client.CoreV1Api(api_client=api_client)
app_client = client.AppsV1Api(api_client=api_client)
await create_all_flow_deployments_and_wait_ready(
dump_path,
namespace=namespace,
api_client=api_client,
app_client=app_client,
core_client=core_client,
deployment_replicas_expected={
'gateway': 1,
'slow-process-executor': 3,
},
logger=logger
)

resp = await run_test(
flow=flow,
namespace=namespace,
core_client=core_client,
n_docs=10,
request_size=1
)

assert len(resp) == 10

0 comments on commit b82180b

Please sign in to comment.