|
|
|
@ -51,7 +51,7 @@ func TestAlertingRule(t *testing.T) {
|
|
|
|
|
expr, |
|
|
|
|
time.Minute, |
|
|
|
|
labels.FromStrings("severity", "{{\"c\"}}ritical"), |
|
|
|
|
nil, true, nil, |
|
|
|
|
nil, nil, true, nil, |
|
|
|
|
) |
|
|
|
|
result := promql.Vector{ |
|
|
|
|
{ |
|
|
|
@ -192,7 +192,7 @@ func TestForStateAddSamples(t *testing.T) {
|
|
|
|
|
expr, |
|
|
|
|
time.Minute, |
|
|
|
|
labels.FromStrings("severity", "{{\"c\"}}ritical"), |
|
|
|
|
nil, true, nil, |
|
|
|
|
nil, nil, true, nil, |
|
|
|
|
) |
|
|
|
|
result := promql.Vector{ |
|
|
|
|
{ |
|
|
|
@ -366,7 +366,7 @@ func TestForStateRestore(t *testing.T) {
|
|
|
|
|
expr, |
|
|
|
|
alertForDuration, |
|
|
|
|
labels.FromStrings("severity", "critical"), |
|
|
|
|
nil, true, nil, |
|
|
|
|
nil, nil, true, nil, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
group := NewGroup("default", "", time.Second, []Rule{rule}, true, opts) |
|
|
|
@ -426,7 +426,7 @@ func TestForStateRestore(t *testing.T) {
|
|
|
|
|
expr, |
|
|
|
|
alertForDuration, |
|
|
|
|
labels.FromStrings("severity", "critical"), |
|
|
|
|
nil, false, nil, |
|
|
|
|
nil, nil, false, nil, |
|
|
|
|
) |
|
|
|
|
newGroup := NewGroup("default", "", time.Second, []Rule{newRule}, true, opts) |
|
|
|
|
|
|
|
|
@ -581,12 +581,12 @@ func readSeriesSet(ss storage.SeriesSet) (map[string][]promql.Point, error) {
|
|
|
|
|
func TestCopyState(t *testing.T) { |
|
|
|
|
oldGroup := &Group{ |
|
|
|
|
rules: []Rule{ |
|
|
|
|
NewAlertingRule("alert", nil, 0, nil, nil, true, nil), |
|
|
|
|
NewAlertingRule("alert", nil, 0, nil, nil, nil, true, nil), |
|
|
|
|
NewRecordingRule("rule1", nil, nil), |
|
|
|
|
NewRecordingRule("rule2", nil, nil), |
|
|
|
|
NewRecordingRule("rule3", nil, labels.Labels{{Name: "l1", Value: "v1"}}), |
|
|
|
|
NewRecordingRule("rule3", nil, labels.Labels{{Name: "l1", Value: "v2"}}), |
|
|
|
|
NewAlertingRule("alert2", nil, 0, labels.Labels{{Name: "l2", Value: "v1"}}, nil, true, nil), |
|
|
|
|
NewAlertingRule("alert2", nil, 0, labels.Labels{{Name: "l2", Value: "v1"}}, nil, nil, true, nil), |
|
|
|
|
}, |
|
|
|
|
seriesInPreviousEval: []map[string]labels.Labels{ |
|
|
|
|
{"a": nil}, |
|
|
|
@ -604,10 +604,10 @@ func TestCopyState(t *testing.T) {
|
|
|
|
|
NewRecordingRule("rule3", nil, labels.Labels{{Name: "l1", Value: "v0"}}), |
|
|
|
|
NewRecordingRule("rule3", nil, labels.Labels{{Name: "l1", Value: "v1"}}), |
|
|
|
|
NewRecordingRule("rule3", nil, labels.Labels{{Name: "l1", Value: "v2"}}), |
|
|
|
|
NewAlertingRule("alert", nil, 0, nil, nil, true, nil), |
|
|
|
|
NewAlertingRule("alert", nil, 0, nil, nil, nil, true, nil), |
|
|
|
|
NewRecordingRule("rule1", nil, nil), |
|
|
|
|
NewAlertingRule("alert2", nil, 0, labels.Labels{{Name: "l2", Value: "v0"}}, nil, true, nil), |
|
|
|
|
NewAlertingRule("alert2", nil, 0, labels.Labels{{Name: "l2", Value: "v1"}}, nil, true, nil), |
|
|
|
|
NewAlertingRule("alert2", nil, 0, labels.Labels{{Name: "l2", Value: "v0"}}, nil, nil, true, nil), |
|
|
|
|
NewAlertingRule("alert2", nil, 0, labels.Labels{{Name: "l2", Value: "v1"}}, nil, nil, true, nil), |
|
|
|
|
NewRecordingRule("rule4", nil, nil), |
|
|
|
|
}, |
|
|
|
|
seriesInPreviousEval: make([]map[string]labels.Labels, 8), |
|
|
|
@ -654,7 +654,7 @@ func TestUpdate(t *testing.T) {
|
|
|
|
|
ruleManager.Run() |
|
|
|
|
defer ruleManager.Stop() |
|
|
|
|
|
|
|
|
|
err := ruleManager.Update(10*time.Second, files) |
|
|
|
|
err := ruleManager.Update(10*time.Second, files, nil) |
|
|
|
|
testutil.Ok(t, err) |
|
|
|
|
testutil.Assert(t, len(ruleManager.groups) > 0, "expected non-empty rule groups") |
|
|
|
|
for _, g := range ruleManager.groups { |
|
|
|
@ -663,7 +663,7 @@ func TestUpdate(t *testing.T) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err = ruleManager.Update(10*time.Second, files) |
|
|
|
|
err = ruleManager.Update(10*time.Second, files, nil) |
|
|
|
|
testutil.Ok(t, err) |
|
|
|
|
for _, g := range ruleManager.groups { |
|
|
|
|
for _, actual := range g.seriesInPreviousEval { |
|
|
|
@ -699,7 +699,7 @@ func TestNotify(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
expr, err := promql.ParseExpr("a > 1") |
|
|
|
|
testutil.Ok(t, err) |
|
|
|
|
rule := NewAlertingRule("aTooHigh", expr, 0, labels.Labels{}, labels.Labels{}, true, log.NewNopLogger()) |
|
|
|
|
rule := NewAlertingRule("aTooHigh", expr, 0, labels.Labels{}, labels.Labels{}, nil, true, log.NewNopLogger()) |
|
|
|
|
group := NewGroup("alert", "", time.Second, []Rule{rule}, true, opts) |
|
|
|
|
|
|
|
|
|
app, _ := storage.Appender() |
|
|
|
|