Documentation ¶
Index ¶
- func AmtoolOk() (bool, error)
- func At(ts float64) float64
- func CompareCollectors(a, b *Collector, opts *AcceptanceOpts) (bool, error)
- func Version() (string, error)
- type AcceptanceOpts
- type AcceptanceTest
- type Alertmanager
- func (am *Alertmanager) AddAlerts(alerts ...*TestAlert)
- func (am *Alertmanager) AddAlertsAt(at float64, alerts ...*TestAlert)
- func (am *Alertmanager) DelSilence(at float64, sil *TestSilence)
- func (am *Alertmanager) QueryAlerts() ([]TestAlert, error)
- func (am *Alertmanager) QuerySilence() ([]TestSilence, error)
- func (am *Alertmanager) Reload()
- func (am *Alertmanager) SetSilence(at float64, sil *TestSilence)
- func (am *Alertmanager) Start(additionalArg []string) error
- func (am *Alertmanager) Terminate()
- func (am *Alertmanager) UpdateConfig(conf string)
- func (am *Alertmanager) WaitForCluster(size int) error
- type AlertmanagerCluster
- func (amc *AlertmanagerCluster) DelSilence(at float64, sil *TestSilence)
- func (amc *AlertmanagerCluster) Members() []*Alertmanager
- func (amc *AlertmanagerCluster) Reload()
- func (amc *AlertmanagerCluster) SetSilence(at float64, sil *TestSilence)
- func (amc *AlertmanagerCluster) Start() error
- func (amc *AlertmanagerCluster) Terminate()
- func (amc *AlertmanagerCluster) UpdateConfig(conf string)
- type Collector
- type Interval
- type MockWebhook
- type TestAlert
- type TestSilence
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AmtoolOk ¶
AmtoolOk verifies that the "amtool" file exists in the correct location for testing, and is a regular file.
func At ¶
At is a convenience method to allow for declarative syntax of Acceptance test definitions.
func CompareCollectors ¶
func CompareCollectors(a, b *Collector, opts *AcceptanceOpts) (bool, error)
CompareCollectors compares two collectors based on their collected alerts
Types ¶
type AcceptanceOpts ¶
type AcceptanceOpts struct { RoutePrefix string Tolerance time.Duration // contains filtered or unexported fields }
AcceptanceOpts defines configuration parameters for an acceptance test.
type AcceptanceTest ¶
AcceptanceTest provides declarative definition of given inputs and expected output of an Alertmanager setup.
func NewAcceptanceTest ¶
func NewAcceptanceTest(t *testing.T, opts *AcceptanceOpts) *AcceptanceTest
NewAcceptanceTest returns a new acceptance test with the base time set to the current time.
func (*AcceptanceTest) AlertmanagerCluster ¶
func (t *AcceptanceTest) AlertmanagerCluster(conf string, size int) *AlertmanagerCluster
AlertmanagerCluster returns a new AlertmanagerCluster that allows starting a cluster of Alertmanager instances on random ports.
func (*AcceptanceTest) Collector ¶
func (t *AcceptanceTest) Collector(name string) *Collector
Collector returns a new collector bound to the test instance.
func (*AcceptanceTest) Do ¶
func (t *AcceptanceTest) Do(at float64, f func())
Do sets the given function to be executed at the given time.
func (*AcceptanceTest) Run ¶
func (t *AcceptanceTest) Run()
Run starts all Alertmanagers and runs queries against them. It then checks whether all expected notifications have arrived at the expected receiver.
type Alertmanager ¶
type Alertmanager struct {
// contains filtered or unexported fields
}
Alertmanager encapsulates an Alertmanager process and allows declaring alerts being pushed to it at fixed points in time.
func (*Alertmanager) AddAlerts ¶
func (am *Alertmanager) AddAlerts(alerts ...*TestAlert)
AddAlerts declares alerts that are to be added to the Alertmanager server.
func (*Alertmanager) AddAlertsAt ¶
func (am *Alertmanager) AddAlertsAt(at float64, alerts ...*TestAlert)
AddAlertsAt declares alerts that are to be added to the Alertmanager server at a relative point in time.
func (*Alertmanager) DelSilence ¶
func (am *Alertmanager) DelSilence(at float64, sil *TestSilence)
DelSilence deletes the silence with the sid at the given time.
func (*Alertmanager) QueryAlerts ¶
func (am *Alertmanager) QueryAlerts() ([]TestAlert, error)
QueryAlerts uses the amtool cli to query alerts.
func (*Alertmanager) QuerySilence ¶
func (am *Alertmanager) QuerySilence() ([]TestSilence, error)
QuerySilence queries the current silences using the 'amtool silence query' command.
func (*Alertmanager) Reload ¶
func (am *Alertmanager) Reload()
Reload sends the reloading signal to the Alertmanager process.
func (*Alertmanager) SetSilence ¶
func (am *Alertmanager) SetSilence(at float64, sil *TestSilence)
SetSilence updates or creates the given Silence.
func (*Alertmanager) Start ¶
func (am *Alertmanager) Start(additionalArg []string) error
Start the alertmanager and wait until it is ready to receive.
func (*Alertmanager) Terminate ¶
func (am *Alertmanager) Terminate()
Terminate kills the underlying Alertmanager process and remove intermediate data.
func (*Alertmanager) UpdateConfig ¶
func (am *Alertmanager) UpdateConfig(conf string)
UpdateConfig rewrites the configuration file for the Alertmanager. It does not initiate config reloading.
func (*Alertmanager) WaitForCluster ¶
func (am *Alertmanager) WaitForCluster(size int) error
WaitForCluster waits for the Alertmanager instance to join a cluster with the given size.
type AlertmanagerCluster ¶
type AlertmanagerCluster struct {
// contains filtered or unexported fields
}
AlertmanagerCluster represents a group of Alertmanager instances acting as a cluster.
func (*AlertmanagerCluster) DelSilence ¶
func (amc *AlertmanagerCluster) DelSilence(at float64, sil *TestSilence)
DelSilence deletes the silence with the sid at the given time.
func (*AlertmanagerCluster) Members ¶
func (amc *AlertmanagerCluster) Members() []*Alertmanager
Members returns the underlying slice of cluster members.
func (*AlertmanagerCluster) Reload ¶
func (amc *AlertmanagerCluster) Reload()
Reload sends the reloading signal to the Alertmanager instances.
func (*AlertmanagerCluster) SetSilence ¶
func (amc *AlertmanagerCluster) SetSilence(at float64, sil *TestSilence)
SetSilence updates or creates the given Silence.
func (*AlertmanagerCluster) Start ¶
func (amc *AlertmanagerCluster) Start() error
Start the Alertmanager cluster and wait until it is ready to receive.
func (*AlertmanagerCluster) Terminate ¶
func (amc *AlertmanagerCluster) Terminate()
Terminate kills the underlying Alertmanager cluster processes and removes intermediate data.
func (*AlertmanagerCluster) UpdateConfig ¶
func (amc *AlertmanagerCluster) UpdateConfig(conf string)
UpdateConfig rewrites the configuration file for the Alertmanager cluster. It does not initiate config reloading.
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector gathers alerts received by a notification receiver and verifies whether all arrived and within the correct time boundaries.
type Interval ¶
type Interval struct {
// contains filtered or unexported fields
}
type MockWebhook ¶
type MockWebhook struct { // Func is called early on when retrieving a notification by an // Alertmanager. If Func returns true, the given notification is dropped. // See sample usage in `send_test.go/TestRetry()`. Func func(timestamp float64) bool // contains filtered or unexported fields }
func NewWebhook ¶
func NewWebhook(c *Collector) *MockWebhook
func (*MockWebhook) Address ¶
func (ws *MockWebhook) Address() string
func (*MockWebhook) ServeHTTP ¶
func (ws *MockWebhook) ServeHTTP(w http.ResponseWriter, req *http.Request)
type TestAlert ¶
type TestAlert struct {
// contains filtered or unexported fields
}
TestAlert models a model.Alert with relative times.
func Alert ¶
func Alert(keyval ...interface{}) *TestAlert
Alert creates a new alert declaration with the given key/value pairs as identifying labels.
type TestSilence ¶
type TestSilence struct {
// contains filtered or unexported fields
}
TestSilence models a model.Silence with relative times.
func Silence ¶
func Silence(start, end float64) *TestSilence
Silence creates a new TestSilence active for the relative interval given by start and end.
func (*TestSilence) Comment ¶
func (s *TestSilence) Comment(c string) *TestSilence
Comment sets the comment to the silence.
func (*TestSilence) Match ¶
func (s *TestSilence) Match(v ...string) *TestSilence
Match adds a new plain matcher to the silence.
func (*TestSilence) MatchRE ¶
func (s *TestSilence) MatchRE(v ...string) *TestSilence
MatchRE adds a new regex matcher to the silence