Alerting: Persist AlertInstance ResolvedAt & LastSentAt (#89135)
* Alerting: Persist AlertInstance ResolvedAt & LastSentAt * Fix test * Modify existing tests * Fix merge conflicts from nullable LastSentAt & ResolvedAt
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
alertingModels "github.com/grafana/alerting/models"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
@@ -840,6 +841,11 @@ func AlertInstanceGen(mutators ...AlertInstanceMutator) *AlertInstance {
|
||||
CurrentStateSince: currentStateSince,
|
||||
CurrentStateEnd: currentStateSince.Add(time.Duration(rand.Intn(100) + 200)),
|
||||
LastEvalTime: time.Now().Add(-time.Duration(rand.Intn(100) + 50)),
|
||||
LastSentAt: util.Pointer(time.Now().Add(-time.Duration(rand.Intn(100) + 50))),
|
||||
}
|
||||
|
||||
if instance.CurrentState == InstanceStateNormal && rand.Intn(2) == 1 {
|
||||
instance.ResolvedAt = util.Pointer(time.Now().Add(-time.Duration(rand.Intn(100) + 50)))
|
||||
}
|
||||
|
||||
for _, mutator := range mutators {
|
||||
|
||||
Reference in New Issue
Block a user