Skip to content

Commit ae068a8

Browse files
authored
fix: harness tests random panic (#10933)
* fix: harness tests random panic Connecting nodes in parallel can cause TLS handshake failures. For each node, connect to the other nodes serially. It is not necessary to connect in parallel as it does not save any significant time. Closes #10932
1 parent dd3f59d commit ae068a8

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

test/cli/harness/nodes.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55

66
. "github.com/ipfs/kubo/test/cli/testutils"
77
"github.com/multiformats/go-multiaddr"
8-
"golang.org/x/sync/errgroup"
98
)
109

1110
// Nodes is a collection of Kubo nodes along with operations on groups of nodes.
@@ -17,37 +16,28 @@ func (n Nodes) Init(args ...string) Nodes {
1716
}
1817

1918
func (n Nodes) ForEachPar(f func(*Node)) {
20-
group := &errgroup.Group{}
19+
var wg sync.WaitGroup
2120
for _, node := range n {
21+
wg.Add(1)
2222
node := node
23-
group.Go(func() error {
23+
go func() {
24+
defer wg.Done()
2425
f(node)
25-
return nil
26-
})
27-
}
28-
err := group.Wait()
29-
if err != nil {
30-
panic(err)
26+
}()
3127
}
28+
wg.Wait()
3229
}
3330

3431
func (n Nodes) Connect() Nodes {
35-
wg := sync.WaitGroup{}
3632
for i, node := range n {
3733
for j, otherNode := range n {
3834
if i == j {
3935
continue
4036
}
41-
node := node
42-
otherNode := otherNode
43-
wg.Add(1)
44-
go func() {
45-
defer wg.Done()
46-
node.Connect(otherNode)
47-
}()
37+
// Do not connect in parallel, because that can cause TLS handshake problems on some platforms.
38+
node.Connect(otherNode)
4839
}
4940
}
50-
wg.Wait()
5141
for _, node := range n {
5242
firstPeer := node.Peers()[0]
5343
if _, err := firstPeer.ValueForProtocol(multiaddr.P_P2P); err != nil {

0 commit comments

Comments
 (0)