test: add reload test
This test reloads the Alertmanager to verify, that it properly keeps state and sends notifications correctly across reloads.
This commit is contained in:
parent
af8cfdde14
commit
ff5ecfff51
|
@ -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