Skip to content

Commit 843bd50

Browse files
authored
fix(tests): handle node crash during waiting (#2691)
1 parent 5765e67 commit 843bd50

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tests/utils/node/nodes.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,6 @@ func (nodes Nodes) InitAndStartTest(ctx context.Context, t *testing.T,
116116
t.FailNow()
117117
}
118118

119-
// this is run sequentially since all nodes start almost at the same time
120-
// so waiting for one node will also wait for all the others.
121-
// You can see this since the test logs out that all the nodes are ready
122-
// at the same time.
123-
for _, node := range nodes {
124-
err := waitForNode(ctx, node.RPCPort())
125-
if err == nil {
126-
t.Logf("Node %s is ready", node)
127-
continue
128-
}
129-
130-
t.Errorf("Node %s failed to be ready: %s", node, err)
131-
stopNodes(t, nodesCancel, runtimeErrors)
132-
t.FailNow()
133-
}
134-
135119
// watch for runtime fatal error from any of the nodes
136120
watchDogCtx, watchDogCancel := context.WithCancel(ctx)
137121
watchDogDone := make(chan struct{})
@@ -159,6 +143,22 @@ func (nodes Nodes) InitAndStartTest(ctx context.Context, t *testing.T,
159143
// Stop and wait for nodes to exit
160144
stopNodes(t, nodesCancel, runtimeErrors)
161145
})
146+
147+
// this is run sequentially since all nodes start almost at the same time
148+
// so waiting for one node will also wait for all the others.
149+
// You can see this since the test logs out that all the nodes are ready
150+
// at the same time.
151+
for _, node := range nodes {
152+
err := waitForNode(ctx, node.RPCPort())
153+
if err == nil {
154+
t.Logf("Node %s is ready", node)
155+
continue
156+
}
157+
158+
t.Errorf("Node %s failed to be ready: %s", node, err)
159+
stopNodes(t, nodesCancel, runtimeErrors)
160+
t.FailNow()
161+
}
162162
}
163163

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

0 commit comments

Comments
 (0)