diff --git a/test/acceptance/send_test.go b/test/acceptance/send_test.go index 12259c6c..1b8f4e1d 100644 --- a/test/acceptance/send_test.go +++ b/test/acceptance/send_test.go @@ -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() +} diff --git a/test/mock.go b/test/mock.go index f503f810..e06e48b3 100644 --- a/test/mock.go +++ b/test/mock.go @@ -238,6 +238,7 @@ func NewWebhook(c *Collector) *MockWebhook { wh := &MockWebhook{ listener: l, collector: c, + opts: c.opts, } go http.Serve(l, wh)