Mock SysLogHandler for proxy/test_server.py

Our tests get rather grabby with file descriptors, mostly due to the
SysLogHandler. In recent work I'm doing, my additional tests put
things just over the 1024 limit and tests would start to fail
somewhat randomly. This alleviates the problem by mocking out one of
the bigger users of SysLogHandler, proxy/test_server.py. If you want
to verify this has an impact, you can put the following in your
proxy/test_server.py's overall teardown method and try it with and
without the mocking:

    import subprocess
    print >>sys.stderr, '%s OPEN FILES' % len(subprocess.Popen(
        ['lsof'], stdout=subprocess.PIPE).communicate()[0].split('\n'))

Change-Id: I1bd3efe46ee69d09a32c5a964f04e36e46506446
This commit is contained in:
gholt 2013-05-31 00:27:09 +00:00
parent 5501a4031f
commit d2dba73afd
1 changed files with 4 additions and 1 deletions

View File

@ -77,7 +77,9 @@ def request_del(self):
def setup():
utils.HASH_PATH_SUFFIX = 'endcap'
global _testdir, _test_servers, _test_sockets, \
_orig_container_listing_limit, _test_coros
_orig_container_listing_limit, _test_coros, _orig_SysLogHandler
_orig_SysLogHandler = utils.SysLogHandler
utils.SysLogHandler = mock.MagicMock()
Request._orig_init = Request.__init__
Request.__init__ = request_init
Request._orig_del = getattr(Request, '__del__', None)
@ -179,6 +181,7 @@ def teardown():
Request.__init__ = Request._orig_init
if Request._orig_del:
Request.__del__ = Request._orig_del
utils.SysLogHandler = _orig_SysLogHandler
def sortHeaderNames(headerNames):