@@ -583,40 +583,138 @@ func TestGlobalLabelsAndAnnotations(t *testing.T) {
583
583
"--set" , "globalAnnotations.four=annotation-four" )
584
584
g .Expect (err ).NotTo (HaveOccurred ())
585
585
AssertHelmInstallWithStatefulSetSubTest (t , "basic" , cmd , g , AssertLabelsAndAnnotations )
586
+ }
587
+
588
+ func TestGlobalLabelsOnOperatorResources (t * testing.T ) {
589
+ g := NewGomegaWithT (t )
590
+
591
+ result , err := helmInstall ("--set" , "globalLabels.one=label-one" ,
592
+ "--set" , "globalLabels.two=label-two" )
593
+
594
+ g .Expect (err ).NotTo (HaveOccurred ())
595
+ g .Expect (result ).NotTo (BeNil ())
596
+
597
+ dep := & appsv1.Deployment {}
598
+ err = result .Get ("coherence-operator" , dep )
599
+ g .Expect (err ).NotTo (HaveOccurred ())
600
+
601
+ labels := dep .Labels
602
+ actual , found := labels ["one" ]
603
+ g .Expect (found ).To (BeTrue ())
604
+ g .Expect (actual ).To (Equal ("label-one" ))
605
+ actual , found = labels ["two" ]
606
+ g .Expect (found ).To (BeTrue ())
607
+ g .Expect (actual ).To (Equal ("label-two" ))
608
+
609
+ labels = dep .Spec .Template .Labels
610
+ actual , found = labels ["one" ]
611
+ g .Expect (found ).To (BeTrue ())
612
+ g .Expect (actual ).To (Equal ("label-one" ))
613
+ actual , found = labels ["two" ]
614
+ g .Expect (found ).To (BeTrue ())
615
+ g .Expect (actual ).To (Equal ("label-two" ))
616
+
617
+ svc := & corev1.Service {}
618
+ err = result .Get ("coherence-operator-webhook" , svc )
619
+ g .Expect (err ).NotTo (HaveOccurred ())
620
+
621
+ labels = svc .Labels
622
+ actual , found = labels ["one" ]
623
+ g .Expect (found ).To (BeTrue ())
624
+ g .Expect (actual ).To (Equal ("label-one" ))
625
+ actual , found = labels ["two" ]
626
+ g .Expect (found ).To (BeTrue ())
627
+ g .Expect (actual ).To (Equal ("label-two" ))
628
+
629
+ svc = & corev1.Service {}
630
+ err = result .Get ("coherence-operator-rest" , svc )
631
+ g .Expect (err ).NotTo (HaveOccurred ())
632
+
633
+ labels = svc .Labels
634
+ actual , found = labels ["one" ]
635
+ g .Expect (found ).To (BeTrue ())
636
+ g .Expect (actual ).To (Equal ("label-one" ))
637
+ actual , found = labels ["two" ]
638
+ g .Expect (found ).To (BeTrue ())
639
+ g .Expect (actual ).To (Equal ("label-two" ))
640
+
641
+ sec := & corev1.Secret {}
642
+ err = result .Get ("coherence-webhook-server-cert" , sec )
643
+ g .Expect (err ).NotTo (HaveOccurred ())
644
+
645
+ labels = sec .Labels
646
+ actual , found = labels ["one" ]
647
+ g .Expect (found ).To (BeTrue ())
648
+ g .Expect (actual ).To (Equal ("label-one" ))
649
+ actual , found = labels ["two" ]
650
+ g .Expect (found ).To (BeTrue ())
651
+ g .Expect (actual ).To (Equal ("label-two" ))
652
+ }
653
+
654
+ func TestGlobalAnnotationsOnOperatorResources (t * testing.T ) {
655
+ g := NewGomegaWithT (t )
656
+
657
+ result , err := helmInstall ("--set" , "globalAnnotations.one=annotation-one" ,
658
+ "--set" , "globalAnnotations.two=annotation-two" )
586
659
587
- //result, err := helmInstall("--set", "globalLabels.one=label-one",
588
- // "--set", "globalLabels.two=label-two",
589
- // "--set", "globalAnnotations.three=annotation-three",
590
- // "--set", "globalAnnotations.four=annotation-four")
591
- //
592
- //g.Expect(err).NotTo(HaveOccurred())
593
- //g.Expect(result).NotTo(BeNil())
594
- //
595
- //dep := &appsv1.Deployment{}
596
- //err = result.Get("coherence-operator", dep)
597
- //g.Expect(err).NotTo(HaveOccurred())
598
- //
599
- //t.Logf("Asserting Helm install. Deploying Coherence resource")
600
- //ns := helper.GetTestNamespace()
601
- //deployment, err := helper.NewSingleCoherenceFromYaml(ns, "coherence.yaml")
602
- //g.Expect(err).NotTo(HaveOccurred())
603
- //
604
- //defer deleteCoherence(t, &deployment)
605
- //
606
- //err = testContext.Client.Create(goctx.TODO(), &deployment)
607
- //g.Expect(err).NotTo(HaveOccurred())
608
- //
609
- //var sts *appsv1.StatefulSet
610
- //sts, err = helper.WaitForStatefulSetForDeployment(testContext, ns, &deployment, helper.RetryInterval, helper.Timeout)
611
- //g.Expect(err).NotTo(HaveOccurred())
612
- //
613
- //g.Expect(sts.Labels).NotTo(BeNil())
614
- //g.Expect(sts.Labels["one"]).To(Equal("label-one"))
615
- //g.Expect(sts.Labels["two"]).To(Equal("label-two"))
616
- //
617
- //g.Expect(sts.Annotations).NotTo(BeNil())
618
- //g.Expect(sts.Annotations["three"]).To(Equal("annotation-three"))
619
- //g.Expect(sts.Annotations["four"]).To(Equal("annotation-four"))
660
+ g .Expect (err ).NotTo (HaveOccurred ())
661
+ g .Expect (result ).NotTo (BeNil ())
662
+
663
+ dep := & appsv1.Deployment {}
664
+ err = result .Get ("coherence-operator" , dep )
665
+ g .Expect (err ).NotTo (HaveOccurred ())
666
+
667
+ annotations := dep .Annotations
668
+ actual , found := annotations ["one" ]
669
+ g .Expect (found ).To (BeTrue ())
670
+ g .Expect (actual ).To (Equal ("annotation-one" ))
671
+ actual , found = annotations ["two" ]
672
+ g .Expect (found ).To (BeTrue ())
673
+ g .Expect (actual ).To (Equal ("annotation-two" ))
674
+
675
+ annotations = dep .Spec .Template .Annotations
676
+ actual , found = annotations ["one" ]
677
+ g .Expect (found ).To (BeTrue ())
678
+ g .Expect (actual ).To (Equal ("annotation-one" ))
679
+ actual , found = annotations ["two" ]
680
+ g .Expect (found ).To (BeTrue ())
681
+ g .Expect (actual ).To (Equal ("annotation-two" ))
682
+
683
+ svc := & corev1.Service {}
684
+ err = result .Get ("coherence-operator-webhook" , svc )
685
+ g .Expect (err ).NotTo (HaveOccurred ())
686
+
687
+ annotations = svc .Annotations
688
+ actual , found = annotations ["one" ]
689
+ g .Expect (found ).To (BeTrue ())
690
+ g .Expect (actual ).To (Equal ("annotation-one" ))
691
+ actual , found = annotations ["two" ]
692
+ g .Expect (found ).To (BeTrue ())
693
+ g .Expect (actual ).To (Equal ("annotation-two" ))
694
+
695
+ svc = & corev1.Service {}
696
+ err = result .Get ("coherence-operator-rest" , svc )
697
+ g .Expect (err ).NotTo (HaveOccurred ())
698
+
699
+ annotations = svc .Annotations
700
+ actual , found = annotations ["one" ]
701
+ g .Expect (found ).To (BeTrue ())
702
+ g .Expect (actual ).To (Equal ("annotation-one" ))
703
+ actual , found = annotations ["two" ]
704
+ g .Expect (found ).To (BeTrue ())
705
+ g .Expect (actual ).To (Equal ("annotation-two" ))
706
+
707
+ sec := & corev1.Secret {}
708
+ err = result .Get ("coherence-webhook-server-cert" , sec )
709
+ g .Expect (err ).NotTo (HaveOccurred ())
710
+
711
+ annotations = sec .Annotations
712
+ actual , found = annotations ["one" ]
713
+ g .Expect (found ).To (BeTrue ())
714
+ g .Expect (actual ).To (Equal ("annotation-one" ))
715
+ actual , found = annotations ["two" ]
716
+ g .Expect (found ).To (BeTrue ())
717
+ g .Expect (actual ).To (Equal ("annotation-two" ))
620
718
}
621
719
622
720
func AssertLabelsAndAnnotations (t * testing.T , g * GomegaWithT , _ * coh.Coherence , sts * appsv1.StatefulSet ) {
0 commit comments