@@ -25,7 +25,6 @@ import (
2525 configv1 "github.com/openshift/api/config/v1"
2626 "github.com/openshift/library-go/pkg/crypto"
2727
28- "github.com/openshift/cluster-version-operator/pkg/featuregates"
2928 "github.com/openshift/cluster-version-operator/pkg/internal"
3029)
3130
@@ -670,7 +669,6 @@ func Test_operatorMetrics_Collect(t *testing.T) {
670669 }
671670 for _ , tt := range tests {
672671 t .Run (tt .name , func (t * testing.T ) {
673- tt .optr .enabledCVOFeatureGates = featuregates .DefaultCvoGates ("version" )
674672 tt .optr .eventRecorder = record .NewFakeRecorder (100 )
675673 if tt .optr .cvLister == nil {
676674 tt .optr .cvLister = & cvLister {}
@@ -977,117 +975,6 @@ func TestCollectUnknownConditionalUpdates(t *testing.T) {
977975 }
978976}
979977
980- func Test_collectConditionalUpdateRisks (t * testing.T ) {
981- type valueWithLabels struct {
982- value float64
983- labels map [string ]string
984- }
985- testCases := []struct {
986- name string
987- risks []configv1.ConditionalUpdateRisk
988- expected []valueWithLabels
989- }{
990- {
991- name : "no conditional updates" ,
992- expected : []valueWithLabels {},
993- },
994- {
995- name : "unknown type" ,
996- risks : []configv1.ConditionalUpdateRisk {
997- {
998- Name : "RiskX" ,
999- Conditions : []metav1.Condition {{
1000- Type : internal .ConditionalUpdateConditionTypeRecommended ,
1001- Status : metav1 .ConditionFalse ,
1002- Reason : "ReasonA" ,
1003- Message : "Risk does not apply" ,
1004- }},
1005- },
1006- },
1007- },
1008- {
1009- name : "apply false" ,
1010- risks : []configv1.ConditionalUpdateRisk {
1011- {
1012- Name : "RiskX" ,
1013- Conditions : []metav1.Condition {{
1014- Type : internal .ConditionalUpdateRiskConditionTypeApplies ,
1015- Status : metav1 .ConditionFalse ,
1016- Reason : "ReasonA" ,
1017- Message : "Risk does not apply" ,
1018- }},
1019- },
1020- },
1021- expected : []valueWithLabels {{
1022- labels : map [string ]string {"condition" : "Applies" , "risk" : "RiskX" , "reason" : "ReasonA" },
1023- }},
1024- },
1025- {
1026- name : "apply true" ,
1027- risks : []configv1.ConditionalUpdateRisk {
1028- {
1029- Name : "RiskX" ,
1030- Conditions : []metav1.Condition {{
1031- Type : internal .ConditionalUpdateRiskConditionTypeApplies ,
1032- Status : metav1 .ConditionTrue ,
1033- Reason : "ReasonA" ,
1034- Message : "Risk does not apply" ,
1035- }},
1036- },
1037- },
1038- expected : []valueWithLabels {{
1039- value : 1 ,
1040- labels : map [string ]string {"condition" : "Applies" , "risk" : "RiskX" , "reason" : "ReasonA" },
1041- }},
1042- },
1043- {
1044- name : "apply unknown" ,
1045- risks : []configv1.ConditionalUpdateRisk {
1046- {
1047- Name : "RiskX" ,
1048- Conditions : []metav1.Condition {{
1049- Type : internal .ConditionalUpdateRiskConditionTypeApplies ,
1050- Status : metav1 .ConditionUnknown ,
1051- Reason : "ReasonA" ,
1052- Message : "Risk does not apply" ,
1053- }},
1054- },
1055- },
1056- expected : []valueWithLabels {{
1057- value : - 1 ,
1058- labels : map [string ]string {"condition" : "Applies" , "risk" : "RiskX" , "reason" : "ReasonA" },
1059- }},
1060- },
1061- }
1062-
1063- for _ , tc := range testCases {
1064- tc := tc
1065- t .Run (tc .name , func (t * testing.T ) {
1066- optr := & Operator {}
1067- m := newOperatorMetrics (optr )
1068- ch := make (chan prometheus.Metric )
1069-
1070- go func () {
1071- m .collectConditionalUpdateRisks (ch , tc .risks )
1072- close (ch )
1073- }()
1074-
1075- var collected []prometheus.Metric
1076- for item := range ch {
1077- collected = append (collected , item )
1078- }
1079-
1080- if lenC , lenE := len (collected ), len (tc .expected ); lenC != lenE {
1081-
1082- t .Fatalf ("Expected %d metrics, got %d metrics\n Got metrics: %s" , lenE , lenC , spew .Sdump (collected ))
1083- }
1084- for i := range tc .expected {
1085- expectMetric (t , collected [i ], tc .expected [i ].value , tc .expected [i ].labels )
1086- }
1087- })
1088- }
1089- }
1090-
1091978func expectMetric (t * testing.T , metric prometheus.Metric , value float64 , labels map [string ]string ) {
1092979 t .Helper ()
1093980 var d dto.Metric
0 commit comments