Skip to content

Commit acee110

Browse files
committed
e2e
1 parent 890787b commit acee110

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

internal/provider/adc/translator/httproute.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"go.uber.org/zap"
1010
discoveryv1 "k8s.io/api/discovery/v1"
1111
"k8s.io/apimachinery/pkg/types"
12+
"k8s.io/utils/ptr"
1213
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
1314

1415
"github.com/api7/api7-ingress-controller/api/common"
@@ -352,6 +353,7 @@ func (t *Translator) TranslateHTTPRoute(tctx *provider.TranslateContext, httpRou
352353
route.Name = name
353354
route.ID = id.GenID(name)
354355
route.Labels = labels
356+
route.EnableWebsocket = ptr.To(true)
355357
routes = append(routes, route)
356358
}
357359
t.fillHTTPRoutePolicies(tctx, rule, routes)

test/e2e/gatewayapi/httproute.go

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ spec:
262262
- path:
263263
type: Exact
264264
value: /get
265+
name: get
265266
backendRefs:
266267
- name: httpbin-service-e2e-test
267268
port: 80
@@ -288,6 +289,30 @@ spec:
288289
backendRefs:
289290
- name: httpbin-service-e2e-test
290291
port: 80
292+
`
293+
var httpRoutePolicy = `
294+
apiVersion: gateway.networking.k8s.io/v1
295+
kind: HTTPRoutePolicy
296+
metadata:
297+
name: httpRoutePolicy0
298+
spec:
299+
targetRefs:
300+
- group: gateway.apisix.io
301+
kind: HTTPRoute
302+
name: httpbin
303+
sectionName: get
304+
- group: gateway.apisix.io
305+
kind: HTTPRoute
306+
name: httpbin
307+
sectionName: put
308+
- group: gateway.apisix.io
309+
kind: HTTPRoute
310+
name: httpbin-1
311+
sectionName: get
312+
priority: 10
313+
vars:
314+
- ["http_x_hrp_name", "==", "httpRoutePolicy0"]
315+
- ["arg_hrp_name", "==", "httpRoutePolicy0"]
291316
`
292317

293318
var prefixRouteByStatus = `
@@ -396,7 +421,7 @@ spec:
396421
Status(404)
397422
})
398423

399-
It("HTTPRoute Vars Match", func() {
424+
FIt("HTTPRoute Vars Match", func() {
400425
By("create HTTPRoute")
401426
ResourceApplied("HTTPRoute", "httpbin", varsRoute, 1)
402427

@@ -413,6 +438,26 @@ spec:
413438
WithHeader("X-Route-Name", "httpbin").
414439
Expect().
415440
Status(http.StatusOK)
441+
442+
By("create HTTPRoutePolicy")
443+
ResourceApplied("HTTPRoutePolicy", "httpRoutePolicy0", httpRoutePolicy, 1)
444+
445+
By("access dataplane to check the HTTPRoutePolicy")
446+
s.NewAPISIXClient().
447+
GET("/get").
448+
WithHost("httpbin.example").
449+
WithHeader("X-Route-Name", "httpbin").
450+
Expect().
451+
Status(http.StatusNotFound)
452+
453+
s.NewAPISIXClient().
454+
GET("/get").
455+
WithHost("httpbin.example").
456+
WithHeader("X-Route-Name", "httpbin").
457+
WithHeader("X-HRP-Name", "httpRoutePolicy0").
458+
WithQuery("hrp_name", "httpRoutePolicy0").
459+
Expect().
460+
Status(http.StatusOK)
416461
})
417462
})
418463

0 commit comments

Comments
 (0)