From d5f5dfa9d3d55953ec98eb9e9d4c377d9c507bed Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 31 May 2025 13:33:57 +0800 Subject: [PATCH] fix flaky TestGracefulShutdownPendingStreams (#5179) --- integrationtests/self/http_shutdown_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/integrationtests/self/http_shutdown_test.go b/integrationtests/self/http_shutdown_test.go index e72c9773..53cbbd8e 100644 --- a/integrationtests/self/http_shutdown_test.go +++ b/integrationtests/self/http_shutdown_test.go @@ -267,7 +267,11 @@ func TestGracefulShutdownPendingStreams(t *testing.T) { tr := &http3.Transport{ TLSClientConfig: getTLSClientConfigWithoutServerName(), 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 return conn, err }, @@ -275,18 +279,15 @@ func TestGracefulShutdownPendingStreams(t *testing.T) { cl := &http.Client{Transport: tr} proxy := quicproxy.Proxy{ - Conn: newUDPConnLocalhost(t), - ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port}, - DelayPacket: func(_ quicproxy.Direction, _, _ net.Addr, data []byte) time.Duration { - return rtt - }, + Conn: newUDPConnLocalhost(t), + ServerAddr: &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: port}, + DelayPacket: func(_ quicproxy.Direction, _, _ net.Addr, _ []byte) time.Duration { return rtt }, } require.NoError(t, proxy.Start()) defer proxy.Close() - proxyPort := proxy.LocalAddr().(*net.UDPAddr).Port 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) go func() { resp, err := cl.Do(req)