Skip to content

Commit 6cbb82a

Browse files
committed
fix: fix listening flake on TestTailnet_ForcesWebSockets
1 parent aa0dc2d commit 6cbb82a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tailnet/conn_test.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,29 @@ func TestTailnet(t *testing.T) {
131131
stitch(t, w2, w1)
132132
stitch(t, w1, w2)
133133
require.True(t, w2.AwaitReachable(ctx, w1IP))
134-
conn := make(chan struct{}, 1)
134+
done := make(chan struct{})
135+
listening := make(chan struct{})
135136
go func() {
137+
defer close(done)
136138
listener, err := w1.Listen("tcp", ":35565")
137-
assert.NoError(t, err)
139+
if !assert.NoError(t, err) {
140+
return
141+
}
138142
defer listener.Close()
143+
close(listening)
139144
nc, err := listener.Accept()
140145
if !assert.NoError(t, err) {
141146
return
142147
}
143148
_ = nc.Close()
144-
conn <- struct{}{}
149+
145150
}()
146151

152+
testutil.RequireRecvCtx(ctx, t, listening)
147153
nc, err := w2.DialContextTCP(ctx, netip.AddrPortFrom(w1IP, 35565))
148154
require.NoError(t, err)
149155
_ = nc.Close()
150-
<-conn
156+
testutil.RequireRecvCtx(ctx, t, done)
151157

152158
nodes := make(chan *tailnet.Node, 1)
153159
w2.SetNodeCallback(func(node *tailnet.Node) {

0 commit comments

Comments
 (0)