Alerting: add state tracker to alerting evaluation (#32298)

* Initial commit for state tracking

* basic state transition logic and tests

* constructor. test and interface fixup

* use new sig for sch.definitionRoutine()

* test fixup

* make the linter happy

* more minor linting cleanup
This commit is contained in:
David Parrott
2021-03-24 15:34:18 -07:00
committed by GitHub
parent 58b814bd7d
commit d33a77a67f
6 changed files with 252 additions and 20 deletions

View File

@@ -8,6 +8,8 @@ import (
"testing"
"time"
"github.com/grafana/grafana/pkg/services/ngalert/state"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/services/ngalert/schedule"
@@ -57,8 +59,10 @@ func TestAlertingTicker(t *testing.T) {
sched := schedule.NewScheduler(schefCfg, nil)
ctx := context.Background()
st := state.NewStateTracker()
go func() {
err := sched.Ticker(ctx)
err := sched.Ticker(ctx, st)
require.NoError(t, err)
}()
runtime.Gosched()