1313package gatewayapi
1414
1515import (
16- "cmp"
1716 "context"
1817 "fmt"
1918 "net/http"
@@ -104,27 +103,6 @@ spec:
104103 kind: GatewayProxy
105104 name: apisix-proxy-config
106105`
107- var ApplyHTTPRoute = func (nn types.NamespacedName , spec string ) {
108- err := s .CreateResourceFromString (spec )
109- Expect (err ).NotTo (HaveOccurred (), "creating HTTPRoute %s" , nn )
110- framework .HTTPRouteMustHaveCondition (s .GinkgoT , s .K8sClient , 8 * time .Second ,
111- types.NamespacedName {},
112- types.NamespacedName {Namespace : cmp .Or (nn .Namespace , s .Namespace ()), Name : nn .Name },
113- metav1.Condition {
114- Type : string (gatewayv1 .RouteConditionAccepted ),
115- Status : metav1 .ConditionTrue ,
116- },
117- )
118- }
119- var ApplyHTTPRoutePolicy = func (refNN , hrpNN types.NamespacedName , spec string ) {
120- err := s .CreateResourceFromString (spec )
121- Expect (err ).NotTo (HaveOccurred (), "creating HTTPRoutePolicy %s" , hrpNN )
122- framework .HTTPRoutePolicyMustHaveCondition (s .GinkgoT , s .K8sClient , 8 * time .Second , refNN , hrpNN , metav1.Condition {
123- Type : string (v1alpha2 .PolicyConditionAccepted ),
124- Status : metav1 .ConditionTrue ,
125- })
126- }
127-
128106 var beforeEachHTTP = func () {
129107 By ("create GatewayProxy" )
130108 gatewayProxy := fmt .Sprintf (gatewayProxyYaml , framework .DashboardTLSEndpoint , s .AdminKey ())
@@ -226,7 +204,7 @@ spec:
226204
227205 It ("Create/Update/Delete HTTPRoute" , func () {
228206 By ("create HTTPRoute" )
229- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
207+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
230208
231209 By ("access data plane to check the HTTPRoute" )
232210 request := func () int {
@@ -361,7 +339,7 @@ spec:
361339
362340 By ("Create HTTPRoute referencing both gateways" )
363341 multiGatewayRoute := fmt .Sprintf (multiGatewayHTTPRoute , s .Namespace (), additionalNamespace )
364- ApplyHTTPRoute (types.NamespacedName {Name : "multi-gateway-route" }, multiGatewayRoute )
342+ s . ApplyHTTPRoute (types.NamespacedName {Name : "multi-gateway-route" }, multiGatewayRoute )
365343
366344 By ("Access through default gateway" )
367345 Eventually (request ).WithArguments (s .NewAPISIXClient (), "httpbin.example" ).
@@ -504,7 +482,7 @@ spec:
504482
505483 It ("Create/Update/Delete HTTPRoute" , func () {
506484 By ("create HTTPRoute" )
507- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
485+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
508486
509487 request := func (host string ) int {
510488 if host == "" {
@@ -527,7 +505,7 @@ spec:
527505
528506 It ("Delete Gateway after apply HTTPRoute" , func () {
529507 By ("create HTTPRoute" )
530- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
508+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
531509
532510 request := func () int {
533511 return s .NewAPISIXClient ().GET ("/get" ).WithHost ("httpbin.example" ).Expect ().Raw ().StatusCode
@@ -543,7 +521,7 @@ spec:
543521
544522 It ("Proxy External Service" , func () {
545523 By ("create HTTPRoute" )
546- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, httprouteWithExternalName )
524+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, httprouteWithExternalName )
547525
548526 By ("checking the external service response" )
549527 request := func () int {
@@ -554,7 +532,7 @@ spec:
554532
555533 It ("Match Port" , func () {
556534 By ("create HTTPRoute" )
557- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, invalidBackendPort )
535+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, invalidBackendPort )
558536
559537 serviceResources , err := s .DefaultDataplaneResource ().Service ().List (context .Background ())
560538 Expect (err ).NotTo (HaveOccurred (), "listing services" )
@@ -576,7 +554,7 @@ spec:
576554 httpbinNN : exactRouteByGet ,
577555 httpbin2NN : exactRouteByGet2 ,
578556 } {
579- ApplyHTTPRoute (nn , spec )
557+ s . ApplyHTTPRoute (nn , spec )
580558 }
581559
582560 request := func (host string ) int {
@@ -714,7 +692,7 @@ spec:
714692
715693 It ("HTTPRoute Exact Match" , func () {
716694 By ("create HTTPRoute" )
717- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
695+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
718696
719697 request := func (uri string ) int {
720698 return s .NewAPISIXClient ().GET (uri ).WithHost ("httpbin.example" ).Expect ().Raw ().StatusCode
@@ -726,7 +704,7 @@ spec:
726704
727705 It ("HTTPRoute Prefix Match" , func () {
728706 By ("create HTTPRoute" )
729- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, prefixRouteByStatus )
707+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, prefixRouteByStatus )
730708
731709 request := func (uri string ) int {
732710 return s .NewAPISIXClient ().GET (uri ).WithHost ("httpbin.example" ).Expect ().Raw ().StatusCode
@@ -738,7 +716,7 @@ spec:
738716
739717 It ("HTTPRoute Method Match" , func () {
740718 By ("create HTTPRoute" )
741- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, methodRouteGETAndDELETEByAnything )
719+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, methodRouteGETAndDELETEByAnything )
742720
743721 request := func (method string ) int {
744722 return s .NewAPISIXClient ().Request (method , "/anything" ).WithHost ("httpbin.example" ).Expect ().Raw ().StatusCode
@@ -751,7 +729,7 @@ spec:
751729
752730 It ("HTTPRoute Vars Match" , func () {
753731 By ("create HTTPRoute" )
754- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
732+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
755733
756734 request := func (headers map [string ]string ) int {
757735 cli := s .NewAPISIXClient ().GET ("/get" ).WithHost ("httpbin.example" )
@@ -769,7 +747,7 @@ spec:
769747
770748 It ("HTTPRoutePolicy in effect" , func () {
771749 By ("create HTTPRoute" )
772- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
750+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
773751 request := func () int {
774752 return s .NewAPISIXClient ().GET ("/get" ).
775753 WithHost ("httpbin.example" ).WithHeader ("X-Route-Name" , "httpbin" ).
@@ -778,7 +756,7 @@ spec:
778756 Eventually (request ).WithTimeout (5 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
779757
780758 By ("create HTTPRoutePolicy" )
781- ApplyHTTPRoutePolicy (
759+ s . ApplyHTTPRoutePolicy (
782760 types.NamespacedName {Name : "apisix" },
783761 types.NamespacedName {Namespace : s .Namespace (), Name : "http-route-policy-0" },
784762 httpRoutePolicy ,
@@ -814,7 +792,7 @@ spec:
814792 - ==
815793 - new-hrp-name
816794`
817- ApplyHTTPRoutePolicy (
795+ s . ApplyHTTPRoutePolicy (
818796 types.NamespacedName {Name : "apisix" },
819797 types.NamespacedName {Namespace : s .Namespace (), Name : "http-route-policy-0" },
820798 changedHTTPRoutePolicy ,
@@ -931,15 +909,15 @@ spec:
931909 - http-route-policy-0
932910`
933911 By ("create HTTPRoute" )
934- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
912+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
935913
936914 By ("create HTTPRoutePolices" )
937915 for name , spec := range map [string ]string {
938916 "http-route-policy-0" : httpRoutePolicy0 ,
939917 "http-route-policy-1" : httpRoutePolicy1 ,
940918 "http-route-policy-2" : httpRoutePolicy2 ,
941919 } {
942- ApplyHTTPRoutePolicy (
920+ s . ApplyHTTPRoutePolicy (
943921 types.NamespacedName {Namespace : s .Namespace (), Name : "apisix" },
944922 types.NamespacedName {Namespace : s .Namespace (), Name : name },
945923 spec ,
@@ -989,7 +967,7 @@ spec:
989967 }).WithTimeout (8 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusNotFound ))
990968
991969 By ("update HTTPRoutePolicy" )
992- ApplyHTTPRoutePolicy (
970+ s . ApplyHTTPRoutePolicy (
993971 types.NamespacedName {Namespace : s .Namespace (), Name : "apisix" },
994972 types.NamespacedName {Namespace : s .Namespace (), Name : "http-route-policy-1" },
995973 httpRoutePolicy1Priority20 ,
@@ -1016,10 +994,10 @@ spec:
1016994
1017995 It ("HTTPRoutePolicy status changes on HTTPRoute deleting" , func () {
1018996 By ("create HTTPRoute" )
1019- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
997+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, varsRoute )
1020998
1021999 By ("create HTTPRoutePolicy" )
1022- ApplyHTTPRoutePolicy (
1000+ s . ApplyHTTPRoutePolicy (
10231001 types.NamespacedName {Name : "apisix" },
10241002 types.NamespacedName {Namespace : s .Namespace (), Name : "http-route-policy-0" },
10251003 httpRoutePolicy ,
@@ -1281,7 +1259,7 @@ spec:
12811259
12821260 It ("HTTPRoute RequestHeaderModifier" , func () {
12831261 By ("create HTTPRoute" )
1284- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, reqHeaderModifyByHeaders )
1262+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, reqHeaderModifyByHeaders )
12851263
12861264 By ("access dataplane to check the HTTPRoute" )
12871265 respExp := s .NewAPISIXClient ().
@@ -1302,7 +1280,7 @@ spec:
13021280
13031281 It ("HTTPRoute ResponseHeaderModifier" , func () {
13041282 By ("create HTTPRoute" )
1305- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, respHeaderModifyByHeaders )
1283+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, respHeaderModifyByHeaders )
13061284
13071285 By ("access dataplane to check the HTTPRoute" )
13081286 respExp := s .NewAPISIXClient ().
@@ -1322,7 +1300,7 @@ spec:
13221300
13231301 It ("HTTPRoute RequestRedirect" , func () {
13241302 By ("create HTTPRoute" )
1325- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, httpsRedirectByHeaders )
1303+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, httpsRedirectByHeaders )
13261304
13271305 s .NewAPISIXClient ().GET ("/headers" ).
13281306 WithHeader ("Host" , "httpbin.example" ).
@@ -1331,7 +1309,7 @@ spec:
13311309 Header ("Location" ).IsEqual ("https://httpbin.example:9443/headers" )
13321310
13331311 By ("update HTTPRoute" )
1334- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, hostnameRedirectByHeaders )
1312+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, hostnameRedirectByHeaders )
13351313
13361314 s .NewAPISIXClient ().GET ("/headers" ).
13371315 WithHeader ("Host" , "httpbin.example" ).
@@ -1399,7 +1377,7 @@ spec:
13991377 - name: httpbin-service-e2e-test
14001378 port: 80
14011379`
1402- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, echoRoute )
1380+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, echoRoute )
14031381 Eventually (func () int {
14041382 return s .NewAPISIXClient ().GET ("/headers" ).
14051383 WithHeader ("Host" , "httpbin.example" ).
@@ -1412,7 +1390,7 @@ spec:
14121390
14131391 It ("HTTPRoute URLRewrite with ReplaceFullPath And Hostname" , func () {
14141392 By ("create HTTPRoute" )
1415- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, replaceFullPathAndHost )
1393+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, replaceFullPathAndHost )
14161394
14171395 By ("/replace/201 should be rewritten to /headers" )
14181396 s .NewAPISIXClient ().GET ("/replace/201" ).
@@ -1433,7 +1411,7 @@ spec:
14331411
14341412 It ("HTTPRoute URLRewrite with ReplacePrefixMatch" , func () {
14351413 By ("create HTTPRoute" )
1436- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, replacePrefixMatch )
1414+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, replacePrefixMatch )
14371415
14381416 By ("/replace/201 should be rewritten to /status/201" )
14391417 s .NewAPISIXClient ().GET ("/replace/201" ).
@@ -1452,7 +1430,7 @@ spec:
14521430 By ("create HTTPRoute" )
14531431 err := s .CreateResourceFromString (echoPlugin )
14541432 Expect (err ).NotTo (HaveOccurred (), "creating PluginConfig" )
1455- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, extensionRefEchoPlugin )
1433+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, extensionRefEchoPlugin )
14561434
14571435 s .NewAPISIXClient ().GET ("/get" ).
14581436 WithHeader ("Host" , "httpbin.example" ).
@@ -1527,7 +1505,7 @@ spec:
15271505 })
15281506 })
15291507 It ("HTTPRoute Canary" , func () {
1530- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, sameWeight )
1508+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, sameWeight )
15311509
15321510 var (
15331511 hitNginxCnt = 0
@@ -1548,7 +1526,7 @@ spec:
15481526 }
15491527 Expect (hitNginxCnt - hitHttpbinCnt ).To (BeNumerically ("~" , 0 , 2 ))
15501528
1551- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, oneWeight )
1529+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, oneWeight )
15521530
15531531 hitNginxCnt = 0
15541532 hitHttpbinCnt = 0
@@ -1613,7 +1591,7 @@ spec:
16131591
16141592 It ("Should sync HTTPRoute when GatewayProxy is updated" , func () {
16151593 By ("create HTTPRoute" )
1616- ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
1594+ s . ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, exactRouteByGet )
16171595
16181596 By ("verify HTTPRoute works" )
16191597 s .NewAPISIXClient ().
0 commit comments