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