@@ -75,21 +75,15 @@ func configV1Client() (result *configv1client.ConfigV1Client) {
75
75
return client
76
76
}
77
77
78
- func clusterOperator (clusterName string ) * configv1.ClusterOperator {
78
+ func clusterOperator (clusterName string , t * testing. T ) * configv1.ClusterOperator {
79
79
// get info about given cluster operator
80
80
operator , err := configClient .ClusterOperators ().Get (context .Background (), clusterName , metav1.GetOptions {})
81
81
if err != nil {
82
- // TODO -> change to t.Fatal in follow-up PR
83
- panic (err .Error ())
82
+ t .Fatalf ("Failed to get information about the operator: %s" , err )
84
83
}
85
84
return operator
86
85
}
87
86
88
- func clusterOperatorInsights () * configv1.ClusterOperator {
89
- // TODO -> delete this function in follow-up PR
90
- return clusterOperator ("insights" )
91
- }
92
-
93
87
func operatorConditionCheck (t * testing.T , operator * configv1.ClusterOperator , conditionType configv1.ClusterStatusConditionType ) bool {
94
88
statusConditions := operator .Status .Conditions
95
89
@@ -291,7 +285,7 @@ func degradeOperatorMonitoring(t *testing.T) func() {
291
285
// delete just in case it was already there, so we don't care about error
292
286
pod := findPod (t , clientset , "openshift-monitoring" , "cluster-monitoring-operator" )
293
287
clientset .CoreV1 ().ConfigMaps (pod .Namespace ).Delete (context .Background (), "cluster-monitoring-config" , metav1.DeleteOptions {})
294
- operatorConditionCheck (t , clusterOperator ("monitoring" ), "Degraded" )
288
+ operatorConditionCheck (t , clusterOperator ("monitoring" , t ), "Degraded" )
295
289
_ , err := clientset .CoreV1 ().ConfigMaps (pod .Namespace ).Create (context .Background (),
296
290
& corev1.ConfigMap {ObjectMeta : metav1.ObjectMeta {Name : "cluster-monitoring-config" }, Data : map [string ]string {"config.yaml" : "telemeterClient: enabled: NOT_BOOELAN" }},
297
291
metav1.CreateOptions {},
@@ -300,12 +294,12 @@ func degradeOperatorMonitoring(t *testing.T) func() {
300
294
err = clientset .CoreV1 ().Pods (pod .Namespace ).Delete (context .Background (), pod .Name , metav1.DeleteOptions {})
301
295
e (t , err , "Failed to delete Pod" )
302
296
wait .PollImmediate (1 * time .Second , 5 * time .Minute , func () (bool , error ) {
303
- return operatorConditionCheck (t , clusterOperator ("monitoring" ), "Degraded" ), nil
297
+ return operatorConditionCheck (t , clusterOperator ("monitoring" , t ), "Degraded" ), nil
304
298
})
305
299
return func () {
306
300
clientset .CoreV1 ().ConfigMaps (pod .Namespace ).Delete (context .Background (), "cluster-monitoring-config" , metav1.DeleteOptions {})
307
301
wait .PollImmediate (3 * time .Second , 3 * time .Minute , func () (bool , error ) {
308
- insightsDegraded := operatorConditionCheck (t , clusterOperator ("monitoring" ), "Degraded" )
302
+ insightsDegraded := operatorConditionCheck (t , clusterOperator ("monitoring" , t ), "Degraded" )
309
303
return ! insightsDegraded , nil
310
304
})
311
305
}
0 commit comments