Skip to content

Commit

Permalink
Timeout functional tests
Browse files Browse the repository at this point in the history
If the functional tests don't exist after five seconds of waiting on
them, they should be killed. This also uses pytest-timeout to impose a
maximum runtime of 30secs on any test in the test suite.

Hopefully this should prevent tests from hanging.
  • Loading branch information
kgaughan committed Oct 28, 2024
1 parent fdd2ecf commit 79ce1df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
- Anticipate multivalue and single-value-only headers in request headers in
parser.py.

- Timeout functests.

- Complex pipelining functests (with intermediate connection: close).

- Killthreads support.
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ where=src
[options.extras_require]
testing =
pytest
pytest-timeout
pytest-cov
coverage>=5.0

Expand All @@ -61,6 +62,7 @@ docs =
pylons-sphinx-themes>=1.0.9

[tool:pytest]
timeout = 30
python_files = test_*.py
# For the benefit of test_wasyncore.py
python_classes = Test*
Expand Down
5 changes: 3 additions & 2 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def stop_subprocess(self):
self.proc.terminate()
self.sock.close()
# This give us one FD back ...
self.proc.join()
self.proc.join(timeout=5)
self.proc.close()
self.queue.close()
self.queue.join_thread()
Expand Down Expand Up @@ -163,9 +163,10 @@ def test_it(self):
time.sleep(3)

for proc in procs:
proc.poll()
if proc.returncode is not None: # pragma: no cover
proc.terminate()
proc.wait()
proc.wait(timeout=5)
# the notsleepy response should always be first returned (it sleeps
# for 2 seconds, then returns; the notsleepy response should be
# processed in the meantime)
Expand Down

0 comments on commit 79ce1df

Please sign in to comment.