Skip to content

Commit

Permalink
Mock SysLogHandler for proxy/test_server.py
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gholt committed May 31, 2013
1 parent 5501a40 commit d2dba73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/unit/proxy/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit d2dba73

Please sign in to comment.