pytest-dev / pytest-dev/pytest-xdist
pytest-xdist server side timeout
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.9k
- Forks
- 287
- Avg merge
- 9h 30m
- Merged PRs (30d)
- 2
Description
NOTE: This is not about timeout for test code itself (pytest-timeout works well here), this is about need for timeout in pytest-xdist.
First, let me say big thank you for pytest and pytest-xdist. We use it to run ~400 Docker containers on ~10 servers on AWS. It works wonders!
There are scenarios where pytest-xdist does not detect remote session crash or disconnect and as such will wait for results forever.
Today's xdist code detects session crash via EOF on the SSH session. When network connection is torn down, server marks the worker as dead, and re-adds it. All good.
But... consider a scenario where the SSH is not torn down:
- Run N tests on multiple remote machines with pytest-xdist,
- Tests spawn a python process on remote machine via SSH
- We run in boxed mode, so this process forks to run actual test code
- Process #2 gets killed or crashes
- SSH session stays up because process #3 inherited at least one stdin/out/err from the process #2 (standard SSH behavior).
In this case, the server side xdist thinks the session is up and is waiting for the results for really, really long time ;-)
And yes, #2 does not crash normally. In our case it was oom killed quite persistently. All it takes is 1 oom kill for tens of thousands of tests and entire batch is ruined.
Please let me know if I can provide more info on this issue.
[root@nsth-c10 nsth] #.python --version
Python 2.7.10
[root@nsth-c10 nsth] #.py.test --version
This is pytest version 2.8.0, imported from /usr/local/lib/python2.7/site-packages/pytest-2.8.0-py2.7.egg/pytest.pyc
setuptools registered plugins:
pytest-xdist-1.13.1 at /usr/local/lib/python2.7/site-packages/pytest_xdist-1.13.1-py2.7.egg/xdist/boxed.pyc
pytest-xdist-1.13.1 at /usr/local/lib/python2.7/site-packages/pytest_xdist-1.13.1-py2.7.egg/xdist/looponfail.pyc
pytest-xdist-1.13.1 at /usr/local/lib/python2.7/site-packages/pytest_xdist-1.13.1-py2.7.egg/xdist/plugin.pyc
[root@nsth-c10 nsth] #.
P.S.
Moved from https://github.com/pytest-dev/pytest/issues/1550
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report does not name source files or tests; start by tracing pytest-xdist's server-side worker/session handling, including boxed mode and the SSH connection lifecycle. Reproduce the remote process crash or OOM scenario and define a timeout that detects the still-open but non-producing session without treating ordinary test timeouts as failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, testing
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100