@@ -272,6 +272,74 @@ func TestAssessControlPlaneStatus_Operators(t *testing.T) {
272
272
}
273
273
}
274
274
275
+ func TestAssessControlPlaneStatus_insights (t * testing.T ) {
276
+ testCases := []struct {
277
+ name string
278
+ cv * configv1.ClusterVersion
279
+ expected []updateInsight
280
+ }{
281
+ {
282
+ name : "cv: something went wrong" ,
283
+ cv : & configv1.ClusterVersion {
284
+ ObjectMeta : metav1.ObjectMeta {Name : "version" },
285
+ Status : configv1.ClusterVersionStatus {
286
+ Desired : configv1.Release {Version : "new" },
287
+ Conditions : []configv1.ClusterOperatorStatusCondition {{
288
+ Type : clusterStatusFailing ,
289
+ Status : configv1 .ConditionTrue ,
290
+ Reason : "something went wrong" ,
291
+ }},
292
+ },
293
+ },
294
+ expected : []updateInsight {
295
+ {
296
+ scope : updateInsightScope {scopeType : "ControlPlane" , resources : []scopeResource {{kind : scopeGroupKind {group : "config.openshift.io" , kind : "ClusterVersion" }, name : "version" }}},
297
+ impact : updateInsightImpact {
298
+ level : warningImpactLevel ,
299
+ impactType : "Update Stalled" ,
300
+ summary : "Cluster Version version is failing to proceed with the update (something went wrong)" ,
301
+ },
302
+ remediation : updateInsightRemediation {reference : "https://github.com/openshift/runbooks/blob/master/alerts/cluster-monitoring-operator/ClusterOperatorDegraded.md" },
303
+ },
304
+ },
305
+ },
306
+ {
307
+ name : "cv: SlowClusterOperator" ,
308
+ cv : & configv1.ClusterVersion {
309
+ ObjectMeta : metav1.ObjectMeta {Name : "version" },
310
+ Status : configv1.ClusterVersionStatus {
311
+ Desired : configv1.Release {Version : "new" },
312
+ Conditions : []configv1.ClusterOperatorStatusCondition {{
313
+ Type : clusterStatusFailing ,
314
+ Status : configv1 .ConditionUnknown ,
315
+ Reason : "SlowClusterOperator" ,
316
+ }},
317
+ },
318
+ },
319
+ expected : []updateInsight {
320
+ {
321
+ scope : updateInsightScope {scopeType : "ControlPlane" , resources : []scopeResource {{kind : scopeGroupKind {group : "config.openshift.io" , kind : "ClusterVersion" }, name : "version" }}},
322
+ impact : updateInsightImpact {
323
+ level : warningImpactLevel ,
324
+ impactType : "Update Stalled" ,
325
+ summary : "Cluster Version version may be failing to proceed with the update (SlowClusterOperator)" ,
326
+ },
327
+ remediation : updateInsightRemediation {reference : "https://github.com/openshift/runbooks/blob/master/alerts/cluster-monitoring-operator/ClusterOperatorDegraded.md" },
328
+ },
329
+ },
330
+ },
331
+ }
332
+
333
+ for _ , tc := range testCases {
334
+ t .Run (tc .name , func (t * testing.T ) {
335
+ _ , insights := assessControlPlaneStatus (tc .cv , nil , "" , time .Now ())
336
+ if diff := cmp .Diff (tc .expected , insights , allowUnexportedInsightStructs ); diff != "" {
337
+ t .Errorf ("%s: expected insights differs from actual:\n %s" , tc .name , diff )
338
+ }
339
+ })
340
+ }
341
+ }
342
+
275
343
func TestAssessControlPlaneStatus_Estimate (t * testing.T ) {
276
344
now := time .Now ()
277
345
minutesAgo := [250 ]time.Time {}
0 commit comments