1
0
Fork 0

Merge branch v2.11 into v3.4

This commit is contained in:
romain 2025-06-02 11:38:16 +02:00
commit bd4bfd8919
110 changed files with 493 additions and 494 deletions

View file

@ -80,7 +80,7 @@ func testShutdown(t *testing.T, router *tcprouter.Router) {
epConfig.RespondingTimeouts.ReadTimeout = ptypes.Duration(5 * time.Second)
epConfig.RespondingTimeouts.WriteTimeout = ptypes.Duration(5 * time.Second)
entryPoint, err := NewTCPEntryPoint(context.Background(), "", &static.EntryPoint{
entryPoint, err := NewTCPEntryPoint(t.Context(), "", &static.EntryPoint{
// We explicitly use an IPV4 address because on Alpine, with an IPV6 address
// there seems to be shenanigans related to properly cleaning up file descriptors
Address: "127.0.0.1:0",
@ -90,7 +90,7 @@ func testShutdown(t *testing.T, router *tcprouter.Router) {
}, nil, nil)
require.NoError(t, err)
conn, err := startEntrypoint(entryPoint, router)
conn, err := startEntrypoint(t, entryPoint, router)
require.NoError(t, err)
t.Cleanup(func() { _ = conn.Close() })
@ -113,7 +113,7 @@ func testShutdown(t *testing.T, router *tcprouter.Router) {
_, err = reader.Peek(1)
require.NoError(t, err)
go entryPoint.Shutdown(context.Background())
go entryPoint.Shutdown(t.Context())
// Make sure that new connections are not permitted anymore.
// Note that this should be true not only after Shutdown has returned,
@ -144,8 +144,10 @@ func testShutdown(t *testing.T, router *tcprouter.Router) {
assert.Equal(t, http.StatusOK, resp.StatusCode)
}
func startEntrypoint(entryPoint *TCPEntryPoint, router *tcprouter.Router) (net.Conn, error) {
go entryPoint.Start(context.Background())
func startEntrypoint(t *testing.T, entryPoint *TCPEntryPoint, router *tcprouter.Router) (net.Conn, error) {
t.Helper()
go entryPoint.Start(t.Context())
entryPoint.SwitchRouter(router)
@ -167,7 +169,7 @@ func TestReadTimeoutWithoutFirstByte(t *testing.T) {
epConfig.SetDefaults()
epConfig.RespondingTimeouts.ReadTimeout = ptypes.Duration(2 * time.Second)
entryPoint, err := NewTCPEntryPoint(context.Background(), "", &static.EntryPoint{
entryPoint, err := NewTCPEntryPoint(t.Context(), "", &static.EntryPoint{
Address: ":0",
Transport: epConfig,
ForwardedHeaders: &static.ForwardedHeaders{},
@ -182,7 +184,7 @@ func TestReadTimeoutWithoutFirstByte(t *testing.T) {
rw.WriteHeader(http.StatusOK)
}))
conn, err := startEntrypoint(entryPoint, router)
conn, err := startEntrypoint(t, entryPoint, router)
require.NoError(t, err)
errChan := make(chan error)
@ -206,7 +208,7 @@ func TestReadTimeoutWithFirstByte(t *testing.T) {
epConfig.SetDefaults()
epConfig.RespondingTimeouts.ReadTimeout = ptypes.Duration(2 * time.Second)
entryPoint, err := NewTCPEntryPoint(context.Background(), "", &static.EntryPoint{
entryPoint, err := NewTCPEntryPoint(t.Context(), "", &static.EntryPoint{
Address: ":0",
Transport: epConfig,
ForwardedHeaders: &static.ForwardedHeaders{},
@ -221,7 +223,7 @@ func TestReadTimeoutWithFirstByte(t *testing.T) {
rw.WriteHeader(http.StatusOK)
}))
conn, err := startEntrypoint(entryPoint, router)
conn, err := startEntrypoint(t, entryPoint, router)
require.NoError(t, err)
_, err = conn.Write([]byte("GET /some HTTP/1.1\r\n"))
@ -248,7 +250,7 @@ func TestKeepAliveMaxRequests(t *testing.T) {
epConfig.SetDefaults()
epConfig.KeepAliveMaxRequests = 3
entryPoint, err := NewTCPEntryPoint(context.Background(), "", &static.EntryPoint{
entryPoint, err := NewTCPEntryPoint(t.Context(), "", &static.EntryPoint{
Address: ":0",
Transport: epConfig,
ForwardedHeaders: &static.ForwardedHeaders{},
@ -263,7 +265,7 @@ func TestKeepAliveMaxRequests(t *testing.T) {
rw.WriteHeader(http.StatusOK)
}))
conn, err := startEntrypoint(entryPoint, router)
conn, err := startEntrypoint(t, entryPoint, router)
require.NoError(t, err)
http.DefaultClient.Transport = &http.Transport{
@ -296,7 +298,7 @@ func TestKeepAliveMaxTime(t *testing.T) {
epConfig.SetDefaults()
epConfig.KeepAliveMaxTime = ptypes.Duration(time.Millisecond)
entryPoint, err := NewTCPEntryPoint(context.Background(), "", &static.EntryPoint{
entryPoint, err := NewTCPEntryPoint(t.Context(), "", &static.EntryPoint{
Address: ":0",
Transport: epConfig,
ForwardedHeaders: &static.ForwardedHeaders{},
@ -311,7 +313,7 @@ func TestKeepAliveMaxTime(t *testing.T) {
rw.WriteHeader(http.StatusOK)
}))
conn, err := startEntrypoint(entryPoint, router)
conn, err := startEntrypoint(t, entryPoint, router)
require.NoError(t, err)
http.DefaultClient.Transport = &http.Transport{
@ -340,7 +342,7 @@ func TestKeepAliveH2c(t *testing.T) {
epConfig.SetDefaults()
epConfig.KeepAliveMaxRequests = 1
entryPoint, err := NewTCPEntryPoint(context.Background(), "", &static.EntryPoint{
entryPoint, err := NewTCPEntryPoint(t.Context(), "", &static.EntryPoint{
Address: ":0",
Transport: epConfig,
ForwardedHeaders: &static.ForwardedHeaders{},
@ -355,7 +357,7 @@ func TestKeepAliveH2c(t *testing.T) {
rw.WriteHeader(http.StatusOK)
}))
conn, err := startEntrypoint(entryPoint, router)
conn, err := startEntrypoint(t, entryPoint, router)
require.NoError(t, err)
http2Transport := &http2.Transport{
@ -524,7 +526,7 @@ func TestPathOperations(t *testing.T) {
configuration.SetDefaults()
// Create the HTTP server using createHTTPServer.
server, err := createHTTPServer(context.Background(), ln, configuration, false, requestdecorator.New(nil))
server, err := createHTTPServer(t.Context(), ln, configuration, false, requestdecorator.New(nil))
require.NoError(t, err)
server.Switcher.UpdateHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {