Flaky daemonize test
fmoo opened this issue · 0 comments
fmoo commented
test_daemon.py is failing sporadically on my linux desktop:
===================================================================================================== FAILURES ======================================================================================================
___________________________________________________________________________________________ SimpleTestCase.test_daemonize ___________________________________________________________________________________________
self = <tests.test_daemon.SimpleTestCase testMethod=test_daemonize>
def test_daemonize(self):
if not HAS_DAEMONIZE:
raise Skip("need `daemonize` for this test case")
def daemon_helper():
time.sleep(100)
self.fail()
with NamedTemporaryFile() as tf:
# Fork so daemonizing the current process does not mess up with the
# test suite.
child_pid = os.fork()
if child_pid == 0:
try:
daemon.daemonize(daemon_helper, name='sparts_unittest',
pidfile=tf.name, logger=self.logger)
except SystemExit:
# Catch the daemonize library's attempt to sys.exit()
pass
else:
def checkdaemon():
try:
return daemon.status(tf.name, self.logger)
except ValueError:
return False
# Eliminate the race condition waiting for
# daemonize.Daemonize() to create *and* write the pid to the
# pidfile.
timer.run_until_true(checkdaemon, timeout=1.0)
self.assertTrue(daemon.status(tf.name, self.logger))
> self.assertTrue(daemon.kill(tf.name, self.logger))
tests/test_daemon.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python2.7/tempfile.py:427: in __exit__
self.close()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <closed file '<fdopen>', mode 'w+b' at 0x7f03d84dfed0>
def close(self):
if not self.close_called:
self.close_called = True
self.file.close()
if self.delete:
> self.unlink(self.name)
E OSError: [Errno 2] No such file or directory: '/tmp/tmpRNzIO8'
/usr/lib/python2.7/tempfile.py:418: OSError
----------------------------------------------------------------------------------------------- Captured stderr call ------------------------------------------------------------------------------------------------
DEBUG:TestService:All tasks started
DEBUG:TestService:VService Active. Awaiting graceful shutdown.
============================================================================================== short test summary info ==============================================================================================
FAIL tests/test_daemon.py::SimpleTestCase::test_daemonize
SKIP [1] /home/pete/src/sparts/tests/test_fb303.py:13: Skip: thrift is required to run this test
SKIP [1] /home/pete/src/sparts/tests/thrift/test_compiler.py:12: Skip: Unable to find thrift binary on this system
SKIP [1] /home/pete/src/sparts/tests/thrift/test_client.py:11: Skip: Need thrift language bindings to run this test
SKIP [1] /home/pete/src/sparts/tests/tasks/thrift/test_multiplexed.py:18: Skip: Need thrift language bindings to run this test
SKIP [1] /home/pete/src/sparts/tests/tasks/test_thrift.py:15: Skip: Need thrift language bindings to run this test
============================================================================ 1 failed, 70 passed, 5 skipped, 2 warnings in 4.91 seconds =============================================================================