Copy over rule group duration on reload.

This is currently getting lost, this will soon be in a metric and we
don't want it dropping to 0 on every reload.
This commit is contained in:
Brian Brazil 2017-11-30 13:49:15 +00:00
parent aa370fa568
commit 0a42a9fc8f
2 changed files with 4 additions and 0 deletions

View File

@ -284,6 +284,8 @@ func (g *Group) offset() time.Duration {
// Rules are matched based on their name. If there are duplicates, the
// first is matched with the first, second with the second etc.
func (g *Group) copyState(from *Group) {
g.evaluationTime = from.evaluationTime
ruleMap := make(map[string][]int, len(from.rules))
for fi, fromRule := range from.rules {

View File

@ -266,6 +266,7 @@ func TestCopyState(t *testing.T) {
map[string]labels.Labels{"r3a": nil},
map[string]labels.Labels{"r3b": nil},
},
evaluationTime: time.Second,
}
oldGroup.rules[0].(*AlertingRule).active[42] = nil
newGroup := &Group{
@ -291,6 +292,7 @@ func TestCopyState(t *testing.T) {
}
testutil.Equals(t, want, newGroup.seriesInPreviousEval)
testutil.Equals(t, oldGroup.rules[0], newGroup.rules[3])
testutil.Equals(t, oldGroup.evaluationTime, newGroup.evaluationTime)
}
func TestUpdate(t *testing.T) {