From 148f4a823a94cc8c7e99115fd502fa922d26ed94 Mon Sep 17 00:00:00 2001 From: Ben Ridley Date: Fri, 29 Sep 2023 10:25:51 +1000 Subject: [PATCH] Add default time interval config to match test cases Signed-off-by: Ben Ridley --- dispatch/route_test.go | 378 +++++++++++++++++++++++------------------ 1 file changed, 216 insertions(+), 162 deletions(-) diff --git a/dispatch/route_test.go b/dispatch/route_test.go index c0a036238c..c91d47e6e8 100644 --- a/dispatch/route_test.go +++ b/dispatch/route_test.go @@ -108,12 +108,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-A", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-A", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{owner=\"team-A\"}"}, @@ -125,12 +127,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-A", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-A", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{owner=\"team-A\"}"}, @@ -141,12 +145,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-BC", - GroupBy: lset("foo", "bar"), - GroupByAll: false, - GroupWait: 2 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-BC", + GroupBy: lset("foo", "bar"), + GroupByAll: false, + GroupWait: 2 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{owner=~\"^(?:team-(B|C))$\"}"}, @@ -158,12 +164,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset(), - GroupByAll: true, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset(), + GroupByAll: true, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{owner=\"team-A\"}/{env=\"testing\"}"}, @@ -175,20 +183,24 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-productionA", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: 1 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-productionA", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: 1 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, { - Receiver: "notify-productionB", - GroupBy: lset("job"), - GroupByAll: false, - GroupWait: 30 * time.Second, - GroupInterval: 5 * time.Minute, - RepeatInterval: 1 * time.Hour, + Receiver: "notify-productionB", + GroupBy: lset("job"), + GroupByAll: false, + GroupWait: 30 * time.Second, + GroupInterval: 5 * time.Minute, + RepeatInterval: 1 * time.Hour, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{ @@ -202,12 +214,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-def", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-def", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}"}, @@ -219,12 +233,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}/{env=\"testing\"}"}, @@ -237,12 +253,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: 2 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: 2 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}/{env=\"testing\"}/{wait=\"long\"}"}, @@ -520,12 +538,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-A", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-A", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{level!=\"critical\",owner=\"team-A\"}"}, @@ -537,12 +557,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-A", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-A", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{level!=\"critical\",owner=\"team-A\"}"}, @@ -553,12 +575,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-BC", - GroupBy: lset("foo", "bar"), - GroupByAll: false, - GroupWait: 2 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-BC", + GroupBy: lset("foo", "bar"), + GroupByAll: false, + GroupWait: 2 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{owner=~\"team-(B|C)\"}"}, @@ -570,12 +594,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset(), - GroupByAll: true, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset(), + GroupByAll: true, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{level!=\"critical\",owner=\"team-A\"}/{baz!~\".*quux\",env=\"testing\"}"}, @@ -587,20 +613,24 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-productionA", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: 1 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-productionA", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: 1 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, { - Receiver: "notify-productionB", - GroupBy: lset("job"), - GroupByAll: false, - GroupWait: 30 * time.Second, - GroupInterval: 5 * time.Minute, - RepeatInterval: 1 * time.Hour, + Receiver: "notify-productionB", + GroupBy: lset("job"), + GroupByAll: false, + GroupWait: 30 * time.Second, + GroupInterval: 5 * time.Minute, + RepeatInterval: 1 * time.Hour, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{ @@ -614,12 +644,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-def", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-def", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}"}, @@ -631,12 +663,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}/{env=\"testing\"}"}, @@ -649,12 +683,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: 2 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: 2 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}/{env=\"testing\"}/{wait=\"long\"}"}, @@ -756,12 +792,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-A", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-A", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{level!=\"critical\",owner=\"team-A\"}"}, @@ -773,12 +811,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-A", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-A", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{level!=\"critical\",owner=\"team-A\"}"}, @@ -789,12 +829,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-BC", - GroupBy: lset("foo", "bar"), - GroupByAll: false, - GroupWait: 2 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-BC", + GroupBy: lset("foo", "bar"), + GroupByAll: false, + GroupWait: 2 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{owner=~\"^(?:team-(B|C))$\"}"}, @@ -806,12 +848,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset(), - GroupByAll: true, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset(), + GroupByAll: true, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{level!=\"critical\",owner=\"team-A\"}/{baz!~\".*quux\",env=\"testing\"}"}, @@ -823,20 +867,24 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-productionA", - GroupBy: def.GroupBy, - GroupByAll: false, - GroupWait: 1 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-productionA", + GroupBy: def.GroupBy, + GroupByAll: false, + GroupWait: 1 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, { - Receiver: "notify-productionB", - GroupBy: lset("job"), - GroupByAll: false, - GroupWait: 30 * time.Second, - GroupInterval: 5 * time.Minute, - RepeatInterval: 1 * time.Hour, + Receiver: "notify-productionB", + GroupBy: lset("job"), + GroupByAll: false, + GroupWait: 30 * time.Second, + GroupInterval: 5 * time.Minute, + RepeatInterval: 1 * time.Hour, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{ @@ -850,12 +898,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-def", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-def", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}"}, @@ -867,12 +917,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: def.GroupWait, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: def.GroupWait, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}/{env=\"testing\"}"}, @@ -885,12 +937,14 @@ routes: }, result: []*RouteOpts{ { - Receiver: "notify-testing", - GroupBy: lset("role"), - GroupByAll: false, - GroupWait: 2 * time.Minute, - GroupInterval: def.GroupInterval, - RepeatInterval: def.RepeatInterval, + Receiver: "notify-testing", + GroupBy: lset("role"), + GroupByAll: false, + GroupWait: 2 * time.Minute, + GroupInterval: def.GroupInterval, + RepeatInterval: def.RepeatInterval, + MuteTimeIntervals: def.MuteTimeIntervals, + ActiveTimeIntervals: def.ActiveTimeIntervals, }, }, keys: []string{"{}/{group_by=\"role\"}/{env=\"testing\"}/{wait=\"long\"}"},