Merge pull request #5429 from Roasbeef/itest-recovery-shutdown

lntest: retry node shutdown attempts to recovery tests
This commit is contained in:
Olaoluwa Osuntokun 2021-06-24 18:43:39 -07:00 committed by GitHub
commit e62f0e1f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

@ -594,7 +594,13 @@ func assertNumConnections(t *harnessTest, alice, bob *lntest.HarnessNode,
// occur. // occur.
func shutdownAndAssert(net *lntest.NetworkHarness, t *harnessTest, func shutdownAndAssert(net *lntest.NetworkHarness, t *harnessTest,
node *lntest.HarnessNode) { node *lntest.HarnessNode) {
if err := net.ShutdownNode(node); err != nil {
// The process may not be in a state to always shutdown immediately, so
// we'll retry up to a hard limit to ensure we eventually shutdown.
err := wait.NoError(func() error {
return net.ShutdownNode(node)
}, defaultTimeout)
if err != nil {
t.Fatalf("unable to shutdown %v: %v", node.Name(), err) t.Fatalf("unable to shutdown %v: %v", node.Name(), err)
} }
} }

@ -1115,7 +1115,10 @@ func (hn *HarnessNode) stop() error {
// closed before a response is returned. // closed before a response is returned.
req := lnrpc.StopRequest{} req := lnrpc.StopRequest{}
ctx := context.Background() ctx := context.Background()
hn.LightningClient.StopDaemon(ctx, &req) _, err := hn.LightningClient.StopDaemon(ctx, &req)
if err != nil {
return err
}
} }
// Wait for lnd process and other goroutines to exit. // Wait for lnd process and other goroutines to exit.