@@ -103,26 +103,6 @@ spec:
103103 kind: GatewayProxy
104104 name: apisix-proxy-config
105105`
106-
107- var ResourceApplied = func (resourType , resourceName , resourceRaw string , observedGeneration int ) {
108- Expect (s .CreateResourceFromString (resourceRaw )).
109- NotTo (HaveOccurred (), fmt .Sprintf ("creating %s" , resourType ))
110-
111- Eventually (func () string {
112- hryaml , err := s .GetResourceYaml (resourType , resourceName )
113- Expect (err ).NotTo (HaveOccurred (), fmt .Sprintf ("getting %s yaml" , resourType ))
114- return hryaml
115- }, "8s" , "2s" ).
116- Should (
117- SatisfyAll (
118- ContainSubstring (`status: "True"` ),
119- ContainSubstring (fmt .Sprintf ("observedGeneration: %d" , observedGeneration )),
120- ),
121- fmt .Sprintf ("checking %s condition status" , resourType ),
122- )
123- time .Sleep (1 * time .Second )
124- }
125-
126106 var beforeEachHTTP = func () {
127107 By ("create GatewayProxy" )
128108 gatewayProxy := fmt .Sprintf (gatewayProxyYaml , framework .DashboardTLSEndpoint , s .AdminKey ())
@@ -929,20 +909,18 @@ spec:
929909 - http-route-policy-0
930910`
931911 By ("create HTTPRoute" )
932- ResourceApplied ( "HTTPRoute" , "httpbin" , varsRoute , 1 )
912+ s . ApplyHTTPRoute (types. NamespacedName { Namespace : s . Namespace (), Name : "httpbin" } , varsRoute )
933913
934914 By ("create HTTPRoutePolices" )
935915 for name , spec := range map [string ]string {
936916 "http-route-policy-0" : httpRoutePolicy0 ,
937917 "http-route-policy-1" : httpRoutePolicy1 ,
938918 "http-route-policy-2" : httpRoutePolicy2 ,
939919 } {
940- err := s .CreateResourceFromString (spec )
941- Expect (err ).NotTo (HaveOccurred (), "creating HTTPRoutePolicy" )
942- // wait for HTTPRoutePolicy is Accepted
943- framework .HTTPRoutePolicyMustHaveCondition (s .GinkgoT , s .K8sClient , 10 * time .Second ,
920+ s .ApplyHTTPRoutePolicy (
944921 types.NamespacedName {Namespace : s .Namespace (), Name : "apisix" },
945922 types.NamespacedName {Namespace : s .Namespace (), Name : name },
923+ spec ,
946924 metav1.Condition {
947925 Type : string (v1alpha2 .PolicyConditionAccepted ),
948926 },
@@ -1414,15 +1392,14 @@ spec:
14141392 - name: httpbin-service-e2e-test
14151393 port: 80
14161394`
1417- ResourceApplied ("HTTPRoute" , "httpbin" , echoRoute , 1 )
1395+ s .ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, echoRoute , func (_ context.Context ) (done bool , err error ) {
1396+ return s .NewAPISIXClient ().GET ("/headers" ).
1397+ WithHeader ("Host" , "httpbin.example" ).
1398+ Expect ().Raw ().StatusCode == http .StatusOK , nil
1399+ })
14181400
14191401 time .Sleep (time .Second * 6 )
14201402
1421- _ = s .NewAPISIXClient ().GET ("/headers" ).
1422- WithHeader ("Host" , "httpbin.example" ).
1423- Expect ().
1424- Status (http .StatusOK )
1425-
14261403 echoLogs := s .GetDeploymentLogs ("echo" )
14271404 Expect (echoLogs ).To (ContainSubstring ("GET /headers" ))
14281405 })
@@ -1554,7 +1531,11 @@ spec:
15541531 })
15551532 })
15561533 It ("HTTPRoute Canary" , func () {
1557- ResourceApplied ("HTTPRoute" , "httpbin" , sameWeight , 1 )
1534+ s .ApplyHTTPRoute (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin" }, sameWeight , func (_ context.Context ) (done bool , err error ) {
1535+ return s .NewAPISIXClient ().GET ("/get" ).
1536+ WithHeader ("Host" , "httpbin.example" ).
1537+ Expect ().Raw ().StatusCode == http .StatusOK , nil
1538+ })
15581539
15591540 var (
15601541 hitNginxCnt = 0
@@ -1575,7 +1556,7 @@ spec:
15751556 }
15761557 Expect (hitNginxCnt - hitHttpbinCnt ).To (BeNumerically ("~" , 0 , 2 ))
15771558
1578- ResourceApplied ( "HTTPRoute" , "httpbin" , oneWeight , 2 )
1559+ s . ApplyHTTPRoute (types. NamespacedName { Namespace : s . Namespace (), Name : "httpbin" } , oneWeight )
15791560
15801561 hitNginxCnt = 0
15811562 hitHttpbinCnt = 0
0 commit comments