|
|
|
@ -39,7 +39,7 @@ func TestDashboardAnnotations(t *testing.T) { |
|
|
|
|
|
|
|
|
|
fakeAnnoRepo := annotationstest.NewFakeAnnotationsRepo() |
|
|
|
|
hist := historian.NewAnnotationHistorian(fakeAnnoRepo, &dashboards.FakeDashboardService{}) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, dbstore, dbstore, &image.NoopImageService{}, clock.New(), hist) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, dbstore, &image.NoopImageService{}, clock.New(), hist) |
|
|
|
|
|
|
|
|
|
const mainOrgID int64 = 1 |
|
|
|
|
|
|
|
|
@ -48,7 +48,7 @@ func TestDashboardAnnotations(t *testing.T) { |
|
|
|
|
"test2": "{{ $labels.instance_label }}", |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
st.Warm(ctx) |
|
|
|
|
st.Warm(ctx, dbstore) |
|
|
|
|
bValue := float64(42) |
|
|
|
|
cValue := float64(1) |
|
|
|
|
_ = st.ProcessEvalResults(ctx, evaluationTime, rule, eval.Results{{ |
|
|
|
@ -2020,7 +2020,7 @@ func TestProcessEvalResults(t *testing.T) { |
|
|
|
|
for _, tc := range testCases { |
|
|
|
|
fakeAnnoRepo := annotationstest.NewFakeAnnotationsRepo() |
|
|
|
|
hist := historian.NewAnnotationHistorian(fakeAnnoRepo, &dashboards.FakeDashboardService{}) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, nil, &state.FakeInstanceStore{}, &image.NotAvailableImageService{}, clock.New(), hist) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, &state.FakeInstanceStore{}, &image.NotAvailableImageService{}, clock.New(), hist) |
|
|
|
|
t.Run(tc.desc, func(t *testing.T) { |
|
|
|
|
for _, res := range tc.evalResults { |
|
|
|
|
_ = st.ProcessEvalResults(context.Background(), evaluationTime, tc.alertRule, res, data.Labels{ |
|
|
|
@ -2047,7 +2047,7 @@ func TestProcessEvalResults(t *testing.T) { |
|
|
|
|
t.Run("should save state to database", func(t *testing.T) { |
|
|
|
|
instanceStore := &state.FakeInstanceStore{} |
|
|
|
|
clk := clock.New() |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, nil, instanceStore, &image.NotAvailableImageService{}, clk, &state.FakeHistorian{}) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, instanceStore, &image.NotAvailableImageService{}, clk, &state.FakeHistorian{}) |
|
|
|
|
rule := models.AlertRuleGen()() |
|
|
|
|
var results = eval.GenerateResults(rand.Intn(4)+1, eval.ResultGen(eval.WithEvaluatedAt(clk.Now()))) |
|
|
|
|
|
|
|
|
@ -2176,8 +2176,8 @@ func TestStaleResultsHandler(t *testing.T) { |
|
|
|
|
|
|
|
|
|
for _, tc := range testCases { |
|
|
|
|
ctx := context.Background() |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, dbstore, dbstore, &image.NoopImageService{}, clock.New(), &state.FakeHistorian{}) |
|
|
|
|
st.Warm(ctx) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, dbstore, &image.NoopImageService{}, clock.New(), &state.FakeHistorian{}) |
|
|
|
|
st.Warm(ctx, dbstore) |
|
|
|
|
existingStatesForRule := st.GetStatesForRuleUID(rule.OrgID, rule.UID) |
|
|
|
|
|
|
|
|
|
// We have loaded the expected number of entries from the db
|
|
|
|
@ -2238,7 +2238,7 @@ func TestStaleResults(t *testing.T) { |
|
|
|
|
clk := clock.NewMock() |
|
|
|
|
clk.Set(time.Now()) |
|
|
|
|
|
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, dbstore, dbstore, &image.NoopImageService{}, clk, &state.FakeHistorian{}) |
|
|
|
|
st := state.NewManager(testMetrics.GetStateMetrics(), nil, dbstore, &image.NoopImageService{}, clk, &state.FakeHistorian{}) |
|
|
|
|
|
|
|
|
|
orgID := rand.Int63() |
|
|
|
|
rule := tests.CreateTestAlertRule(t, ctx, dbstore, 10, orgID) |
|
|
|
|