forked from quic-go/quic-go
fix flaky TestServerCreateConnection (#5039)
This commit is contained in:
@@ -672,10 +672,17 @@ func testServerCreateConnection(t *testing.T, useRetry bool) {
|
|||||||
tokenGeneratorKey: tokenGeneratorKey,
|
tokenGeneratorKey: tokenGeneratorKey,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
done := make(chan struct{}, 3)
|
||||||
c := NewMockQUICConn(mockCtrl)
|
c := NewMockQUICConn(mockCtrl)
|
||||||
c.EXPECT().run()
|
c.EXPECT().run().Do(func() error { done <- struct{}{}; return nil })
|
||||||
c.EXPECT().Context().Return(context.Background())
|
c.EXPECT().Context().DoAndReturn(func() context.Context {
|
||||||
c.EXPECT().HandshakeComplete().Return(make(chan struct{}))
|
done <- struct{}{}
|
||||||
|
return context.Background()
|
||||||
|
})
|
||||||
|
c.EXPECT().HandshakeComplete().DoAndReturn(func() <-chan struct{} {
|
||||||
|
done <- struct{}{}
|
||||||
|
return make(chan struct{})
|
||||||
|
})
|
||||||
recorder := newConnConstructorRecorder(c)
|
recorder := newConnConstructorRecorder(c)
|
||||||
server.newConn = recorder.NewConn
|
server.newConn = recorder.NewConn
|
||||||
|
|
||||||
@@ -725,6 +732,14 @@ func testServerCreateConnection(t *testing.T, useRetry bool) {
|
|||||||
assert.Zero(t, args.retrySrcConnID)
|
assert.Zero(t, args.retrySrcConnID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for range 3 {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
case <-time.After(time.Second):
|
||||||
|
t.Fatal("timeout")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// shutdown
|
// shutdown
|
||||||
c.EXPECT().closeWithTransportError(ConnectionRefused)
|
c.EXPECT().closeWithTransportError(ConnectionRefused)
|
||||||
c.EXPECT().destroy(gomock.Any()).AnyTimes()
|
c.EXPECT().destroy(gomock.Any()).AnyTimes()
|
||||||
|
|||||||
Reference in New Issue
Block a user