Skip to content
Open
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
51 changes: 4 additions & 47 deletions test/e2e/gatewayapi/tcproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -59,6 +60,7 @@ spec:
name: apisix-proxy-config
`

Context("TCPRoute Base", func() {
var tcpRoute = `
apiVersion: gateway.networking.k8s.io/v1
kind: TCPRoute
Expand Down Expand Up @@ -114,27 +116,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/v1
kind: TCPRoute
Expand Down Expand Up @@ -199,30 +180,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 so that when
# listener_port_match_mode=auto the injected server_port matches the port
# connections arrive on (see apache/apisix-ingress-controller#2818).
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/v1
kind: TCPRoute
Expand Down
25 changes: 16 additions & 9 deletions test/e2e/gatewayapi/tlsroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package gatewayapi
import (
"fmt"
"net/http"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -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")
Expand All @@ -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")
})
})
})
23 changes: 17 additions & 6 deletions test/e2e/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,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())
Expand All @@ -853,8 +858,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())
Expand All @@ -877,8 +885,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())
Expand Down
Loading