Skip to content

Commit

Permalink
[tmpnet] Fail node health check if node is not running (#3274)
Browse files Browse the repository at this point in the history
  • Loading branch information
marun authored Aug 6, 2024
1 parent 479145a commit 9b34a2d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions tests/fixture/tmpnet/node_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions tests/fixture/tmpnet/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package tmpnet
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 9b34a2d

Please sign in to comment.