This is an automated email from the ASF dual-hosted git repository.

AlinsRan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 39325e8f test: fix the broken TCPRoute e2e listener port and de-flake 
two stream/ingress specs (#2836)
39325e8f is described below

commit 39325e8f4598c1d45d821fea445e9dff2828c216
Author: AlinsRan <[email protected]>
AuthorDate: Thu Aug 6 14:29:40 2026 +0800

    test: fix the broken TCPRoute e2e listener port and de-flake two 
stream/ingress specs (#2836)
---
 test/e2e/gatewayapi/tcproute.go | 51 ++++-------------------------------------
 test/e2e/gatewayapi/tlsroute.go | 25 ++++++++++++--------
 test/e2e/ingress/ingress.go     | 23 ++++++++++++++-----
 3 files changed, 37 insertions(+), 62 deletions(-)

diff --git a/test/e2e/gatewayapi/tcproute.go b/test/e2e/gatewayapi/tcproute.go
index 6b72b6e0..0ad0a351 100644
--- a/test/e2e/gatewayapi/tcproute.go
+++ b/test/e2e/gatewayapi/tcproute.go
@@ -34,8 +34,9 @@ import (
 
 var _ = Describe("TCPRoute E2E Test", Label("networking.k8s.io", "tcproute"), 
func() {
        s := scaffold.NewDefaultScaffold()
-       Context("TCPRoute Base", func() {
-               var tcpGateway = `
+
+       // Shared by every TCPRoute context so the listener port cannot drift 
between them.
+       var tcpGateway = `
 apiVersion: gateway.networking.k8s.io/v1
 kind: Gateway
 metadata:
@@ -59,6 +60,7 @@ spec:
       name: apisix-proxy-config
 `
 
+       Context("TCPRoute Base", func() {
                var tcpRoute = `
 apiVersion: gateway.networking.k8s.io/v1alpha2
 kind: TCPRoute
@@ -118,27 +120,6 @@ spec:
        })
 
        Context("TCPRoute With BackendTrafficPolicy", func() {
-               var tcpGateway = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: Gateway
-metadata:
-  name: %s
-spec:
-  gatewayClassName: %s
-  listeners:
-  - name: tcp
-    protocol: TCP
-    port: 80
-    allowedRoutes:
-      kinds:
-      - kind: TCPRoute
-  infrastructure:
-    parametersRef:
-      group: apisix.apache.org
-      kind: GatewayProxy
-      name: apisix-proxy-config
-`
-
                var tcpRoute = `
 apiVersion: gateway.networking.k8s.io/v1alpha2
 kind: TCPRoute
@@ -203,30 +184,6 @@ spec:
        })
 
        Context("TCPRoute With L4RoutePolicy", func() {
-               var tcpGateway = `
-apiVersion: gateway.networking.k8s.io/v1
-kind: Gateway
-metadata:
-  name: %s
-spec:
-  gatewayClassName: %s
-  listeners:
-  - name: tcp
-    protocol: TCP
-    # Must equal APISIX's physical stream_proxy TCP port: the e2e controller 
runs
-    # with listener_port_match_mode=auto, so sectionName targeting injects
-    # server_port from this listener; it must match the port connections 
arrive on.
-    port: 9100
-    allowedRoutes:
-      kinds:
-      - kind: TCPRoute
-  infrastructure:
-    parametersRef:
-      group: apisix.apache.org
-      kind: GatewayProxy
-      name: apisix-proxy-config
-`
-
                var tcpRoute = `
 apiVersion: gateway.networking.k8s.io/v1alpha2
 kind: TCPRoute
diff --git a/test/e2e/gatewayapi/tlsroute.go b/test/e2e/gatewayapi/tlsroute.go
index 74fc1b93..f58cfe16 100644
--- a/test/e2e/gatewayapi/tlsroute.go
+++ b/test/e2e/gatewayapi/tlsroute.go
@@ -20,6 +20,7 @@ package gatewayapi
 import (
        "fmt"
        "net/http"
+       "time"
 
        . "github.com/onsi/ginkgo/v2"
        . "github.com/onsi/gomega"
@@ -88,17 +89,22 @@ spec:
                        s.ResourceApplied("TLSRoute", "tls-route", tlsRoute, 1)
 
                        client := s.NewAPISIXClientWithTLSProxy(host)
+                       // TLSRoute is served by the stream subsystem through a 
port-forward
+                       // tunnel, which needs the same headroom as the other 
stream specs
+                       // (tcproute/udproute); the 30s default is too tight on 
a loaded runner.
                        s.RequestAssert(&scaffold.RequestAssert{
-                               Client: client,
-                               Method: http.MethodGet,
-                               Path:   "/ip",
-                               Check:  
scaffold.WithExpectedStatus(http.StatusOK),
+                               Client:  client,
+                               Method:  http.MethodGet,
+                               Path:    "/ip",
+                               Check:   
scaffold.WithExpectedStatus(http.StatusOK),
+                               Timeout: time.Minute * 3,
                        })
                        s.RequestAssert(&scaffold.RequestAssert{
-                               Client: client,
-                               Method: http.MethodGet,
-                               Path:   "/notfound",
-                               Check:  
scaffold.WithExpectedStatus(http.StatusNotFound),
+                               Client:  client,
+                               Method:  http.MethodGet,
+                               Path:    "/notfound",
+                               Check:   
scaffold.WithExpectedStatus(http.StatusNotFound),
+                               Timeout: time.Minute * 3,
                        })
 
                        
Expect(s.DeleteResourceFromString(tlsRoute)).NotTo(HaveOccurred(), "deleting 
TLSRoute")
@@ -111,7 +117,8 @@ spec:
                                        errMsg = reporter.Err().Error()
                                }
                                return errMsg
-                       }).Should(ContainSubstring("EOF"), "should get EOF 
after deleting TLSRoute")
+                       }).WithTimeout(time.Minute*3).
+                               Should(ContainSubstring("EOF"), "should get EOF 
after deleting TLSRoute")
                })
        })
 })
diff --git a/test/e2e/ingress/ingress.go b/test/e2e/ingress/ingress.go
index ef726157..594da5f6 100644
--- a/test/e2e/ingress/ingress.go
+++ b/test/e2e/ingress/ingress.go
@@ -787,9 +787,14 @@ spec:
                        }).
                                WithTimeout(20 * 
time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusNotFound))
 
+                       // The preceding Not Found is also satisfied while the 
route is being
+                       // rebuilt, so this must retry instead of asserting 
once.
                        By("request the route with the correct vars should be 
OK")
-                       s.NewAPISIXClient().GET("/get").WithHost("example.com").
-                               WithHeader("X-HRP-Name", 
"http-route-policy-0").Expect().Status(http.StatusOK)
+                       Eventually(func() int {
+                               return 
s.NewAPISIXClient().GET("/get").WithHost("example.com").
+                                       WithHeader("X-HRP-Name", 
"http-route-policy-0").Expect().Raw().StatusCode
+                       }).
+                               WithTimeout(20 * 
time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK))
 
                        By("update the HTTPRoutePolicy")
                        err = 
s.CreateResourceFromStringWithNamespace(httpRoutePolicySpec1, s.Namespace())
@@ -803,8 +808,11 @@ spec:
                                WithTimeout(20 * 
time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusNotFound))
 
                        By("request with the new vars should be OK")
-                       s.NewAPISIXClient().GET("/get").WithHost("example.com").
-                               WithQuery("hrp_name", 
"http-route-policy-0").Expect().Status(http.StatusOK)
+                       Eventually(func() int {
+                               return 
s.NewAPISIXClient().GET("/get").WithHost("example.com").
+                                       WithQuery("hrp_name", 
"http-route-policy-0").Expect().Raw().StatusCode
+                       }).
+                               WithTimeout(20 * 
time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK))
 
                        By("update the HTTPRoutePolicy's targetRef")
                        err = 
s.CreateResourceFromStringWithNamespace(httpRoutePolicySpec2, s.Namespace())
@@ -827,8 +835,11 @@ spec:
                                WithTimeout(20 * 
time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusNotFound))
 
                        By("request the route with the correct vars should be 
OK")
-                       s.NewAPISIXClient().GET("/get").WithHost("example.com").
-                               WithHeader("X-HRP-Name", 
"http-route-policy-0").Expect().Status(http.StatusOK)
+                       Eventually(func() int {
+                               return 
s.NewAPISIXClient().GET("/get").WithHost("example.com").
+                                       WithHeader("X-HRP-Name", 
"http-route-policy-0").Expect().Raw().StatusCode
+                       }).
+                               WithTimeout(20 * 
time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK))
 
                        By("apply conflict HTTPRoutePolicy")
                        err = 
s.CreateResourceFromStringWithNamespace(httpRoutePolicySpec3, s.Namespace())

Reply via email to