mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-26 16:12:20 +00:00
Add route tests for receiver inheritance
Tests for: - inheriting a receiver from the default route - overriding the receiver when the parent route has not set one - inheriting a receiver from a parent route that's not the default Adds a route which matches on a `group_by` label which inherits the default receiver and also has a child route, matching on an `env` label, which overrides the receiver. To be sure of edge case behaviour, we test inheriting the receiver from a child route. Hopefully no one would actually implement this edge case in reality as it's overly complex but we test anyway to be sure that it doesn't trigger unexpected behaviour.
This commit is contained in:
parent
a29860d80e
commit
aec84c0288
@ -65,6 +65,19 @@ routes:
|
||||
group_by: ['foo', 'bar']
|
||||
group_wait: 2m
|
||||
receiver: 'notify-BC'
|
||||
|
||||
- match:
|
||||
group_by: 'role'
|
||||
group_by: ['role']
|
||||
|
||||
routes:
|
||||
- match:
|
||||
env: 'testing'
|
||||
receiver: 'notify-testing'
|
||||
routes:
|
||||
- match:
|
||||
wait: 'long'
|
||||
group_wait: 2m
|
||||
`
|
||||
|
||||
var ctree config.Route
|
||||
@ -167,6 +180,51 @@ routes:
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: model.LabelSet{
|
||||
"group_by": "role",
|
||||
},
|
||||
result: []*RouteOpts{
|
||||
{
|
||||
Receiver: "notify-def",
|
||||
GroupBy: lset("role"),
|
||||
GroupWait: def.GroupWait,
|
||||
GroupInterval: def.GroupInterval,
|
||||
RepeatInterval: def.RepeatInterval,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: model.LabelSet{
|
||||
"env": "testing",
|
||||
"group_by": "role",
|
||||
},
|
||||
result: []*RouteOpts{
|
||||
{
|
||||
Receiver: "notify-testing",
|
||||
GroupBy: lset("role"),
|
||||
GroupWait: def.GroupWait,
|
||||
GroupInterval: def.GroupInterval,
|
||||
RepeatInterval: def.RepeatInterval,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
input: model.LabelSet{
|
||||
"env": "testing",
|
||||
"group_by": "role",
|
||||
"wait": "long",
|
||||
},
|
||||
result: []*RouteOpts{
|
||||
{
|
||||
Receiver: "notify-testing",
|
||||
GroupBy: lset("role"),
|
||||
GroupWait: 2 * time.Minute,
|
||||
GroupInterval: def.GroupInterval,
|
||||
RepeatInterval: def.RepeatInterval,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
Loading…
Reference in New Issue
Block a user