Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): handle node crash during waiting #2691

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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