Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable client timeout test #3811

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func TestE2E(t *testing.T) {
// All e2e tests should leave Features empty.
SupportedFeatures: sets.New[features.SupportedFeature](features.SupportGateway),
SkipTests: []string{
tests.ClientTimeoutTest.ShortName, // https://github.com/envoyproxy/gateway/issues/2720
tests.GatewayInfraResourceTest.ShortName, // https://github.com/envoyproxy/gateway/issues/3191
tests.UseClientProtocolTest.ShortName, // https://github.com/envoyproxy/gateway/issues/3473
},
Expand Down
17 changes: 15 additions & 2 deletions test/e2e/testdata/client-timeout.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: BackendTrafficPolicy
metadata:
name: client-timeout
namespace: gateway-conformance-infra
spec:
targetRef:
group: gateway.networking.k8s.io
kind: HTTPRoute
name: http-client-timeout
faultInjection:
delay:
fixedDelay: 100ms
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
name: client-timeout
Expand All @@ -8,10 +22,9 @@ spec:
group: gateway.networking.k8s.io
kind: Gateway
name: same-namespace
namespace: gateway-conformance-infra
timeout:
http:
requestReceivedTimeout: 1ms
requestReceivedTimeout: 50ms
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
Expand Down
18 changes: 3 additions & 15 deletions test/e2e/tests/client_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package tests
import (
"net/http"
"net/url"
"strings"
"testing"
"time"

Expand All @@ -25,14 +24,6 @@ func init() {
ConformanceTests = append(ConformanceTests, ClientTimeoutTest)
}

var largeSizeHeader = func() string {
var b strings.Builder
for i := 0; i < 5000; i++ {
b.WriteString("FakeHeaderValue")
}
return b.String()
}

var ClientTimeoutTest = suite.ConformanceTest{
ShortName: "ClientTimeout",
Description: "Test that the ClientTrafficPolicy API implementation supports client timeout",
Expand All @@ -48,10 +39,6 @@ var ClientTimeoutTest = suite.ConformanceTest{
req := &http.Request{
Method: "GET",
URL: &url.URL{Scheme: "http", Host: gwAddr, Path: "/request-timeout"},
Header: http.Header{
// larger enough to trigger request timeout
"x-large-size-header": []string{largeSizeHeader()},
},
}

client := &http.Client{}
Expand All @@ -66,8 +53,9 @@ var ClientTimeoutTest = suite.ConformanceTest{
}
defer resp.Body.Close()

// return 408 instead of 400 when request timeout.
if http.StatusRequestTimeout == resp.StatusCode {
// return 504 instead of 400 when request timeout.
// https://github.com/envoyproxy/envoy/blob/56021dbfb10b53c6d08ed6fc811e1ff4c9ac41fd/source/common/http/utility.cc#L1409
if http.StatusGatewayTimeout == resp.StatusCode {
return true
} else {
t.Logf("response status code: %d, (after %v) ", resp.StatusCode, elapsed)
Expand Down