@@ -40,27 +40,6 @@ import (
4040var _ = Describe ("Test HTTPRoute" , Label ("networking.k8s.io" , "httproute" ), func () {
4141 s := scaffold .NewDefaultScaffold ()
4242
43- var gatewayProxyYaml = `
44- apiVersion: apisix.apache.org/v1alpha1
45- kind: GatewayProxy
46- metadata:
47- name: %s
48- spec:
49- provider:
50- type: ControlPlane
51- controlPlane:
52- service:
53- name: %s
54- port: 9180
55- auth:
56- type: AdminKey
57- adminKey:
58- value: "%s"
59- `
60- getGatewayProxySpec := func () string {
61- return fmt .Sprintf (gatewayProxyYaml , s .Namespace (), framework .ProviderType , s .AdminKey ())
62- }
63-
6443 var gatewayClassYaml = `
6544apiVersion: gateway.networking.k8s.io/v1
6645kind: GatewayClass
7049 controllerName: %s
7150`
7251
73- var defaultGateway = `
74- apiVersion: gateway.networking.k8s.io/v1
75- kind: Gateway
76- metadata:
77- name: %s
78- spec:
79- gatewayClassName: %s
80- listeners:
81- - name: http1
82- protocol: HTTP
83- port: 80
84- infrastructure:
85- parametersRef:
86- group: apisix.apache.org
87- kind: GatewayProxy
88- name: %s
89- `
9052 var defaultGatewayHTTPS = `
9153apiVersion: gateway.networking.k8s.io/v1
9254kind: Gateway
@@ -108,19 +70,18 @@ spec:
10870 parametersRef:
10971 group: apisix.apache.org
11072 kind: GatewayProxy
111- name: %s
73+ name: apisix-proxy-config
11274`
11375
11476 var beforeEachHTTP = func () {
115- Expect ( s . CreateResourceFromStringWithNamespace ( getGatewayProxySpec (), s . Namespace ())).
116- NotTo (HaveOccurred (), "creating GatewayProxy" )
77+ By ( "create GatewayProxy" )
78+ Expect ( s . CreateResourceFromString ( s . GetGatewayProxySpec ())). NotTo (HaveOccurred (), "creating GatewayProxy" )
11779
118- gatewayClassName := s .Namespace ()
119- Expect (s .CreateResourceFromStringWithNamespace (fmt .Sprintf (gatewayClassYaml , gatewayClassName , s .GetControllerName ()), "" )).
120- NotTo (HaveOccurred (), "creating GatewayClass" )
80+ By ("create GatewayClass" )
81+ Expect (s .CreateResourceFromString (s .GetGatewayClassYaml ())).NotTo (HaveOccurred (), "creating GatewayClass" )
12182
12283 s .RetryAssertion (func () string {
123- gcyaml , _ := s .GetResourceYaml ("GatewayClass" , gatewayClassName )
84+ gcyaml , _ := s .GetResourceYaml ("GatewayClass" , s . Namespace () )
12485 return gcyaml
12586 }).Should (
12687 And (
@@ -129,12 +90,11 @@ spec:
12990 ),
13091 "check GatewayClass condition" ,
13192 )
132- gatewayName := s .Namespace ()
133- Expect (s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defaultGateway , gatewayName , gatewayClassName , s .Namespace ()), s .Namespace ())).
134- NotTo (HaveOccurred (), "creating Gateway" )
93+
94+ Expect (s .CreateResourceFromString (s .GetGatewayYaml ())).NotTo (HaveOccurred (), "creating Gateway" )
13595
13696 s .RetryAssertion (func () string {
137- gcyaml , _ := s .GetResourceYaml ("Gateway" , gatewayName )
97+ gcyaml , _ := s .GetResourceYaml ("Gateway" , s . Namespace () )
13898 return gcyaml
13999 }).Should (
140100 And (
@@ -147,19 +107,17 @@ spec:
147107
148108 var beforeEachHTTPS = func () {
149109 By ("create GatewayProxy" )
150- err := s .CreateResourceFromStringWithNamespace ( getGatewayProxySpec (), s . Namespace ())
110+ err := s .CreateResourceFromString ( s . GetGatewayProxySpec ())
151111 Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
152112
153113 secretName := _secretName
154114 createSecret (s , secretName )
155115
156116 By ("create GatewayClass" )
157- gatewayClassName := s .Namespace ()
158- Expect (s .CreateResourceFromStringWithNamespace (fmt .Sprintf (gatewayClassYaml , gatewayClassName , s .GetControllerName ()), "" )).
159- NotTo (HaveOccurred (), "creating GatewayClass" )
117+ Expect (s .CreateResourceFromString (s .GetGatewayClassYaml ())).NotTo (HaveOccurred (), "creating GatewayClass" )
160118
161119 s .RetryAssertion (func () string {
162- gcyaml , _ := s .GetResourceYaml ("GatewayClass" , gatewayClassName )
120+ gcyaml , _ := s .GetResourceYaml ("GatewayClass" , s . Namespace () )
163121 return gcyaml
164122 }).Should (
165123 And (
@@ -170,12 +128,11 @@ spec:
170128 )
171129
172130 By ("create Gateway" )
173- gatewayName := s .Namespace ()
174- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defaultGatewayHTTPS , gatewayName , gatewayClassName , s .Namespace ()), s .Namespace ())
131+ err = s .CreateResourceFromString (fmt .Sprintf (defaultGatewayHTTPS , s .Namespace (), s .Namespace ()))
175132 Expect (err ).NotTo (HaveOccurred (), "creating Gateway" )
176133
177134 s .RetryAssertion (func () string {
178- gcyaml , _ := s .GetResourceYaml ("Gateway" , gatewayName )
135+ gcyaml , _ := s .GetResourceYaml ("Gateway" , s . Namespace () )
179136 return gcyaml
180137 }).Should (
181138 And (
@@ -1853,7 +1810,7 @@ spec:
18531810apiVersion: apisix.apache.org/v1alpha1
18541811kind: GatewayProxy
18551812metadata:
1856- name: %s
1813+ name: apisix-proxy-config
18571814spec:
18581815 provider:
18591816 type: ControlPlane
@@ -1905,8 +1862,8 @@ spec:
19051862 })
19061863
19071864 By ("update GatewayProxy with new admin key" )
1908- updatedProxy := fmt .Sprintf (updatedGatewayProxy , s .Namespace (), s . Deployer .GetAdminEndpoint (resources .DataplaneService ), resources .AdminAPIKey )
1909- err = s .CreateResourceFromStringWithNamespace (updatedProxy , s . Namespace () )
1865+ updatedProxy := fmt .Sprintf (updatedGatewayProxy , s .Deployer .GetAdminEndpoint (resources .DataplaneService ), resources .AdminAPIKey )
1866+ err = s .CreateResourceFromString (updatedProxy )
19101867 Expect (err ).NotTo (HaveOccurred (), "updating GatewayProxy" )
19111868
19121869 By ("verify HTTPRoute works for additional gateway group" )
@@ -2060,7 +2017,7 @@ spec:
20602017`
20612018 It ("Should sync ApisixRoute during startup" , func () {
20622019 By ("apply ApisixRoute" )
2063- Expect (s .CreateResourceFromStringWithNamespace (route2 , s . Namespace () )).ShouldNot (HaveOccurred (), "applying HTTPRoute with non-existent parent" )
2020+ Expect (s .CreateResourceFromString (route2 )).ShouldNot (HaveOccurred (), "applying HTTPRoute with non-existent parent" )
20642021 s .ResourceApplied ("HTTPRoute" , "httpbin" , fmt .Sprintf (route , s .Namespace ()), 1 )
20652022
20662023 s .RequestAssert (& scaffold.RequestAssert {
@@ -2080,7 +2037,6 @@ spec:
20802037 Timeout : 30 * time .Second ,
20812038 })
20822039
2083- time .Sleep (8 * time .Second )
20842040 By ("restart controller and dataplane" )
20852041 s .Deployer .ScaleIngress (0 )
20862042 s .Deployer .ScaleDataplane (0 )
@@ -2093,7 +2049,7 @@ spec:
20932049 Host : "httpbin" ,
20942050 Check : scaffold .WithExpectedStatus (http .StatusOK ),
20952051 Interval : time .Second * 2 ,
2096- Timeout : 30 * time .Second ,
2052+ Timeout : 1 * time .Minute ,
20972053 })
20982054 s .RequestAssert (& scaffold.RequestAssert {
20992055 Method : "GET" ,
0 commit comments