@@ -460,6 +460,86 @@ spec:
460460 })
461461 })
462462
463+ Context ("Ingress Scale and Route Management" , func () {
464+ It ("should handle ApisixRoute management during ingress scaling" , func () {
465+ const apisixRouteSpec1 = `
466+ apiVersion: apisix.apache.org/v2
467+ kind: ApisixRoute
468+ metadata:
469+ name: route1
470+ spec:
471+ ingressClassName: apisix
472+ http:
473+ - name: rule1
474+ match:
475+ hosts:
476+ - httpbin
477+ paths:
478+ - /get
479+ backends:
480+ - serviceName: httpbin-service-e2e-test
481+ servicePort: 80
482+ `
483+
484+ const apisixRouteSpec2 = `
485+ apiVersion: apisix.apache.org/v2
486+ kind: ApisixRoute
487+ metadata:
488+ name: route2
489+ spec:
490+ ingressClassName: apisix
491+ http:
492+ - name: rule2
493+ match:
494+ hosts:
495+ - httpbin
496+ paths:
497+ - /anything
498+ backends:
499+ - serviceName: httpbin-service-e2e-test
500+ servicePort: 80
501+ `
502+
503+ request := func (path string ) int {
504+ return s .NewAPISIXClient ().GET (path ).WithHost ("httpbin" ).Expect ().Raw ().StatusCode
505+ }
506+
507+ By ("apply first ApisixRoute" )
508+ var apisixRoute1 apiv2.ApisixRoute
509+ applier .MustApplyAPIv2 (types.NamespacedName {Namespace : s .Namespace (), Name : "route1" }, & apisixRoute1 , apisixRouteSpec1 )
510+
511+ By ("apply second ApisixRoute" )
512+ var apisixRoute2 apiv2.ApisixRoute
513+ applier .MustApplyAPIv2 (types.NamespacedName {Namespace : s .Namespace (), Name : "route2" }, & apisixRoute2 , apisixRouteSpec2 )
514+
515+ By ("verify both ApisixRoutes work" )
516+ Eventually (request ).WithArguments ("/get" ).WithTimeout (8 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
517+ Eventually (request ).WithArguments ("/anything" ).WithTimeout (8 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
518+
519+ By ("scale ingress to 0" )
520+ s .Deployer .ScaleIngress (0 )
521+
522+ By ("delete first ApisixRoute" )
523+ err := s .DeleteResource ("ApisixRoute" , "route1" )
524+ Expect (err ).ShouldNot (HaveOccurred (), "deleting ApisixRoute route1" )
525+
526+ By ("verify both routes still accessible during scale-down" )
527+ Eventually (request ).WithArguments ("/get" ).WithTimeout (8 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
528+ Eventually (request ).WithArguments ("/anything" ).WithTimeout (8 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
529+
530+ By ("scale ingress back to 1" )
531+ s .Deployer .ScaleIngress (1 )
532+
533+ By ("verify first route is gone and second route still accessible after scale-up" )
534+ Eventually (request ).WithArguments ("/get" ).WithTimeout (30 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusNotFound ))
535+ Eventually (request ).WithArguments ("/anything" ).WithTimeout (30 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
536+
537+ routes , err := s .DefaultDataplaneResource ().Route ().List (context .Background ())
538+ Expect (err ).NotTo (HaveOccurred (), "list routes error" )
539+ Expect (routes ).To (HaveLen (1 ), "routes number not expect" )
540+ })
541+ })
542+
463543 Context ("Test ApisixRoute reference ApisixUpstream" , func () {
464544 It ("Test reference ApisixUpstream" , func () {
465545 const apisixRouteSpec = `
0 commit comments