Let tests specify how long parent waits for child process

This commit is contained in:
Seth Schoen 2015-02-04 22:36:24 -08:00
parent ff3c0c6689
commit 41284ffc0a
2 changed files with 5 additions and 4 deletions

View file

@ -310,16 +310,17 @@ class StandaloneAuthenticator(object):
new_ctx.use_privatekey(self.private_key)
connection.set_context(new_ctx)
def do_parent_process(self, port):
def do_parent_process(self, port, delay_amount=5):
"""Perform the parent process side of the TCP listener task. This
should only be called by start_listener()."""
should only be called by start_listener(). We will wait up to
delay_amount seconds to hear from the child process via a signal."""
signal.signal(signal.SIGIO, self.client_signal_handler)
signal.signal(signal.SIGUSR1, self.client_signal_handler)
signal.signal(signal.SIGUSR2, self.client_signal_handler)
display = zope.component.getUtility(interfaces.IDisplay)
start_time = time.time()
while time.time() < start_time + 5:
while time.time() < start_time + delay_amount:
if self.subproc_ready:
return True
if self.subproc_inuse:

View file

@ -329,7 +329,7 @@ class DoParentProcessTest(unittest.TestCase):
@mock.patch("letsencrypt.client.standalone_authenticator.zope.component.getUtility")
def test_do_parent_process_timeout(self, mock_getUtility, mock_signal):
# Times out in 5 seconds and returns False.
result = self.authenticator.do_parent_process(1717)
result = self.authenticator.do_parent_process(1717, delay_amount=1)
self.assertFalse(result)
self.assertEqual(mock_signal.call_count, 3)