mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
b099d84271
* Initial rules evaluation support. Rules are now store alerts state in private field `alerts`. Every evaluation updates the alerts and state. Every unique metric received from datastore represents a unique alert, uniqueness is guaranteed by hashing ordered labelset. * merge with master * cleanup * support endAt parameter as 3*evaluationInterval for active alerts * make golint happy
36 lines
962 B
Go
36 lines
962 B
Go
package main
|
|
|
|
import (
|
|
"net/url"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmalert/notifier"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
u, _ := url.Parse("https://victoriametrics.com/path")
|
|
notifier.InitTemplateFunc(u)
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestParseGood(t *testing.T) {
|
|
if _, err := Parse([]string{"testdata/*good.rules", "testdata/dir/*good.*"}, true); err != nil {
|
|
t.Errorf("error parsing files %s", err)
|
|
}
|
|
}
|
|
|
|
func TestParseBad(t *testing.T) {
|
|
if _, err := Parse([]string{"testdata/rules0-bad.rules"}, true); err == nil {
|
|
t.Errorf("expected syntaxt error")
|
|
}
|
|
if _, err := Parse([]string{"testdata/dir/rules0-bad.rules"}, true); err == nil {
|
|
t.Errorf("expected template annotation error")
|
|
}
|
|
if _, err := Parse([]string{"testdata/dir/rules1-bad.rules"}, true); err == nil {
|
|
t.Errorf("expected same group error")
|
|
}
|
|
if _, err := Parse([]string{"testdata/*.yaml"}, true); err == nil {
|
|
t.Errorf("expected empty group")
|
|
}
|
|
}
|