Skip to content

Commit

Permalink
Restrict the individual test execution time
Browse files Browse the repository at this point in the history
Normally, individual tests should not take longer than 1 second, preferably closer to 0 seconds. Some selected tests, however, are slow by their nature (e.g. ngrok or kopf-runner) — so they take around 1-2 seconds. But this limit is only applicable to CI — not to local dev-mode runs, where breakpoints and infinite pauses are needed.

This change should prevent the test-runs from being stuck at one single test if the test is designed improperly or because of the environment issues. This removes the need to keep the timing safeguards inside the tests, which complicates the tests themselves (e.g. with `async-timeout`) — unless such safe-guards are a part of the test design.

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
  • Loading branch information
nolar committed Dec 25, 2021
1 parent 2564558 commit ae3411f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- run: pip install -r requirements.txt
- run: pip install -e .[${{ matrix.install-extras }}]
if: ${{ matrix.install-extras }}
- run: pytest --color=yes --cov=kopf --cov-branch
- run: pytest --color=yes --timeout=2 --cov=kopf --cov-branch

- name: Publish coverage to Coveralls.io
if: success()
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
- run: pip install -r requirements.txt
- run: pip install -e .[${{ matrix.install-extras }}]
if: ${{ matrix.install-extras }}
- run: pytest --color=yes --no-cov
- run: pytest --color=yes --timeout=2 --no-cov

functional:
strategy:
Expand All @@ -114,7 +114,7 @@ jobs:
version: ${{ matrix.k3s }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: pip install -r requirements.txt -r examples/requirements.txt
- run: pytest --color=yes --only-e2e
- run: pytest --color=yes --timeout=10 --only-e2e

coveralls-finish:
name: Finalize coveralls.io
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/thorough.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- run: pip install -r requirements.txt
- run: pip install -e .[${{ matrix.install-extras }}]
if: ${{ matrix.install-extras }}
- run: pytest --color=yes --cov=kopf --cov-branch
- run: pytest --color=yes --timeout=2 --cov=kopf --cov-branch

- name: Publish coverage to Coveralls.io
if: success()
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
- run: pip install -r requirements.txt
- run: pip install -e .[${{ matrix.install-extras }}]
if: ${{ matrix.install-extras }}
- run: pytest --color=yes --no-cov
- run: pytest --color=yes --timeout=2 --no-cov

functional:
strategy:
Expand All @@ -118,7 +118,7 @@ jobs:
version: ${{ matrix.k3s }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: pip install -r requirements.txt -r examples/requirements.txt
- run: pytest --color=yes --only-e2e
- run: pytest --color=yes --timeout=10 --only-e2e

full-scale:
strategy:
Expand All @@ -137,7 +137,7 @@ jobs:
python-version: "3.10"
- run: tools/install-minikube.sh
- run: pip install -r requirements.txt -r examples/requirements.txt
- run: pytest --color=yes --only-e2e
- run: pytest --color=yes --timeout=10 --only-e2e

coveralls-finish:
name: Finalize coveralls.io
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
addopts =
--strict-markers
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ pytest-aiohttp
pytest-asyncio
pytest-cov
pytest-mock
pytest-timeout
types-pkg_resources
types-PyYAML

0 comments on commit ae3411f

Please sign in to comment.