From d97f52d12a9644632ad988f3400ab52544ebc755 Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Sat, 29 Oct 2022 01:01:58 +0800 Subject: [PATCH] lntest: shutdown running nodes when test fails Fixes the zip log files failure we see. --- lntest/harness.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lntest/harness.go b/lntest/harness.go index e72f7abfe..91f2e188f 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -351,6 +351,7 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest { // Don't bother run the cleanups if the test is failed. if st.Failed() { st.Log("test failed, skipped cleanup") + st.shutdownAllNodes() return } @@ -391,10 +392,21 @@ func (h *HarnessTest) Subtest(t *testing.T) *HarnessTest { // shutdownNonStandbyNodes will shutdown any non-standby nodes. func (h *HarnessTest) shutdownNonStandbyNodes() { + h.shutdownNodes(true) +} + +// shutdownAllNodes will shutdown all running nodes. +func (h *HarnessTest) shutdownAllNodes() { + h.shutdownNodes(false) +} + +// shutdownNodes will shutdown any non-standby nodes. If skipStandby is false, +// all the standby nodes will be shutdown too. +func (h *HarnessTest) shutdownNodes(skipStandby bool) { for nid, node := range h.manager.activeNodes { // If it's a standby node, skip. _, ok := h.manager.standbyNodes[nid] - if ok { + if ok && skipStandby { continue }