Skip to content

Commit 62e5b60

Browse files
committed
TEST: add multiple listeners per gateway match with one parentRef from HTTPRoute
1 parent 929b0a5 commit 62e5b60

File tree

7 files changed

+165
-0
lines changed

7 files changed

+165
-0
lines changed

test/integration/httproute/httproute_basic_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,40 @@ func (s *HTTPRouteTestSuite) Test_HTTPRoute_KO_ResolvedRefs() {
176176
s.expectAttachedRoute(s.Test().Ctx, s.Test().Namespace, "gateway", "http", 1)
177177
s.expectAttachedRoute(s.Test().Ctx, s.Test().Namespace, "gateway", "http2", 1)
178178
}
179+
180+
func (s *HTTPRouteTestSuite) Test_HTTPRoute_OK_Multiple_Listeners_One_Gateway() {
181+
fixtureDirPath := utils.GetCRDFixturePath()
182+
fixtureDir := "basic"
183+
184+
fixturePath := path.Join(fixtureDirPath, fixtureDir, "ok _multiple_listeners_one_gateway")
185+
s.CreateFixtures(fixturePath, nil)
186+
defer s.CleanupFixtures(fixturePath, nil)
187+
188+
// Expected Conditions
189+
expectationsPath := path.Join(fixturePath, "expectations")
190+
expectedCondPath := path.Join(expectationsPath, "conditions.yaml")
191+
expectedConditions := s.YamlToRouteConditions(expectedCondPath)
192+
193+
httpRouteName := "route-echo"
194+
s.expectConditionsUpdated(s.Test().Ctx, s.Test().Namespace, httpRouteName, expectedConditions)
195+
196+
// Check AttachedRoutes on Gateway status
197+
s.expectAttachedRoute(s.Test().Ctx, s.Test().Namespace, "gateway", "http", 1)
198+
s.expectAttachedRoute(s.Test().Ctx, s.Test().Namespace, "gateway", "http2", 1)
199+
200+
// haproxy.cfg Backends
201+
backendsExpectationsPath := path.Join(expectationsPath, "backends")
202+
expectedBackends := []string{"link1_e2e-tests-httproute_http-echo_80__"}
203+
s.ExpectBackends(s.Test().Ctx, backendsExpectationsPath, expectedBackends)
204+
205+
httpPathPrefixMapFile := "link1_" + s.Test().Namespace + "_gateway_http/path_prefix.map"
206+
if !s.CheckEntryInMapFile(httpPathPrefixMapFile,
207+
"example.haproxy/path1", "link1_e2e-tests-httproute_http-echo_80__") {
208+
s.T().Fatalf("Map file %s , missing entry : %s->%s", httpPathPrefixMapFile, "example.haproxy/path1", "link1_e2e-tests-httproute_http-echo_80__")
209+
}
210+
httpPathPrefixMapFile = "link1_" + s.Test().Namespace + "_gateway_http2/path_prefix.map"
211+
if !s.CheckEntryInMapFile(httpPathPrefixMapFile,
212+
"example.haproxy/path1", "link1_e2e-tests-httproute_http-echo_80__") {
213+
s.T().Fatalf("Map file %s , missing entry : %s->%s", httpPathPrefixMapFile, "example.haproxy/path1", "link1_e2e-tests-httproute_http-echo_80__")
214+
}
215+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"from": "haproxytech",
3+
"metadata": {
4+
"hug": {
5+
"HTTPRoute": {
6+
"e2e-tests-httproute/route-echo": {
7+
"Generation": 1,
8+
"LinkID": "link1"
9+
}
10+
}
11+
}
12+
},
13+
"mode": "http",
14+
"name": "link1_e2e-tests-httproute_http-echo_80__",
15+
"abortonclose": "disabled",
16+
"balance": {
17+
"algorithm": "roundrobin"
18+
},
19+
"default_server": {
20+
"check": "enabled"
21+
},
22+
"forwardfor": {
23+
"enabled": "enabled"
24+
},
25+
"server_timeout": 50000
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
parents:
2+
- conditions:
3+
- message: Route Accepted
4+
reason: Accepted
5+
status: "True"
6+
type: Accepted
7+
- message: References resolved
8+
reason: ResolvedRefs
9+
status: "True"
10+
type: ResolvedRefs
11+
controllerName: gate.haproxy.org/hug
12+
parentRef:
13+
group: gateway.networking.k8s.io
14+
kind: Gateway
15+
name: gateway
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: Gateway
3+
metadata:
4+
name: gateway
5+
spec:
6+
gatewayClassName: haproxy
7+
listeners:
8+
- name: http
9+
port: 8080
10+
protocol: HTTP
11+
allowedRoutes:
12+
kinds:
13+
- group: gateway.networking.k8s.io
14+
kind: HTTPRoute
15+
hostname: "*.haproxy"
16+
- name: http2
17+
protocol: HTTP
18+
port: 8088
19+
allowedRoutes:
20+
kinds:
21+
- group: gateway.networking.k8s.io
22+
kind: HTTPRoute
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: GatewayClass
3+
metadata:
4+
name: haproxy
5+
spec:
6+
controllerName: gate.haproxy.org/hug
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
kind: Deployment
2+
apiVersion: apps/v1
3+
metadata:
4+
name: http-echo
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: http-echo
10+
template:
11+
metadata:
12+
labels:
13+
app: http-echo
14+
spec:
15+
containers:
16+
- name: http-echo
17+
image: "haproxytech/http-echo:latest"
18+
imagePullPolicy: Never
19+
ports:
20+
- name: http
21+
containerPort: 8888
22+
protocol: TCP
23+
- name: https
24+
containerPort: 8443
25+
protocol: TCP
26+
---
27+
kind: Service
28+
apiVersion: v1
29+
metadata:
30+
name: http-echo
31+
spec:
32+
ports:
33+
- name: http
34+
protocol: TCP
35+
port: 80
36+
targetPort: http
37+
- name: https
38+
protocol: TCP
39+
port: 443
40+
targetPort: https
41+
selector:
42+
app: http-echo
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: gateway.networking.k8s.io/v1
2+
kind: HTTPRoute
3+
metadata:
4+
name: route-echo
5+
spec:
6+
parentRefs:
7+
- name: gateway
8+
hostnames:
9+
- "example.haproxy"
10+
rules:
11+
- matches:
12+
- path:
13+
type: PathPrefix
14+
value: /path1
15+
backendRefs:
16+
- name: http-echo
17+
port: 80

0 commit comments

Comments
 (0)