Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb30cbe

Browse files
committedOct 15, 2024··
Update health checks
Signed-off-by: Gerald Nunn <[email protected]>
1 parent 55a6bf3 commit bb30cbe

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed
 

Diff for: ‎controllers/argocd_metrics_controller_test.go

+41-7
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,38 @@ func TestReconciler_add_prometheus_rule(t *testing.T) {
313313
namespace: "namespace-two",
314314
},
315315
}
316+
testMonitoringRules := []struct {
317+
name string
318+
duration string
319+
expr string
320+
}{
321+
{
322+
name: "ArgoCDSyncAlert",
323+
duration: "5m",
324+
expr: "argocd_app_info{namespace=\"%s\",sync_status=\"OutOfSync\"} > 0",
325+
},
326+
{
327+
name: "ArgoCDUnknownSyncAlert",
328+
duration: "5m",
329+
expr: "argocd_app_info{namespace=\"%s\",sync_status=\"Unknown\"} > 0",
330+
},
331+
{
332+
name: "ArgoCDHealthAlert",
333+
duration: "5m",
334+
expr: "argocd_app_info{namespace=\"%s\", health_status!~\"Healthy|Suspended|Progressing|Degraded\"} > 0",
335+
},
336+
{
337+
name: "ArgoCDDegradedAlert",
338+
duration: "5m",
339+
expr: "argocd_app_info{namespace=\"%s\", health_status=\"Degraded\"} > 0",
340+
},
341+
{
342+
name: "ArgoCDProgressingAlert",
343+
duration: "10m",
344+
expr: "argocd_app_info{namespace=\"%s\", health_status=\"Progressing\"} > 0",
345+
},
346+
}
347+
316348
flagPtr := false
317349
for _, tc := range testCases {
318350
r := newMetricsReconciler(t, tc.namespace, tc.instanceName, &flagPtr)
@@ -327,13 +359,15 @@ func TestReconciler_add_prometheus_rule(t *testing.T) {
327359
assert.Equal(t, rule.OwnerReferences[0].Kind, argocdKind)
328360
assert.Equal(t, rule.OwnerReferences[0].Name, tc.instanceName)
329361

330-
assert.Equal(t, rule.Spec.Groups[0].Rules[0].Alert, "ArgoCDSyncAlert")
331-
assert.Assert(t, rule.Spec.Groups[0].Rules[0].Annotations["summary"] != "")
332-
assert.Assert(t, rule.Spec.Groups[0].Rules[0].Annotations["description"] != "")
333-
assert.Assert(t, rule.Spec.Groups[0].Rules[0].Labels["severity"] != "")
334-
assert.Equal(t, rule.Spec.Groups[0].Rules[0].For, "5m")
335-
expr := fmt.Sprintf("argocd_app_info{namespace=\"%s\",sync_status=\"OutOfSync\"} > 0", tc.namespace)
336-
assert.Equal(t, rule.Spec.Groups[0].Rules[0].Expr.StrVal, expr)
362+
for index, testMonitoringRule := range testMonitoringRules {
363+
assert.Equal(t, rule.Spec.Groups[0].Rules[index].Alert, testMonitoringRule.name)
364+
assert.Assert(t, rule.Spec.Groups[0].Rules[index].Annotations["summary"] != "")
365+
assert.Assert(t, rule.Spec.Groups[0].Rules[index].Annotations["description"] != "")
366+
assert.Assert(t, rule.Spec.Groups[0].Rules[index].Labels["severity"] != "")
367+
assert.Equal(t, rule.Spec.Groups[0].Rules[index].For, testMonitoringRule.duration)
368+
expr := fmt.Sprintf(testMonitoringRule.expr, tc.namespace)
369+
assert.Equal(t, rule.Spec.Groups[0].Rules[index].Expr.StrVal, expr)
370+
}
337371
}
338372
}
339373

0 commit comments

Comments
 (0)
Please sign in to comment.