@@ -3375,6 +3375,23 @@ func TestSyncOperatorGroups(t *testing.T) {
33753375 },
33763376 }
33773377
3378+ // Failed CSV due to operatorgroup namespace selector doesn't any existing namespaces
3379+ operatorCSVFailedNoTargetNS := operatorCSV .DeepCopy ()
3380+ operatorCSVFailedNoTargetNS .Status .Phase = v1alpha1 .CSVPhaseFailed
3381+ operatorCSVFailedNoTargetNS .Status .Message = "no targetNamespaces are matched operatorgroups namespace selection"
3382+ operatorCSVFailedNoTargetNS .Status .Reason = v1alpha1 .CSVReasonNoTargetNamespaces
3383+ operatorCSVFailedNoTargetNS .Status .LastUpdateTime = timeNow ()
3384+ operatorCSVFailedNoTargetNS .Status .LastTransitionTime = timeNow ()
3385+ operatorCSVFailedNoTargetNS .Status .Conditions = []v1alpha1.ClusterServiceVersionCondition {
3386+ {
3387+ Phase : v1alpha1 .CSVPhaseFailed ,
3388+ Reason : v1alpha1 .CSVReasonNoTargetNamespaces ,
3389+ Message : "no targetNamespaces are matched operatorgroups namespace selection" ,
3390+ LastUpdateTime : timeNow (),
3391+ LastTransitionTime : timeNow (),
3392+ },
3393+ }
3394+
33783395 targetCSV := operatorCSVFinal .DeepCopy ()
33793396 targetCSV .SetNamespace (targetNamespace )
33803397 targetCSV .Status .Reason = v1alpha1 .CSVReasonCopied
@@ -3489,6 +3506,47 @@ func TestSyncOperatorGroups(t *testing.T) {
34893506 },
34903507 expectedStatus : v1.OperatorGroupStatus {},
34913508 },
3509+ {
3510+ name : "NoMatchingNamespace/CSVPresent" ,
3511+ expectedEqual : true ,
3512+ initial : initial {
3513+ operatorGroup : & v1.OperatorGroup {
3514+ ObjectMeta : metav1.ObjectMeta {
3515+ Name : "operator-group-1" ,
3516+ Namespace : operatorNamespace ,
3517+ },
3518+ Spec : v1.OperatorGroupSpec {
3519+ Selector : & metav1.LabelSelector {
3520+ MatchLabels : map [string ]string {"a" : "app-a" },
3521+ },
3522+ },
3523+ },
3524+ clientObjs : []runtime.Object {operatorCSV },
3525+ k8sObjs : []runtime.Object {
3526+ & corev1.Namespace {
3527+ ObjectMeta : metav1.ObjectMeta {
3528+ Name : operatorNamespace ,
3529+ },
3530+ },
3531+ & corev1.Namespace {
3532+ ObjectMeta : metav1.ObjectMeta {
3533+ Name : targetNamespace ,
3534+ },
3535+ },
3536+ ownedDeployment ,
3537+ serviceAccount ,
3538+ role ,
3539+ roleBinding ,
3540+ },
3541+ crds : []runtime.Object {crd },
3542+ },
3543+ expectedStatus : v1.OperatorGroupStatus {},
3544+ final : final {objects : map [string ][]runtime.Object {
3545+ operatorNamespace : {
3546+ withAnnotations (operatorCSVFailedNoTargetNS .DeepCopy (), map [string ]string {v1 .OperatorGroupAnnotationKey : "operator-group-1" , v1 .OperatorGroupNamespaceAnnotationKey : operatorNamespace }),
3547+ },
3548+ }},
3549+ },
34923550 {
34933551 name : "MatchingNamespace/NoCSVs" ,
34943552 expectedEqual : true ,
0 commit comments