diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3c0514bbeeef6..4abbbce3d75b6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -135,7 +135,7 @@ jobs: - name: Test id: test run: | - pytest --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml --timeout=600 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }} + pytest --forked --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml --timeout=600 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }} echo "flag it as jina for codeoverage" echo "::set-output name=codecov_flag::jina" timeout-minutes: 30 @@ -350,7 +350,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test docker compose run: | - pytest -v -s --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml ./tests/docker_compose/test_*.py + pytest --forked -v -s --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml ./tests/docker_compose/test_*.py timeout-minutes: 30 - name: Check codecov file id: check_files diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6af6c788d84a5..88211993ede0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -273,7 +273,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test docker compose run: | - pytest -v -s --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml ./tests/docker_compose/test_*.py + pytest --forked -v -s --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml ./tests/docker_compose/test_*.py timeout-minutes: 30 - name: Check codecov file id: check_files @@ -328,7 +328,7 @@ jobs: - name: Test id: test run: | - pytest --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml --timeout=600 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }} + pytest --forked --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml --timeout=600 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }} echo "flag it as jina for codeoverage" echo "::set-output name=codecov_flag::jina" diff --git a/extra-requirements.txt b/extra-requirements.txt index f803a5b3fdbe8..dab5fedb7a924 100644 --- a/extra-requirements.txt +++ b/extra-requirements.txt @@ -87,3 +87,4 @@ jsonschema: cicd portforward>=0.2.4: cicd tensorflow>=2.0: cicd opentelemetry-test-utils>=0.33b0: test +pytest-forked>=1.4.0: test \ No newline at end of file diff --git a/jina/resources/extra-requirements.txt b/jina/resources/extra-requirements.txt index f803a5b3fdbe8..dab5fedb7a924 100644 --- a/jina/resources/extra-requirements.txt +++ b/jina/resources/extra-requirements.txt @@ -87,3 +87,4 @@ jsonschema: cicd portforward>=0.2.4: cicd tensorflow>=2.0: cicd opentelemetry-test-utils>=0.33b0: test +pytest-forked>=1.4.0: test \ No newline at end of file diff --git a/tests/unit/orchestrate/pods/test_pod.py b/tests/unit/orchestrate/pods/test_pod.py index 05591af4be4f1..12cf7b751e27c 100644 --- a/tests/unit/orchestrate/pods/test_pod.py +++ b/tests/unit/orchestrate/pods/test_pod.py @@ -192,28 +192,3 @@ def run_forever(self): pod = Pod(set_pod_parser().parse_args(['--noblock-on-start'])) pod.start() pod.close() - - -@pytest.mark.timeout(4) -def test_close_before_start_slow_enter(monkeypatch): - class SlowFakeRuntime: - def __init__(self, *args, **kwargs): - pass - - def __enter__(self): - time.sleep(5.0) - - def __exit__(self, exc_type, exc_val, exc_tb): - pass - - def run_forever(self): - pass - - monkeypatch.setattr( - runtimes, - 'get_runtime', - lambda *args, **kwargs: SlowFakeRuntime, - ) - pod = Pod(set_pod_parser().parse_args(['--noblock-on-start'])) - pod.start() - pod.close() diff --git a/tests/unit/test_yamlparser.py b/tests/unit/test_yamlparser.py index c2130aa6df8a1..358a19f0d83a2 100644 --- a/tests/unit/test_yamlparser.py +++ b/tests/unit/test_yamlparser.py @@ -113,13 +113,19 @@ def test_expand_env(): assert expand_env_var('$PATH-${AA}') != '$PATH-${AA}' -def test_encoder_name_env_replace(): +@pytest.fixture +def set_test_encoder_env_var(): os.environ['BE_TEST_NAME'] = 'hello123' + yield + del os.environ['BE_TEST_NAME'] + + +def test_encoder_name_env_replace(set_test_encoder_env_var): with BaseExecutor.load_config('yaml/test-encoder-env.yml') as be: assert be.metas.name == 'hello123' -def test_encoder_name_dict_replace(): +def test_encoder_name_dict_replace(set_test_encoder_env_var): d = {'BE_TEST_NAME': 'hello123'} with BaseExecutor.load_config('yaml/test-encoder-env.yml', context=d) as be: assert be.metas.name == 'hello123'