From f20f5dce426656c1fccc83b08745b189756a5416 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Wed, 30 Sep 2015 16:18:44 +0200 Subject: [PATCH] Document example acceptance test scenario --- test/acceptance/simple_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/acceptance/simple_test.go b/test/acceptance/simple_test.go index c3dbb48b..9a229ff5 100644 --- a/test/acceptance/simple_test.go +++ b/test/acceptance/simple_test.go @@ -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() }