2121import java .util .Optional ;
2222import java .util .Random ;
2323import java .util .function .Predicate ;
24+ import java .util .stream .Collectors ;
2425
2526import com .google .common .collect .ImmutableMap ;
2627import io .fabric8 .kubernetes .api .model .HasMetadata ;
2728import io .fabric8 .kubernetes .api .model .LoadBalancerIngressBuilder ;
2829import io .fabric8 .kubernetes .api .model .LoadBalancerStatusBuilder ;
30+ import io .fabric8 .kubernetes .api .model .Pod ;
2931import io .fabric8 .kubernetes .api .model .Service ;
3032import io .fabric8 .kubernetes .api .model .ServiceSpecBuilder ;
3133import io .fabric8 .kubernetes .api .model .ServiceStatusBuilder ;
@@ -177,9 +179,12 @@ void whenThereIsNoChanges_allResourcesShouldBeEmpty() {
177179 foundDeployedResources );
178180
179181 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
180- assertEquals (0 , result .getDeletions ().size ());
181- assertEquals (0 , result .getCreations ().size ());
182- assertEquals (0 , result .getPatches ().size ());
182+ assertEquals (0 , result .getDeletions ().size (),
183+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
184+ assertEquals (0 , result .getCreations ().size (),
185+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
186+ assertEquals (0 , result .getPatches ().size (),
187+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
183188
184189 assertTrue (result .isUpToDate ());
185190 }
@@ -323,9 +328,12 @@ void whenThereAreDeployedChangesOnMetadataOwnerReferences_shouldDoNothing() {
323328 foundDeployedResources );
324329
325330 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
326- assertEquals (0 , result .getDeletions ().size ());
327- assertEquals (0 , result .getCreations ().size ());
328- assertEquals (0 , result .getPatches ().size ());
331+ assertEquals (0 , result .getDeletions ().size (),
332+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
333+ assertEquals (0 , result .getCreations ().size (),
334+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
335+ assertEquals (0 , result .getPatches ().size (),
336+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
329337 }
330338
331339 @ Test
@@ -342,6 +350,7 @@ void whenThereAreDeployedWithOtherMetadataOwnerReferences_shouldDoNoting() {
342350
343351 var updatedResource = Seq .seq (foundDeployedResources )
344352 .zipWithIndex ()
353+ .filter (Predicate .not (t -> t .v1 instanceof Pod ))
345354 .filter (t -> hasAnotherOwnerReference (t .v1 ))
346355 .sorted (shuffle ())
347356 .findFirst ()
@@ -356,9 +365,12 @@ void whenThereAreDeployedWithOtherMetadataOwnerReferences_shouldDoNoting() {
356365 foundDeployedResources );
357366
358367 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
359- assertEquals (0 , result .getDeletions ().size ());
360- assertEquals (0 , result .getCreations ().size ());
361- assertEquals (0 , result .getPatches ().size ());
368+ assertEquals (0 , result .getDeletions ().size (),
369+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
370+ assertEquals (0 , result .getCreations ().size (),
371+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
372+ assertEquals (0 , result .getPatches ().size (),
373+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
362374 }
363375
364376 @ Test
@@ -461,9 +473,12 @@ void whenThereAreDeployedChangesOnMetadataResourceVersion_shouldNotBeDetected()
461473 foundDeployedResources );
462474
463475 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
464- assertEquals (0 , result .getDeletions ().size ());
465- assertEquals (0 , result .getCreations ().size ());
466- assertEquals (0 , result .getPatches ().size ());
476+ assertEquals (0 , result .getDeletions ().size (),
477+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
478+ assertEquals (0 , result .getCreations ().size (),
479+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
480+ assertEquals (0 , result .getPatches ().size (),
481+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
467482 }
468483
469484 @ Test
@@ -494,9 +509,12 @@ void whenThereAreDeployedChangesOnStatefulSetStatus_shouldNotBeDetected() {
494509 foundDeployedResources );
495510
496511 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
497- assertEquals (0 , result .getDeletions ().size ());
498- assertEquals (0 , result .getCreations ().size ());
499- assertEquals (0 , result .getPatches ().size ());
512+ assertEquals (0 , result .getDeletions ().size (),
513+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
514+ assertEquals (0 , result .getCreations ().size (),
515+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
516+ assertEquals (0 , result .getPatches ().size (),
517+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
500518 }
501519
502520 @ Test
@@ -531,9 +549,12 @@ void whenThereAreDeployedChangesOnServiceStatus_shouldNotBeDetected() {
531549 foundDeployedResources );
532550
533551 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
534- assertEquals (0 , result .getDeletions ().size ());
535- assertEquals (0 , result .getCreations ().size ());
536- assertEquals (0 , result .getPatches ().size ());
552+ assertEquals (0 , result .getDeletions ().size (),
553+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
554+ assertEquals (0 , result .getCreations ().size (),
555+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
556+ assertEquals (0 , result .getPatches ().size (),
557+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
537558 }
538559
539560 @ Test
@@ -598,9 +619,12 @@ void conciliation_shouldIgnoreChangesOnResourcesMarkedWithReconciliationPauseAnn
598619
599620 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
600621
601- assertEquals (0 , result .getDeletions ().size ());
602- assertEquals (0 , result .getCreations ().size ());
603- assertEquals (0 , result .getPatches ().size ());
622+ assertEquals (0 , result .getDeletions ().size (),
623+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
624+ assertEquals (0 , result .getCreations ().size (),
625+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
626+ assertEquals (0 , result .getPatches ().size (),
627+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
604628
605629 assertTrue (result .isUpToDate ());
606630 }
@@ -647,9 +671,12 @@ void conciliation_shouldIgnoreDeletionsOnResourcesMarkedWithReconciliationPauseA
647671 foundDeployedResources );
648672
649673 ReconciliationResult result = conciliator .evalReconciliationState (cluster );
650- assertEquals (0 , result .getCreations ().size ());
651- assertEquals (0 , result .getDeletions ().size ());
652- assertEquals (0 , result .getPatches ().size ());
674+ assertEquals (0 , result .getDeletions ().size (),
675+ result .getDeletions ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
676+ assertEquals (0 , result .getCreations ().size (),
677+ result .getCreations ().stream ().map (t -> t .getKind ()).collect (Collectors .joining (", " )));
678+ assertEquals (0 , result .getPatches ().size (),
679+ result .getPatches ().stream ().map (t -> t .v2 .getKind ()).collect (Collectors .joining (", " )));
653680
654681 assertTrue (result .isUpToDate ());
655682 }
@@ -733,16 +760,16 @@ protected ClusterConciliator buildConciliator(
733760 }
734761
735762 private boolean hasAnotherOwnerReference (HasMetadata resource ) {
736- return resource .getMetadata ().getOwnerReferences () ! = null
737- && ( resource .getMetadata ().getOwnerReferences ().isEmpty ()
763+ return resource .getMetadata ().getOwnerReferences () = = null
764+ || resource .getMetadata ().getOwnerReferences ().isEmpty ()
738765 || resource .getMetadata ().getOwnerReferences ().stream ()
739766 .noneMatch (ownerReference -> ownerReference .getKind ()
740767 .equals (HasMetadata .getKind (cluster .getClass ()))
741768 && ownerReference .getApiVersion ().equals (HasMetadata .getApiVersion (cluster .getClass ()))
742769 && ownerReference .getName ().equals (cluster .getMetadata ().getName ())
743770 && ownerReference .getUid ().equals (cluster .getMetadata ().getUid ())
744- && ownerReference .getController () != null
745- && ownerReference .getController () ));
771+ && ownerReference .getController () != null
772+ && ownerReference .getController ());
746773 }
747774
748775 private boolean hasControllerOwnerReference (HasMetadata resource ) {
0 commit comments