From 9b34a2dd8a32837a20539ff96dbefd0068dd4386 Mon Sep 17 00:00:00 2001 From: marun Date: Tue, 6 Aug 2024 14:37:25 -0700 Subject: [PATCH] [tmpnet] Fail node health check if node is not running (#3274) --- tests/fixture/tmpnet/network.go | 2 +- tests/fixture/tmpnet/node_process.go | 7 +++++-- tests/fixture/tmpnet/utils.go | 5 +---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/fixture/tmpnet/network.go b/tests/fixture/tmpnet/network.go index afa59e653c1..695017c0620 100644 --- a/tests/fixture/tmpnet/network.go +++ b/tests/fixture/tmpnet/network.go @@ -865,7 +865,7 @@ func waitForHealthy(ctx context.Context, w io.Writer, nodes []*Node) error { for { for node := range unhealthyNodes { healthy, err := node.IsHealthy(ctx) - if err != nil && !errors.Is(err, ErrNotRunning) { + if err != nil { return err } if !healthy { diff --git a/tests/fixture/tmpnet/node_process.go b/tests/fixture/tmpnet/node_process.go index a866cec63db..8636d2953fd 100644 --- a/tests/fixture/tmpnet/node_process.go +++ b/tests/fixture/tmpnet/node_process.go @@ -31,7 +31,10 @@ const ( defaultNodeInitTimeout = 10 * time.Second ) -var errNodeAlreadyRunning = errors.New("failed to start node: node is already running") +var ( + errNodeAlreadyRunning = errors.New("failed to start node: node is already running") + errNotRunning = errors.New("node is not running") +) func checkNodeHealth(ctx context.Context, uri string) (bool, error) { // Check that the node is reporting healthy @@ -194,7 +197,7 @@ func (p *NodeProcess) IsHealthy(ctx context.Context) (bool, error) { return false, fmt.Errorf("failed to determine process status: %w", err) } if proc == nil { - return false, ErrNotRunning + return false, errNotRunning } return checkNodeHealth(ctx, p.node.URI) diff --git a/tests/fixture/tmpnet/utils.go b/tests/fixture/tmpnet/utils.go index ba32ed3d434..ea320f2a880 100644 --- a/tests/fixture/tmpnet/utils.go +++ b/tests/fixture/tmpnet/utils.go @@ -6,7 +6,6 @@ package tmpnet import ( "context" "encoding/json" - "errors" "fmt" "time" @@ -18,8 +17,6 @@ const ( DefaultNodeTickerInterval = 50 * time.Millisecond ) -var ErrNotRunning = errors.New("not running") - // WaitForHealthy blocks until Node.IsHealthy returns true or an error (including context timeout) is observed. func WaitForHealthy(ctx context.Context, node *Node) error { if _, ok := ctx.Deadline(); !ok { @@ -30,7 +27,7 @@ func WaitForHealthy(ctx context.Context, node *Node) error { for { healthy, err := node.IsHealthy(ctx) - if err != nil && !errors.Is(err, ErrNotRunning) { + if err != nil { return fmt.Errorf("failed to wait for health of node %q: %w", node.NodeID, err) } if healthy {