lntest+itest: kill node and wait its process

Fix a flake found in `testRPCMiddlewareInterceptor` when running in
macOS.
This commit is contained in:
yyforyongyu committed 2024-11-12 23:55:40 +08:00
1 parent 90bca1022b
commit 2905e7b3df
3 files changed
+21 -9

No files matched your search

+3 -2
View File
@@ -841,9 +841,10 @@ func (h *HarnessTest) NewNodeRemoteSigner(name string, extraArgs []string,
return hn
}
// KillNode kills the node (but won't wait for the node process to stop).
// KillNode kills the node and waits for the node process to stop.
func (h *HarnessTest) KillNode(hn *node.HarnessNode) {
require.NoErrorf(h, hn.Kill(), "%s: kill got error", hn.Name())
h.Logf("Manually killing the node %s", hn.Name())
require.NoErrorf(h, hn.KillAndWait(), "%s: kill got error", hn.Name())
delete(h.manager.activeNodes, hn.Cfg.NodeID)
}
+12
View File
@@ -796,6 +796,18 @@ func (hn *HarnessNode) Kill() error {
return hn.cmd.Process.Kill()
}
// KillAndWait kills the lnd process and waits for it to finish.
func (hn *HarnessNode) KillAndWait() error {
err := hn.cmd.Process.Kill()
if err != nil {
return err
}
_, err = hn.cmd.Process.Wait()
return err
}
// printErrf prints an error to the console.
func (hn *HarnessNode) printErrf(format string, a ...interface{}) {
fmt.Printf("itest error from [%s:%s]: %s\n", //nolint:forbidigo