forked from quic-go/quic-go
fix flaky TestGracefulShutdownPendingStreams (#5179)
This commit is contained in:
@@ -267,7 +267,11 @@ func TestGracefulShutdownPendingStreams(t *testing.T) {
|
|||||||
tr := &http3.Transport{
|
tr := &http3.Transport{
|
||||||
TLSClientConfig: getTLSClientConfigWithoutServerName(),
|
TLSClientConfig: getTLSClientConfigWithoutServerName(),
|
||||||
Dial: func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
|
Dial: func(ctx context.Context, addr string, tlsCfg *tls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
|
||||||
conn, err := quic.DialAddrEarly(ctx, addr, tlsCfg, cfg)
|
a, err := net.ResolveUDPAddr("udp", addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
conn, err := quic.DialEarly(ctx, newUDPConnLocalhost(t), a, tlsCfg, cfg)
|
||||||
connChan <- conn
|
connChan <- conn
|
||||||
return conn, err
|
return conn, err
|
||||||
},
|
},
|
||||||
@@ -275,18 +279,15 @@ func TestGracefulShutdownPendingStreams(t *testing.T) {
|
|||||||
cl := &http.Client{Transport: tr}
|
cl := &http.Client{Transport: tr}
|
||||||
|
|
||||||
proxy := quicproxy.Proxy{
|
proxy := quicproxy.Proxy{
|
||||||
Conn: newUDPConnLocalhost(t),
|
Conn: newUDPConnLocalhost(t),
|
||||||
ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port},
|
ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port},
|
||||||
DelayPacket: func(_ quicproxy.Direction, _, _ net.Addr, data []byte) time.Duration {
|
DelayPacket: func(_ quicproxy.Direction, _, _ net.Addr, _ []byte) time.Duration { return rtt },
|
||||||
return rtt
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
require.NoError(t, proxy.Start())
|
require.NoError(t, proxy.Start())
|
||||||
defer proxy.Close()
|
defer proxy.Close()
|
||||||
proxyPort := proxy.LocalAddr().(*net.UDPAddr).Port
|
|
||||||
|
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://localhost:%d/helloworld", proxyPort), nil)
|
req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://%s/helloworld", proxy.LocalAddr()), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
go func() {
|
go func() {
|
||||||
resp, err := cl.Do(req)
|
resp, err := cl.Do(req)
|
||||||
|
|||||||
Reference in New Issue
Block a user