mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-15 19:05:41 +00:00
Merge pull request #716 from prometheus/reloadtest
test: add reload test
This commit is contained in:
commit
c61a6ec8b6
@ -402,3 +402,48 @@ receivers:
|
||||
|
||||
at.Run()
|
||||
}
|
||||
|
||||
func TestReload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// We create a notification config that fans out into two different
|
||||
// webhooks.
|
||||
// The succeeding one must still only receive the first successful
|
||||
// notifications. Sending to the succeeding one must eventually succeed.
|
||||
conf := `
|
||||
route:
|
||||
receiver: "default"
|
||||
group_by: []
|
||||
group_wait: 1s
|
||||
group_interval: 6s
|
||||
repeat_interval: 10m
|
||||
|
||||
receivers:
|
||||
- name: "default"
|
||||
webhook_configs:
|
||||
- url: 'http://%s'
|
||||
`
|
||||
|
||||
at := NewAcceptanceTest(t, &AcceptanceOpts{
|
||||
Tolerance: 150 * time.Millisecond,
|
||||
})
|
||||
|
||||
co := at.Collector("webhook")
|
||||
wh := NewWebhook(co)
|
||||
|
||||
am := at.Alertmanager(fmt.Sprintf(conf, wh.Address()))
|
||||
|
||||
am.Push(At(1), Alert("alertname", "test1"))
|
||||
at.Do(At(3), am.Reload)
|
||||
am.Push(At(4), Alert("alertname", "test2"))
|
||||
|
||||
co.Want(Between(2, 2.5), Alert("alertname", "test1").Active(1))
|
||||
// Timers are reset on reload regardless, so we count the 6 second group
|
||||
// interval from 3 onwards.
|
||||
co.Want(Between(9, 9.5),
|
||||
Alert("alertname", "test1").Active(1),
|
||||
Alert("alertname", "test2").Active(4),
|
||||
)
|
||||
|
||||
at.Run()
|
||||
}
|
||||
|
@ -238,6 +238,7 @@ func NewWebhook(c *Collector) *MockWebhook {
|
||||
wh := &MockWebhook{
|
||||
listener: l,
|
||||
collector: c,
|
||||
opts: c.opts,
|
||||
}
|
||||
go http.Serve(l, wh)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user