Document example acceptance test scenario
This commit is contained in:
parent
4401bb1b82
commit
f20f5dce42
|
@ -22,22 +22,35 @@ notification_configs:
|
|||
`
|
||||
|
||||
func TestSomething(t *testing.T) {
|
||||
// Create a new acceptance test that instantiates new Alertmanagers
|
||||
// with the given configuration and verifies times with the given
|
||||
// tollerance.
|
||||
at := NewAcceptanceTest(t, &AcceptanceOpts{
|
||||
Tolerance: 150 * time.Millisecond,
|
||||
Config: somethingConfig,
|
||||
})
|
||||
|
||||
// Create a new Alertmanager process listening to a random port
|
||||
am := at.Alertmanager()
|
||||
// Create a collector to which alerts can be written and verified
|
||||
// against a set of expected alert notifications.
|
||||
co := at.Collector("webhook")
|
||||
|
||||
// Run something that satisfies the webhook interface to which the
|
||||
// Alertmanager pushes as defined by its configuration.
|
||||
go NewWebhook(":8088", co).Run()
|
||||
|
||||
// Declare pushes to be made to the Alertmanager at the given time.
|
||||
// Times are provided in fractions of seconds.
|
||||
am.Push(At(1), Alert("alertname", "test").Active(1))
|
||||
am.Push(At(3.5), Alert("alertname", "test").Active(1, 3))
|
||||
|
||||
// Declare which alerts are expected to arrive at the collector within
|
||||
// the defined time intervals.
|
||||
co.Want(Between(2, 2.5), Alert("alertname", "test").Active(1))
|
||||
co.Want(Between(3, 3.5), Alert("alertname", "test").Active(1))
|
||||
co.Want(Between(3.5, 4.5), Alert("alertname", "test").Active(1, 3))
|
||||
|
||||
// Start the flow as defined above and run the checks afterwards.
|
||||
at.Run()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue