@@ -127,6 +127,8 @@ var _ = Describe("eventHandler", func() {
127127 updateGatewayClassStatus : true ,
128128 })
129129 Expect (handler .cfg .graphBuiltHealthChecker .ready ).To (BeFalse ())
130+
131+ handler .cfg .graphBuiltHealthChecker .leader = true
130132 })
131133
132134 AfterEach (func () {
@@ -193,6 +195,17 @@ var _ = Describe("eventHandler", func() {
193195 expectReconfig (dcfg , fakeCfgFiles )
194196 Expect (helpers .Diff (handler .GetLatestConfiguration (), & dcfg )).To (BeEmpty ())
195197 })
198+
199+ It ("should process a NewLeaderEvent" , func () {
200+ e := & events.NewLeaderEvent {}
201+
202+ batch := []interface {}{e }
203+
204+ handler .HandleEventBatch (context .Background (), ctlrZap .New (), batch )
205+
206+ dcfg := dataplane .GetDefaultConfiguration (& graph.Graph {}, 1 )
207+ Expect (helpers .Diff (handler .GetLatestConfiguration (), & dcfg )).To (BeEmpty ())
208+ })
196209 })
197210
198211 When ("a batch has multiple events" , func () {
@@ -202,7 +215,8 @@ var _ = Describe("eventHandler", func() {
202215 Type : & gatewayv1.HTTPRoute {},
203216 NamespacedName : types.NamespacedName {Namespace : "test" , Name : "route" },
204217 }
205- batch := []interface {}{upsertEvent , deleteEvent }
218+ newLeaderEvent := & events.NewLeaderEvent {}
219+ batch := []interface {}{upsertEvent , deleteEvent , newLeaderEvent }
206220
207221 handler .HandleEventBatch (context .Background (), ctlrZap .New (), batch )
208222
@@ -502,6 +516,25 @@ var _ = Describe("eventHandler", func() {
502516 Expect (handler .cfg .graphBuiltHealthChecker .readyCheck (nil )).To (Succeed ())
503517 })
504518
519+ It ("should not update nginx conf if NGF is not leader" , func () {
520+ e := & events.UpsertEvent {Resource : & gatewayv1.HTTPRoute {}}
521+ batch := []interface {}{e }
522+ readyChannel := handler .cfg .graphBuiltHealthChecker .getReadyCh ()
523+
524+ fakeProcessor .ProcessReturns (state .ClusterStateChange , & graph.Graph {})
525+
526+ handler .cfg .graphBuiltHealthChecker .leader = false
527+
528+ Expect (handler .cfg .graphBuiltHealthChecker .readyCheck (nil )).ToNot (Succeed ())
529+ handler .HandleEventBatch (context .Background (), ctlrZap .New (), batch )
530+
531+ Expect (handler .GetLatestConfiguration ()).To (BeNil ())
532+
533+ Expect (readyChannel ).ShouldNot (BeClosed ())
534+
535+ Expect (handler .cfg .graphBuiltHealthChecker .readyCheck (nil )).ToNot (Succeed ())
536+ })
537+
505538 It ("should panic for an unknown event type" , func () {
506539 e := & struct {}{}
507540
0 commit comments