Skip to content

Commit

Permalink
fix(tests): handle node crash during waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jul 22, 2022
1 parent 2311061 commit 9622b53
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/utils/node/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,6 @@ func (nodes Nodes) InitAndStartTest(ctx context.Context, t *testing.T,
t.FailNow()
}

// this is run sequentially since all nodes start almost at the same time
// so waiting for one node will also wait for all the others.
// You can see this since the test logs out that all the nodes are ready
// at the same time.
for _, node := range nodes {
err := waitForNode(ctx, node.RPCPort())
if err == nil {
t.Logf("Node %s is ready", node)
continue
}

t.Errorf("Node %s failed to be ready: %s", node, err)
stopNodes(t, nodesCancel, runtimeErrors)
t.FailNow()
}

// watch for runtime fatal error from any of the nodes
watchDogCtx, watchDogCancel := context.WithCancel(ctx)
watchDogDone := make(chan struct{})
Expand Down Expand Up @@ -159,6 +143,22 @@ func (nodes Nodes) InitAndStartTest(ctx context.Context, t *testing.T,
// Stop and wait for nodes to exit
stopNodes(t, nodesCancel, runtimeErrors)
})

// this is run sequentially since all nodes start almost at the same time
// so waiting for one node will also wait for all the others.
// You can see this since the test logs out that all the nodes are ready
// at the same time.
for _, node := range nodes {
err := waitForNode(ctx, node.RPCPort())
if err == nil {
t.Logf("Node %s is ready", node)
continue
}

t.Errorf("Node %s failed to be ready: %s", node, err)
stopNodes(t, nodesCancel, runtimeErrors)
t.FailNow()
}
}

func stopNodes(t *testing.T, nodesCancel context.CancelFunc,
Expand Down

0 comments on commit 9622b53

Please sign in to comment.