2727import org .apache .flink .kubernetes .operator .controller .FlinkResourceContext ;
2828import org .apache .flink .kubernetes .operator .exception .ReconciliationException ;
2929
30+ import io .fabric8 .kubernetes .api .model .Event ;
3031import io .fabric8 .kubernetes .api .model .networking .v1 .Ingress ;
3132import io .fabric8 .kubernetes .api .model .networking .v1 .IngressRule ;
3233import io .fabric8 .kubernetes .api .model .networking .v1 .IngressTLS ;
@@ -84,7 +85,7 @@ void testIngress() {
8485
8586 // no ingress when ingressDomain is empty
8687 IngressUtils .reconcileIngress (
87- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
88+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
8889 if (IngressUtils .ingressInNetworkingV1 (client )) {
8990 assertNull (
9091 client .network ()
@@ -108,7 +109,7 @@ void testIngress() {
108109 builder .template ("{{name}}.{{namespace}}.example.com" );
109110 appCluster .getSpec ().setIngress (builder .build ());
110111 IngressUtils .reconcileIngress (
111- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
112+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
112113 Ingress ingress = null ;
113114 io .fabric8 .kubernetes .api .model .networking .v1beta1 .Ingress ingressV1beta1 = null ;
114115 if (IngressUtils .ingressInNetworkingV1 (client )) {
@@ -157,7 +158,7 @@ void testIngress() {
157158 builder .annotations (Map .of ("nginx.ingress.kubernetes.io/rewrite-target" , "/$2" ));
158159 appCluster .getSpec ().setIngress (builder .build ());
159160 IngressUtils .reconcileIngress (
160- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
161+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
161162 if (IngressUtils .ingressInNetworkingV1 (client )) {
162163 ingress =
163164 client .network ()
@@ -214,7 +215,7 @@ void testIngress() {
214215 builder .className ("nginx" );
215216 appCluster .getSpec ().setIngress (builder .build ());
216217 IngressUtils .reconcileIngress (
217- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
218+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
218219 if (IngressUtils .ingressInNetworkingV1 (client )) {
219220 ingress =
220221 client .network ()
@@ -298,7 +299,7 @@ public void testIngressTls() {
298299 builder .tls (new ArrayList <>());
299300 appCluster .getSpec ().setIngress (builder .build ());
300301 IngressUtils .reconcileIngress (
301- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
302+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
302303 Ingress ingress = null ;
303304 io .fabric8 .kubernetes .api .model .networking .v1beta1 .Ingress ingressV1beta1 = null ;
304305 if (IngressUtils .ingressInNetworkingV1 (client )) {
@@ -335,7 +336,7 @@ public void testIngressTls() {
335336 builder .tls (List .of (ingressTlsSpecSecretOnly ));
336337 appCluster .getSpec ().setIngress (builder .build ());
337338 IngressUtils .reconcileIngress (
338- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
339+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
339340 if (IngressUtils .ingressInNetworkingV1 (client )) {
340341 ingress =
341342 client .network ()
@@ -373,7 +374,7 @@ public void testIngressTls() {
373374 builder .tls (List .of (ingressTlsSpecHostsOnly ));
374375 appCluster .getSpec ().setIngress (builder .build ());
375376 IngressUtils .reconcileIngress (
376- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
377+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
377378 if (IngressUtils .ingressInNetworkingV1 (client )) {
378379 ingress =
379380 client .network ()
@@ -411,7 +412,7 @@ public void testIngressTls() {
411412 builder .tls (List .of (ingressTlsSpecSingleTLSWithHost ));
412413 appCluster .getSpec ().setIngress (builder .build ());
413414 IngressUtils .reconcileIngress (
414- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
415+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
415416 if (IngressUtils .ingressInNetworkingV1 (client )) {
416417 ingress =
417418 client .network ()
@@ -453,7 +454,7 @@ public void testIngressTls() {
453454 builder .tls (List .of (ingressTlsSpecSingleTLSWithHosts ));
454455 appCluster .getSpec ().setIngress (builder .build ());
455456 IngressUtils .reconcileIngress (
456- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
457+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
457458 if (IngressUtils .ingressInNetworkingV1 (client )) {
458459 ingress =
459460 client .network ()
@@ -500,7 +501,7 @@ public void testIngressTls() {
500501 List .of (ingressTlsSpecMultipleTLSWithHosts1 , ingressTlsSpecMultipleTLSWithHosts2 ));
501502 appCluster .getSpec ().setIngress (builder .build ());
502503 IngressUtils .reconcileIngress (
503- createResourceContext (appCluster ), appCluster .getSpec (), config , client );
504+ createResourceContext (appCluster ), appCluster .getSpec (), config , client , null );
504505 if (IngressUtils .ingressInNetworkingV1 (client )) {
505506 ingress =
506507 client .network ()
@@ -564,7 +565,7 @@ void testDeletesIngress() {
564565 io .fabric8 .kubernetes .api .model .networking .v1beta1 .Ingress .class ,
565566 List .of (ingress )));
566567
567- IngressUtils .reconcileIngress (context , appCluster .getSpec (), null , client );
568+ IngressUtils .reconcileIngress (context , appCluster .getSpec (), null , client , null );
568569
569570 var ingressV1beta1 =
570571 client .network ()
@@ -578,6 +579,9 @@ void testDeletesIngress() {
578579
579580 @ Test
580581 void skipIngressReconciliationIfFeatureFlagOff () {
582+ List <Event > events = new ArrayList <>();
583+ EventRecorder eventRecorder =
584+ new EventRecorder ((a , event ) -> events .add (event ), (a , b ) -> {});
581585 FlinkDeployment appCluster = TestUtils .buildApplicationCluster ();
582586 FlinkConfigManager manager =
583587 new FlinkConfigManager (
@@ -593,7 +597,7 @@ void skipIngressReconciliationIfFeatureFlagOff() {
593597 builder .tls (new ArrayList <>());
594598 appCluster .getSpec ().setIngress (builder .build ());
595599
596- IngressUtils .reconcileIngress (context , appCluster .getSpec (), config , client );
600+ IngressUtils .reconcileIngress (context , appCluster .getSpec (), config , client , eventRecorder );
597601
598602 var ingressV1beta1 =
599603 client .network ()
@@ -603,5 +607,6 @@ void skipIngressReconciliationIfFeatureFlagOff() {
603607 .withName (appCluster .getMetadata ().getName ())
604608 .get ();
605609 assertThat (ingressV1beta1 ).isNull ();
610+ assertThat (events ).hasSize (1 );
606611 }
607612}
0 commit comments