@@ -638,4 +638,116 @@ spec:
638638 WithTimeout (8 * time .Second ).ProbeEvery (time .Second ).Should (Equal (http .StatusOK ))
639639 })
640640 })
641+
642+ Context ("Ingress with GatewayProxy Update" , func () {
643+ var additionalGatewayGroupID string
644+
645+ var ingressClass = `
646+ apiVersion: networking.k8s.io/v1
647+ kind: IngressClass
648+ metadata:
649+ name: api7-ingress-class
650+ spec:
651+ controller: "apisix.apache.org/api7-ingress-controller"
652+ parameters:
653+ apiGroup: "apisix.apache.org"
654+ kind: "GatewayProxy"
655+ name: "api7-proxy-config"
656+ namespace: "default"
657+ scope: "Namespace"
658+ `
659+ var ingress = `
660+ apiVersion: networking.k8s.io/v1
661+ kind: Ingress
662+ metadata:
663+ name: api7-ingress
664+ spec:
665+ ingressClassName: api7-ingress-class
666+ rules:
667+ - host: ingress.example.com
668+ http:
669+ paths:
670+ - path: /
671+ pathType: Prefix
672+ backend:
673+ service:
674+ name: httpbin-service-e2e-test
675+ port:
676+ number: 80
677+ `
678+ var updatedGatewayProxy = `
679+ apiVersion: apisix.apache.org/v1alpha1
680+ kind: GatewayProxy
681+ metadata:
682+ name: api7-proxy-config
683+ namespace: default
684+ spec:
685+ provider:
686+ type: ControlPlane
687+ controlPlane:
688+ endpoints:
689+ - %s
690+ auth:
691+ type: AdminKey
692+ adminKey:
693+ value: "%s"
694+ `
695+
696+ BeforeEach (func () {
697+ By ("create GatewayProxy" )
698+ gatewayProxy := fmt .Sprintf (gatewayProxyYaml , framework .DashboardTLSEndpoint , s .AdminKey ())
699+ err := s .CreateResourceFromStringWithNamespace (gatewayProxy , "default" )
700+ Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
701+ time .Sleep (5 * time .Second )
702+
703+ By ("create IngressClass" )
704+ err = s .CreateResourceFromStringWithNamespace (ingressClass , "" )
705+ Expect (err ).NotTo (HaveOccurred (), "creating IngressClass" )
706+ time .Sleep (5 * time .Second )
707+ })
708+
709+ It ("Should sync Ingress when GatewayProxy is updated" , func () {
710+ By ("create Ingress" )
711+ err := s .CreateResourceFromString (ingress )
712+ Expect (err ).NotTo (HaveOccurred (), "creating Ingress" )
713+ time .Sleep (5 * time .Second )
714+
715+ By ("verify Ingress works" )
716+ s .NewAPISIXClient ().
717+ GET ("/get" ).
718+ WithHost ("ingress.example.com" ).
719+ Expect ().
720+ Status (200 )
721+
722+ By ("create additional gateway group to get new admin key" )
723+ additionalGatewayGroupID , _ , err = s .CreateAdditionalGatewayGroup ("gateway-proxy-update" )
724+ Expect (err ).NotTo (HaveOccurred (), "creating additional gateway group" )
725+
726+ client , err := s .NewAPISIXClientForGatewayGroup (additionalGatewayGroupID )
727+ Expect (err ).NotTo (HaveOccurred (), "creating APISIX client for additional gateway group" )
728+
729+ By ("Ingress not found for additional gateway group" )
730+ client .
731+ GET ("/get" ).
732+ WithHost ("ingress.example.com" ).
733+ Expect ().
734+ Status (404 )
735+
736+ resources , exists := s .GetAdditionalGatewayGroup (additionalGatewayGroupID )
737+ Expect (exists ).To (BeTrue (), "additional gateway group should exist" )
738+
739+ By ("update GatewayProxy with new admin key" )
740+ updatedProxy := fmt .Sprintf (updatedGatewayProxy , framework .DashboardTLSEndpoint , resources .AdminAPIKey )
741+ err = s .CreateResourceFromStringWithNamespace (updatedProxy , "default" )
742+ Expect (err ).NotTo (HaveOccurred (), "updating GatewayProxy" )
743+ time .Sleep (5 * time .Second )
744+
745+ By ("verify Ingress works for additional gateway group" )
746+ client .
747+ GET ("/get" ).
748+ WithHost ("ingress.example.com" ).
749+ Expect ().
750+ Status (200 )
751+ })
752+ })
641753})
0 commit comments