From ff41da926f39c9740f7b13f9d5962218c9fd2f91 Mon Sep 17 00:00:00 2001 From: zirain Date: Tue, 20 May 2025 11:34:43 +0800 Subject: [PATCH 1/3] e2e: fix TCPRouteBackend flaky Signed-off-by: zirain --- test/e2e/testdata/tcproute-to-backend-ip.yaml | 36 ------------------ ...end-fqdn.yaml => tcproute-to-backend.yaml} | 30 +++++++++++---- test/e2e/tests/tcproute_with_backend.go | 37 ++++++++----------- 3 files changed, 38 insertions(+), 65 deletions(-) delete mode 100644 test/e2e/testdata/tcproute-to-backend-ip.yaml rename test/e2e/testdata/{tcproute-to-backend-fqdn.yaml => tcproute-to-backend.yaml} (57%) diff --git a/test/e2e/testdata/tcproute-to-backend-ip.yaml b/test/e2e/testdata/tcproute-to-backend-ip.yaml deleted file mode 100644 index 5d2764a2f6..0000000000 --- a/test/e2e/testdata/tcproute-to-backend-ip.yaml +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: gateway.networking.k8s.io/v1beta1 -kind: Gateway -metadata: - name: my-tcp-gateway - namespace: gateway-conformance-infra -spec: - gatewayClassName: "{GATEWAY_CLASS_NAME}" - listeners: - - name: foo - protocol: TCP - port: 8080 - allowedRoutes: - kinds: - - kind: TCPRoute - - name: bar - protocol: TCP - port: 8090 - allowedRoutes: - kinds: - - kind: TCPRoute ---- -apiVersion: gateway.networking.k8s.io/v1alpha2 -kind: TCPRoute -metadata: - name: tcp-app-1 - namespace: gateway-conformance-infra -spec: - parentRefs: - - name: my-tcp-gateway - sectionName: foo - rules: - - backendRefs: - - group: gateway.envoyproxy.io - kind: Backend - name: backend-ip - port: 8080 diff --git a/test/e2e/testdata/tcproute-to-backend-fqdn.yaml b/test/e2e/testdata/tcproute-to-backend.yaml similarity index 57% rename from test/e2e/testdata/tcproute-to-backend-fqdn.yaml rename to test/e2e/testdata/tcproute-to-backend.yaml index e61061be20..97139734d1 100644 --- a/test/e2e/testdata/tcproute-to-backend-fqdn.yaml +++ b/test/e2e/testdata/tcproute-to-backend.yaml @@ -1,7 +1,7 @@ apiVersion: gateway.networking.k8s.io/v1beta1 kind: Gateway metadata: - name: my-tcp-gateway + name: tcp-backend-gateway namespace: gateway-conformance-infra spec: gatewayClassName: "{GATEWAY_CLASS_NAME}" @@ -22,19 +22,35 @@ spec: apiVersion: gateway.networking.k8s.io/v1alpha2 kind: TCPRoute metadata: - name: tcp-app-1 + name: tcp-backend-ip namespace: gateway-conformance-infra spec: parentRefs: - - name: my-tcp-gateway + - name: tcp-backend-gateway sectionName: foo rules: - backendRefs: - group: gateway.envoyproxy.io kind: Backend - name: backend-fqdn + name: backend-ip port: 8080 --- +apiVersion: gateway.networking.k8s.io/v1alpha2 +kind: TCPRoute +metadata: + name: tcp-backend-fqdn + namespace: gateway-conformance-infra +spec: + parentRefs: + - name: tcp-backend-gateway + sectionName: bar + rules: + - backendRefs: + - group: gateway.envoyproxy.io + kind: Backend + name: backend-fqdn + port: 8080 +--- apiVersion: gateway.envoyproxy.io/v1alpha1 kind: Backend metadata: @@ -42,6 +58,6 @@ metadata: namespace: gateway-conformance-infra spec: endpoints: - - fqdn: - hostname: infra-backend-v1.gateway-conformance-infra.svc.cluster.local - port: 8080 + - fqdn: + hostname: infra-backend-v1.gateway-conformance-infra.svc.cluster.local + port: 8080 diff --git a/test/e2e/tests/tcproute_with_backend.go b/test/e2e/tests/tcproute_with_backend.go index e78afe26d1..51fddc6e63 100644 --- a/test/e2e/tests/tcproute_with_backend.go +++ b/test/e2e/tests/tcproute_with_backend.go @@ -18,27 +18,20 @@ import ( ) func init() { - ConformanceTests = append(ConformanceTests, TCPRouteBackendFQDNTest) - ConformanceTests = append(ConformanceTests, TCPRouteBackendIPTest) + ConformanceTests = append(ConformanceTests, TCPRouteBackend) } -var TCPRouteBackendFQDNTest = suite.ConformanceTest{ - ShortName: "TCPRouteBackendFQDNTest", - Description: "TCPRoutes with a backend ref to a FQDN Backend", - Manifests: []string{"testdata/tcproute-to-backend-fqdn.yaml"}, - Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - t.Run("tcp-route-1", func(t *testing.T) { - testTCPRouteWithBackend(t, suite, "backend-fqdn") - }) +var TCPRouteBackend = suite.ConformanceTest{ + ShortName: "TCPRouteBackend", + Description: "TCPRoute with a backend ref", + Manifests: []string{ + "testdata/tcproute-to-backend.yaml", }, -} - -var TCPRouteBackendIPTest = suite.ConformanceTest{ - ShortName: "TCPRouteBackendIPTest", - Description: "TCPRoutes with a backend ref to an IP Backend", - Manifests: []string{"testdata/tcproute-to-backend-ip.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { - t.Run("tcp-route-1", func(t *testing.T) { + t.Run("FQDN", func(t *testing.T) { + testTCPRouteWithBackend(t, suite, "tcp-backend-gateway", "tcp-backend-fqdn", "backend-fqdn") + }) + t.Run("IP", func(t *testing.T) { svcNN := types.NamespacedName{ Name: "infra-backend-v1", Namespace: "gateway-conformance-infra", @@ -59,15 +52,15 @@ var TCPRouteBackendIPTest = suite.ConformanceTest{ t.Fatalf("failed to delete backend %s: %v", backendIPName, err) } }) - testTCPRouteWithBackend(t, suite, backendIPName) + testTCPRouteWithBackend(t, suite, "tcp-backend-gateway", "tcp-backend-ip", backendIPName) }) }, } -func testTCPRouteWithBackend(t *testing.T, suite *suite.ConformanceTestSuite, backendName string) { +func testTCPRouteWithBackend(t *testing.T, suite *suite.ConformanceTestSuite, gwName, routeName, backendName string) { ns := "gateway-conformance-infra" - routeNN := types.NamespacedName{Name: "tcp-app-1", Namespace: ns} - gwNN := types.NamespacedName{Name: "my-tcp-gateway", Namespace: ns} + routeNN := types.NamespacedName{Name: routeName, Namespace: ns} + gwNN := types.NamespacedName{Name: gwName, Namespace: ns} gwAddr := GatewayAndTCPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, NewGatewayRef(gwNN), routeNN) BackendMustBeAccepted(t, suite.Client, types.NamespacedName{Name: backendName, Namespace: ns}) OkResp := http.ExpectedResponse{ @@ -80,6 +73,6 @@ func testTCPRouteWithBackend(t *testing.T, suite *suite.ConformanceTestSuite, ba Namespace: ns, } - // Send a request to an valid path and expect a successful response + // Send a request to a valid path and expect a successful response http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp) } From 787a0845ba51db01005c531ea7442d752f6ab086 Mon Sep 17 00:00:00 2001 From: zirain Date: Tue, 20 May 2025 11:46:15 +0800 Subject: [PATCH 2/3] lint Signed-off-by: zirain --- test/e2e/testdata/tcproute-to-backend.yaml | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/e2e/testdata/tcproute-to-backend.yaml b/test/e2e/testdata/tcproute-to-backend.yaml index 97139734d1..0308daeca7 100644 --- a/test/e2e/testdata/tcproute-to-backend.yaml +++ b/test/e2e/testdata/tcproute-to-backend.yaml @@ -6,18 +6,18 @@ metadata: spec: gatewayClassName: "{GATEWAY_CLASS_NAME}" listeners: - - name: foo - protocol: TCP - port: 8080 - allowedRoutes: - kinds: - - kind: TCPRoute - - name: bar - protocol: TCP - port: 8090 - allowedRoutes: - kinds: - - kind: TCPRoute + - name: foo + protocol: TCP + port: 8080 + allowedRoutes: + kinds: + - kind: TCPRoute + - name: bar + protocol: TCP + port: 8090 + allowedRoutes: + kinds: + - kind: TCPRoute --- apiVersion: gateway.networking.k8s.io/v1alpha2 kind: TCPRoute @@ -26,14 +26,14 @@ metadata: namespace: gateway-conformance-infra spec: parentRefs: - - name: tcp-backend-gateway - sectionName: foo + - name: tcp-backend-gateway + sectionName: foo rules: - - backendRefs: - - group: gateway.envoyproxy.io - kind: Backend - name: backend-ip - port: 8080 + - backendRefs: + - group: gateway.envoyproxy.io + kind: Backend + name: backend-ip + port: 8080 --- apiVersion: gateway.networking.k8s.io/v1alpha2 kind: TCPRoute From e65a90486475e685461208848dbb99c37c8d8780 Mon Sep 17 00:00:00 2001 From: zirain Date: Tue, 20 May 2025 11:50:22 +0800 Subject: [PATCH 3/3] update sectionName Signed-off-by: zirain --- test/e2e/testdata/tcproute-to-backend.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/e2e/testdata/tcproute-to-backend.yaml b/test/e2e/testdata/tcproute-to-backend.yaml index 0308daeca7..ff98f2f068 100644 --- a/test/e2e/testdata/tcproute-to-backend.yaml +++ b/test/e2e/testdata/tcproute-to-backend.yaml @@ -6,13 +6,13 @@ metadata: spec: gatewayClassName: "{GATEWAY_CLASS_NAME}" listeners: - - name: foo + - name: ip protocol: TCP port: 8080 allowedRoutes: kinds: - kind: TCPRoute - - name: bar + - name: fqdn protocol: TCP port: 8090 allowedRoutes: @@ -27,7 +27,7 @@ metadata: spec: parentRefs: - name: tcp-backend-gateway - sectionName: foo + sectionName: ip rules: - backendRefs: - group: gateway.envoyproxy.io @@ -43,7 +43,7 @@ metadata: spec: parentRefs: - name: tcp-backend-gateway - sectionName: bar + sectionName: fqdn rules: - backendRefs: - group: gateway.envoyproxy.io