3333 value: "%s"
3434`
3535
36- var defautlGatewayClass = `
36+ var gatewayClassYaml = `
3737apiVersion: gateway.networking.k8s.io/v1
3838kind: GatewayClass
3939metadata:
4242 controllerName: %s
4343`
4444
45- var defautlGateway = `
45+ var defaultGateway = `
4646apiVersion: gateway.networking.k8s.io/v1
4747kind: Gateway
4848metadata:
5959 kind: GatewayProxy
6060 name: api7-proxy-config
6161`
62- var defautlGatewayHTTPS = `
62+ var defaultGatewayHTTPS = `
6363apiVersion: gateway.networking.k8s.io/v1
6464kind: Gateway
6565metadata:
@@ -111,7 +111,7 @@ spec:
111111
112112 By ("create GatewayClass" )
113113 gatewayClassName := fmt .Sprintf ("api7-%d" , time .Now ().Unix ())
114- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defautlGatewayClass , gatewayClassName , s .GetControllerName ()), "" )
114+ err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (gatewayClassYaml , gatewayClassName , s .GetControllerName ()), "" )
115115 Expect (err ).NotTo (HaveOccurred (), "creating GatewayClass" )
116116 time .Sleep (5 * time .Second )
117117
@@ -122,7 +122,7 @@ spec:
122122 Expect (gcyaml ).To (ContainSubstring ("message: the gatewayclass has been accepted by the api7-ingress-controller" ), "checking GatewayClass condition message" )
123123
124124 By ("create Gateway" )
125- err = s .CreateResourceFromString (fmt .Sprintf (defautlGateway , gatewayClassName ))
125+ err = s .CreateResourceFromString (fmt .Sprintf (defaultGateway , gatewayClassName ))
126126 Expect (err ).NotTo (HaveOccurred (), "creating Gateway" )
127127 time .Sleep (5 * time .Second )
128128
@@ -144,7 +144,7 @@ spec:
144144 createSecret (s , secretName )
145145 By ("create GatewayClass" )
146146 gatewayClassName := fmt .Sprintf ("api7-%d" , time .Now ().Unix ())
147- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defautlGatewayClass , gatewayClassName , s .GetControllerName ()), "" )
147+ err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (gatewayClassYaml , gatewayClassName , s .GetControllerName ()), "" )
148148 Expect (err ).NotTo (HaveOccurred (), "creating GatewayClass" )
149149 time .Sleep (5 * time .Second )
150150
@@ -155,7 +155,7 @@ spec:
155155 Expect (gcyaml ).To (ContainSubstring ("message: the gatewayclass has been accepted by the api7-ingress-controller" ), "checking GatewayClass condition message" )
156156
157157 By ("create Gateway" )
158- err = s .CreateResourceFromString (fmt .Sprintf (defautlGatewayHTTPS , gatewayClassName ))
158+ err = s .CreateResourceFromString (fmt .Sprintf (defaultGatewayHTTPS , gatewayClassName ))
159159 Expect (err ).NotTo (HaveOccurred (), "creating Gateway" )
160160 time .Sleep (5 * time .Second )
161161
@@ -214,6 +214,7 @@ spec:
214214 Context ("HTTPRoute with Multiple Gateway" , func () {
215215 var additionalGatewayGroupID string
216216 var additionalNamespace string
217+ var additionalGatewayClassName string
217218
218219 var additionalGatewayProxyYaml = `
219220apiVersion: gateway.apisix.io/v1alpha1
@@ -278,58 +279,37 @@ spec:
278279 port: 80
279280`
280281
281- var gatewayClassName string
282-
283282 BeforeEach (func () {
284- By ("Create GatewayProxy" )
285- gatewayProxy := fmt .Sprintf (gatewayProxyYaml , framework .DashboardTLSEndpoint , s .AdminKey ())
286- err := s .CreateResourceFromString (gatewayProxy )
287- Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
288- time .Sleep (5 * time .Second )
289-
290- By ("create GatewayClass" )
291- gatewayClassName = fmt .Sprintf ("api7-%d" , time .Now ().Unix ())
292- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defautlGatewayClass , gatewayClassName , s .GetControllerName ()), "" )
293- Expect (err ).NotTo (HaveOccurred (), "creating GatewayClass" )
294- time .Sleep (5 * time .Second )
295-
296- By ("check GatewayClass condition" )
297- gcyaml , err := s .GetResourceYaml ("GatewayClass" , gatewayClassName )
298- Expect (err ).NotTo (HaveOccurred (), "getting GatewayClass yaml" )
299- Expect (gcyaml ).To (ContainSubstring (`status: "True"` ), "checking GatewayClass condition status" )
300- Expect (gcyaml ).To (ContainSubstring ("message: the gatewayclass has been accepted by the api7-ingress-controller" ), "checking GatewayClass condition message" )
301-
302- By ("create Gateway" )
303- err = s .CreateResourceFromString (fmt .Sprintf (defautlGateway , gatewayClassName ))
304- Expect (err ).NotTo (HaveOccurred (), "creating Gateway" )
305- time .Sleep (5 * time .Second )
306-
307- By ("check Gateway condition" )
308- gwyaml , err := s .GetResourceYaml ("Gateway" , "api7ee" )
309- Expect (err ).NotTo (HaveOccurred (), "getting Gateway yaml" )
310- Expect (gwyaml ).To (ContainSubstring (`status: "True"` ), "checking Gateway condition status" )
311- Expect (gwyaml ).To (ContainSubstring ("message: the gateway has been accepted by the api7-ingress-controller" ), "checking Gateway condition message" )
283+ beforeEachHTTP ()
312284
313285 By ("Create additional gateway group" )
286+ var err error
314287 additionalGatewayGroupID , additionalNamespace , err = s .CreateAdditionalGatewayGroup ("multi-gw" )
315288 Expect (err ).NotTo (HaveOccurred (), "creating additional gateway group" )
316289
317- By ("Initialize dataplane client for additional gateway group" )
318- err = s .InitializeDataplaneClientForGatewayGroup (additionalGatewayGroupID )
319- Expect (err ).NotTo (HaveOccurred (), "initializing dataplane client" )
320-
321290 By ("Create additional GatewayProxy" )
322291 // Get admin key for the additional gateway group
323292 resources , exists := s .GetAdditionalGatewayGroup (additionalGatewayGroupID )
324293 Expect (exists ).To (BeTrue (), "additional gateway group should exist" )
325294
295+ By ("Create additional GatewayClass" )
296+ additionalGatewayClassName = fmt .Sprintf ("api7-%d" , time .Now ().Unix ())
297+ err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (gatewayClassYaml , additionalGatewayClassName , s .GetControllerName ()), "" )
298+ Expect (err ).NotTo (HaveOccurred (), "creating additional GatewayClass" )
299+ time .Sleep (5 * time .Second )
300+ By ("Check additional GatewayClass condition" )
301+ gcyaml , err := s .GetResourceYaml ("GatewayClass" , additionalGatewayClassName )
302+ Expect (err ).NotTo (HaveOccurred (), "getting additional GatewayClass yaml" )
303+ Expect (gcyaml ).To (ContainSubstring (`status: "True"` ), "checking additional GatewayClass condition status" )
304+ Expect (gcyaml ).To (ContainSubstring ("message: the gatewayclass has been accepted by the api7-ingress-controller" ), "checking additional GatewayClass condition message" )
305+
326306 additionalGatewayProxy := fmt .Sprintf (additionalGatewayProxyYaml , framework .DashboardTLSEndpoint , resources .AdminAPIKey )
327307 err = s .CreateResourceFromStringWithNamespace (additionalGatewayProxy , additionalNamespace )
328308 Expect (err ).NotTo (HaveOccurred (), "creating additional GatewayProxy" )
329309
330310 By ("Create additional Gateway" )
331311 err = s .CreateResourceFromStringWithNamespace (
332- fmt .Sprintf (additionalGateway , gatewayClassName ),
312+ fmt .Sprintf (additionalGateway , additionalGatewayClassName ),
333313 additionalNamespace ,
334314 )
335315 Expect (err ).NotTo (HaveOccurred (), "creating additional Gateway" )
@@ -359,7 +339,7 @@ spec:
359339 Status (http .StatusOK )
360340
361341 By ("Delete Additional Gateway" )
362- err = s .DeleteResourceFromStringWithNamespace (fmt .Sprintf (additionalGateway , gatewayClassName ), additionalNamespace )
342+ err = s .DeleteResourceFromStringWithNamespace (fmt .Sprintf (additionalGateway , additionalGatewayClassName ), additionalNamespace )
363343 Expect (err ).NotTo (HaveOccurred (), "deleting additional Gateway" )
364344 time .Sleep (5 * time .Second )
365345
0 commit comments