You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by as...@apache.org on 2025/08/26 06:58:44 UTC
(apisix-ingress-controller) branch master updated: chore: migrate e2e tests for httproute basic (#2525)
This is an automated email from the ASF dual-hosted git repository.
ashishtiwari 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 1faf2ae4 chore: migrate e2e tests for httproute basic (#2525)
1faf2ae4 is described below
commit 1faf2ae472ff16b102654a609bb131aa876f5c70
Author: Ashish Tiwari <as...@gmail.com>
AuthorDate: Tue Aug 26 12:28:40 2025 +0530
chore: migrate e2e tests for httproute basic (#2525)
---
test/e2e/gatewayapi/httproute.go | 114 +++++++++++++++++++++++++++++++++++++++
1 file changed, 114 insertions(+)
diff --git a/test/e2e/gatewayapi/httproute.go b/test/e2e/gatewayapi/httproute.go
index 233ea2ae..06ae3c72 100644
--- a/test/e2e/gatewayapi/httproute.go
+++ b/test/e2e/gatewayapi/httproute.go
@@ -37,6 +37,14 @@ import (
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
)
+// helper to apply an HTTPRoute and run a list of request assertions
+func applyHTTPRouteAndAssert(s *scaffold.Scaffold, route string, asserts []scaffold.RequestAssert) {
+ s.ResourceApplied("HTTPRoute", "httpbin", route, 1)
+ for i := range asserts {
+ s.RequestAssert(&asserts[i])
+ }
+}
+
var _ = Describe("Test HTTPRoute", Label("networking.k8s.io", "httproute"), func() {
s := scaffold.NewDefaultScaffold()
@@ -667,6 +675,112 @@ spec:
Interval: time.Second * 2,
})
})
+ It("HTTPRoute with multiple hostnames", func() {
+ route := fmt.Sprintf(`
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: httpbin
+spec:
+ parentRefs:
+ - name: %s
+ hostnames:
+ - httpbin.example
+ - httpbin2.example
+ rules:
+ - matches:
+ - path:
+ type: Exact
+ value: /get
+ backendRefs:
+ - name: httpbin-service-e2e-test
+ port: 80
+`, s.Namespace())
+
+ asserts := []scaffold.RequestAssert{
+ {
+ Method: "GET",
+ Path: "/get",
+ Host: "httpbin.example",
+ Check: scaffold.WithExpectedStatus(http.StatusOK),
+ Timeout: 30 * time.Second,
+ Interval: 2 * time.Second,
+ },
+ {
+ Method: "GET",
+ Path: "/get",
+ Host: "httpbin2.example",
+ Check: scaffold.WithExpectedStatus(http.StatusOK),
+ Timeout: 30 * time.Second,
+ Interval: 2 * time.Second,
+ },
+ {
+ Method: "GET",
+ Path: "/get",
+ Host: "httpbin3.example",
+ Check: scaffold.WithExpectedStatus(http.StatusNotFound),
+ Timeout: 30 * time.Second,
+ Interval: 2 * time.Second,
+ },
+ }
+
+ applyHTTPRouteAndAssert(s, route, asserts)
+ })
+
+ It("HTTPRoute with multiple matches in one rule", func() {
+ route := fmt.Sprintf(`
+apiVersion: gateway.networking.k8s.io/v1
+kind: HTTPRoute
+metadata:
+ name: httpbin
+spec:
+ parentRefs:
+ - name: %s
+ hostnames:
+ - httpbin.example
+ rules:
+ - matches:
+ - path:
+ type: Exact
+ value: /get
+ - path:
+ type: Exact
+ value: /ip
+ backendRefs:
+ - name: httpbin-service-e2e-test
+ port: 80
+`, s.Namespace())
+
+ asserts := []scaffold.RequestAssert{
+ {
+ Method: "GET",
+ Path: "/get",
+ Host: "httpbin.example",
+ Check: scaffold.WithExpectedStatus(http.StatusOK),
+ Timeout: 30 * time.Second,
+ Interval: 2 * time.Second,
+ },
+ {
+ Method: "GET",
+ Path: "/ip",
+ Host: "httpbin.example",
+ Check: scaffold.WithExpectedStatus(http.StatusOK),
+ Timeout: 30 * time.Second,
+ Interval: 2 * time.Second,
+ },
+ {
+ Method: "GET",
+ Path: "/status",
+ Host: "httpbin.example",
+ Check: scaffold.WithExpectedStatus(http.StatusNotFound),
+ Timeout: 30 * time.Second,
+ Interval: 2 * time.Second,
+ },
+ }
+
+ applyHTTPRouteAndAssert(s, route, asserts)
+ })
+
})
Context("HTTPRoute Rule Match", func() {