mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
pytest: make sure we truncate disconnect file for blackhole processes.
In particular, I found lightning_openingd processes after running tests. When we use the dev_disconnect blackhole '0' option, they stick around until the dev_disconnect file is truncated (there is only so much you can do with only a file descriptor), so let's do that. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
8668b0028e
commit
5135d3ad7d
@@ -291,6 +291,7 @@ class LightningD(TailableProc):
|
|||||||
self.lightning_dir = lightning_dir
|
self.lightning_dir = lightning_dir
|
||||||
self.port = port
|
self.port = port
|
||||||
self.cmd_prefix = []
|
self.cmd_prefix = []
|
||||||
|
self.disconnect_file = None
|
||||||
|
|
||||||
self.opts = LIGHTNINGD_CONFIG.copy()
|
self.opts = LIGHTNINGD_CONFIG.copy()
|
||||||
opts = {
|
opts = {
|
||||||
@@ -329,6 +330,12 @@ class LightningD(TailableProc):
|
|||||||
filter_re = re.compile(r'({})'.format("|".join(filters)))
|
filter_re = re.compile(r'({})'.format("|".join(filters)))
|
||||||
self.log_filter = lambda line: filter_re.search(line) is not None
|
self.log_filter = lambda line: filter_re.search(line) is not None
|
||||||
|
|
||||||
|
def cleanup(self):
|
||||||
|
# To force blackhole to exit, disconnect file must be truncated!
|
||||||
|
if self.disconnect_file:
|
||||||
|
with open(self.disconnect_file, "w") as f:
|
||||||
|
f.truncate()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cmd_line(self):
|
def cmd_line(self):
|
||||||
|
|
||||||
@@ -452,6 +459,7 @@ class LightningNode(object):
|
|||||||
rc = self.daemon.stop()
|
rc = self.daemon.stop()
|
||||||
|
|
||||||
self.daemon.save_log()
|
self.daemon.save_log()
|
||||||
|
self.daemon.cleanup()
|
||||||
|
|
||||||
if rc != 0 and not self.may_fail:
|
if rc != 0 and not self.may_fail:
|
||||||
raise ValueError("Node did not exit cleanly, rc={}".format(rc))
|
raise ValueError("Node did not exit cleanly, rc={}".format(rc))
|
||||||
@@ -677,7 +685,8 @@ class NodeFactory(object):
|
|||||||
)
|
)
|
||||||
# If we have a disconnect string, dump it to a file for daemon.
|
# If we have a disconnect string, dump it to a file for daemon.
|
||||||
if disconnect:
|
if disconnect:
|
||||||
with open(os.path.join(lightning_dir, "dev_disconnect"), "w") as f:
|
daemon.disconnect_file = os.path.join(lightning_dir, "dev_disconnect")
|
||||||
|
with open(daemon.disconnect_file, "w") as f:
|
||||||
f.write("\n".join(disconnect))
|
f.write("\n".join(disconnect))
|
||||||
daemon.opts["dev-disconnect"] = "dev_disconnect"
|
daemon.opts["dev-disconnect"] = "dev_disconnect"
|
||||||
if DEVELOPER:
|
if DEVELOPER:
|
||||||
|
|||||||
Reference in New Issue
Block a user