@@ -34,7 +34,7 @@ import (
3434 "github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
3535)
3636
37- var _ = Describe ("Test CRD Status" , Label ("apisix.apache.org" , "v2" , "apisixroute" ), func () {
37+ var _ = Describe ("Test apisix.apache.org/v2 Status" , Label ("apisix.apache.org" , "v2" , "apisixroute" ), func () {
3838 var (
3939 s = scaffold .NewScaffold (& scaffold.Options {
4040 ControllerName : "apisix.apache.org/apisix-ingress-controller" ,
@@ -220,147 +220,4 @@ spec:
220220 "should not update the same status condition again" )
221221 })
222222 })
223-
224- Context ("Test HTTPRoute Sync Status" , func () {
225- const httproute = `
226- apiVersion: gateway.networking.k8s.io/v1
227- kind: HTTPRoute
228- metadata:
229- name: httpbin
230- spec:
231- parentRefs:
232- - name: apisix
233- hostnames:
234- - "httpbin"
235- rules:
236- - matches:
237- - path:
238- type: Exact
239- value: /get
240- backendRefs:
241- - name: httpbin-service-e2e-test
242- port: 80
243- `
244- const gatewayClass = `
245- apiVersion: gateway.networking.k8s.io/v1
246- kind: GatewayClass
247- metadata:
248- name: %s
249- spec:
250- controllerName: %s
251- `
252- const gatewayProxy = `
253- apiVersion: apisix.apache.org/v1alpha1
254- kind: GatewayProxy
255- metadata:
256- name: apisix-proxy-config
257- spec:
258- provider:
259- type: ControlPlane
260- controlPlane:
261- endpoints:
262- - %s
263- auth:
264- type: AdminKey
265- adminKey:
266- value: "%s"
267- `
268- const defaultGateway = `
269- apiVersion: gateway.networking.k8s.io/v1
270- kind: Gateway
271- metadata:
272- name: apisix
273- spec:
274- gatewayClassName: %s
275- listeners:
276- - name: http1
277- protocol: HTTP
278- port: 80
279- infrastructure:
280- parametersRef:
281- group: apisix.apache.org
282- kind: GatewayProxy
283- name: apisix-proxy-config
284- `
285- BeforeEach (func () {
286- By ("create GatewayProxy" )
287- gatewayProxy := fmt .Sprintf (gatewayProxy , s .Deployer .GetAdminEndpoint (), s .AdminKey ())
288- err := s .CreateResourceFromString (gatewayProxy )
289- Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
290- time .Sleep (5 * time .Second )
291-
292- By ("create GatewayClass" )
293- gatewayClassName := fmt .Sprintf ("apisix-%d" , time .Now ().Unix ())
294- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (gatewayClass , gatewayClassName , s .GetControllerName ()), "" )
295- Expect (err ).NotTo (HaveOccurred (), "creating GatewayClass" )
296- time .Sleep (5 * time .Second )
297-
298- By ("create Gateway" )
299- err = s .CreateResourceFromString (fmt .Sprintf (defaultGateway , gatewayClassName ))
300- Expect (err ).NotTo (HaveOccurred (), "creating Gateway" )
301- time .Sleep (5 * time .Second )
302-
303- By ("check Gateway condition" )
304- gwyaml , err := s .GetResourceYaml ("Gateway" , "apisix" )
305- Expect (err ).NotTo (HaveOccurred (), "getting Gateway yaml" )
306- Expect (gwyaml ).To (ContainSubstring (`status: "True"` ), "checking Gateway condition status" )
307- Expect (gwyaml ).To (ContainSubstring ("message: the gateway has been accepted by the apisix-ingress-controller" ), "checking Gateway condition message" )
308- })
309- AfterEach (func () {
310- _ = s .DeleteResource ("Gateway" , "apisix" )
311- })
312-
313- It ("dataplane unavailable" , func () {
314- if os .Getenv ("PROVIDER_TYPE" ) == adc .BackendModeAPI7EE {
315- Skip ("skip for api7ee mode because it use dashboard admin api" )
316- }
317- By ("Create HTTPRoute" )
318- err := s .CreateResourceFromString (httproute )
319- Expect (err ).NotTo (HaveOccurred (), "creating HTTPRoute" )
320-
321- By ("check route in APISIX" )
322- s .RequestAssert (& scaffold.RequestAssert {
323- Method : "GET" ,
324- Path : "/get" ,
325- Host : "httpbin" ,
326- Check : scaffold .WithExpectedStatus (200 ),
327- })
328-
329- s .Deployer .ScaleDataplane (0 )
330-
331- By ("check ApisixRoute status" )
332- s .RetryAssertion (func () string {
333- output , _ := s .GetOutputFromString ("httproute" , "httpbin" , "-o" , "yaml" )
334- return output
335- }).WithTimeout (80 * time .Second ).
336- Should (
337- And (
338- ContainSubstring (`status: "False"` ),
339- ContainSubstring (`reason: SyncFailed` ),
340- ),
341- )
342-
343- s .Deployer .ScaleDataplane (1 )
344-
345- By ("check ApisixRoute status after scaling up" )
346- s .RetryAssertion (func () string {
347- output , _ := s .GetOutputFromString ("httproute" , "httpbin" , "-o" , "yaml" )
348- return output
349- }).WithTimeout (80 * time .Second ).
350- Should (
351- And (
352- ContainSubstring (`status: "True"` ),
353- ContainSubstring (`reason: Accepted` ),
354- ),
355- )
356-
357- By ("check route in APISIX" )
358- s .RequestAssert (& scaffold.RequestAssert {
359- Method : "GET" ,
360- Path : "/get" ,
361- Host : "httpbin" ,
362- Check : scaffold .WithExpectedStatus (200 ),
363- })
364- })
365- })
366223})
0 commit comments