MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_low_fd_limit

Function test_low_fd_limit

tests/test_misc.py:5012–5037  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

5010
5011
5012def test_low_fd_limit(node_factory, bitcoind):
5013 limits = resource.getrlimit(resource.RLIMIT_NOFILE)
5014
5015 # We assume this, otherwise l2 cannot increase limits!
5016 if limits[0] == limits[1]:
5017 limits = (limits[1] // 2, limits[1])
5018 resource.setrlimit(resource.RLIMIT_NOFILE, limits)
5019
5020 # l1 asks for too much, l2 asks for more than it has, but enough.
5021 l1, l2 = node_factory.line_graph(2, opts=[{'dev-fd-limit-multiplier': limits[1] + 1,
5022 'allow_warning': True},
5023 {'dev-fd-limit-multiplier': limits[1],
5024 'allow_warning': True}])
5025
5026 # fd check is done at start, so restart.
5027 l1.restart()
5028
5029 # Github CI seems to give children a lower fd hard limit that we have (32768 vs 65536?)
5030 # so we don't check the actual numbers here.
5031
5032 # It should warn that FD limit is "low".
5033 assert l1.daemon.is_in_log('UNUSUAL.*WARNING: we have 1 channels but file descriptors limited')
5034
5035 l2.restart()
5036
5037 assert l2.daemon.is_in_log(r'Increasing file descriptor limit')
5038
5039
5040@pytest.mark.parametrize("preapprove", [False, True])

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
restartMethod · 0.80
is_in_logMethod · 0.80

Tested by

no test coverage detected