Skip to content
Snippets Groups Projects
Verified Commit cae036ca authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

test: Make the child process wait longer so it gets actually killed

Prior to this, depending on the load on jenkins, the test could be flaky and fail for
the wrong reason [1]

[1] https://jenkins.softwareheritage.org/job/DLDHG/job/tests-on-diff/263/console
parent f3232bfd
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# See the AUTHORS file at the top-level directory of this distribution # See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version # License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information # See top-level LICENSE file for more information
from collections import defaultdict from collections import defaultdict
from dataclasses import dataclass from dataclasses import dataclass
import io import io
...@@ -154,7 +155,7 @@ def clone(src: str, dest: str, timeout: float) -> None: ...@@ -154,7 +155,7 @@ def clone(src: str, dest: str, timeout: float) -> None:
if process.is_alive(): if process.is_alive():
process.terminate() process.terminate()
# Give it a second (literally), then kill it # Give it literally a second (in successive steps of 0.1 second), then kill it.
# Can't use `process.join(1)` here, billiard appears to be bugged # Can't use `process.join(1)` here, billiard appears to be bugged
# https://github.com/celery/billiard/issues/270 # https://github.com/celery/billiard/issues/270
killed = False killed = False
......
...@@ -15,12 +15,14 @@ from .. import hgutil ...@@ -15,12 +15,14 @@ from .. import hgutil
def test_clone_timeout(monkeypatch): def test_clone_timeout(monkeypatch):
src = "https://www.mercurial-scm.org/repo/hello" src = "https://www.mercurial-scm.org/repo/hello"
dest = "/dev/null" dest = "/dev/null"
timeout = 0.1 timeout = 1
sleepy_time = 100 * timeout
assert sleepy_time > timeout
def clone(*args, **kwargs): def clone(*args, **kwargs):
# ignore SIGTERM to force sigkill # ignore SIGTERM to force sigkill
signal.signal(signal.SIGTERM, lambda signum, frame: None) signal.signal(signal.SIGTERM, lambda signum, frame: None)
time.sleep(2) time.sleep(sleepy_time) # we make sure we exceed the timeout
monkeypatch.setattr(hg, "clone", clone) monkeypatch.setattr(hg, "clone", clone)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment