Documentation
¶
Index ¶
- func AssertExpectation(expectation Expectation, records []httpRequest) error
- func NewAlertmanagerClient(t *testing.T, alertmanagerURL *url.URL, tenantID, httpReceiverPort string) *alertmanagerClient
- func NewHTTPReceiver(t *testing.T) (*httpReceiver, error)
- func RunAlertmanagerIntegrationTest(t *testing.T, testCases []TestCase, waitTime time.Duration)
- type Alert
- type Expectation
- type TestCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertExpectation ¶
func AssertExpectation(expectation Expectation, records []httpRequest) error
AssertExpectation validates that a given expectation is present in a set of records. It does so by matching the Host and RequestURI of the expectation url against the request. The expectation.body is partially matched against the request body.
func NewAlertmanagerClient ¶
func NewAlertmanagerClient(t *testing.T, alertmanagerURL *url.URL, tenantID, httpReceiverPort string) *alertmanagerClient
NewAlertmanagerClient creates a new Mimir Alertmanager client
func NewHTTPReceiver ¶
NewHTTPReceiver creates a new HTTP receiver
func RunAlertmanagerIntegrationTest ¶
RunAlertmanagerIntegrationTest is the main entry point for running Alertmanager routes integration tests. It evaluates multiple test cases by sending all alerts at once to Alertmanager, wait for the given waitTime and then verifying the received notifications against the expectations. Each TestCase is run as a separate test (using t.Run). Various parameters are configured using flags, see other helper test files for flags definitions.
Types ¶
type Alert ¶
type Alert struct {
// Name of the Alert, should ideally be unique across all test cases
// The Name is added as "alertname" in the set of labels.
Name string
// Labels represents the set of labels representing the alert
Labels map[string]string
}
Alert represents a single alert to be sent to Alertmanager
type Expectation ¶
type Expectation struct {
// URL is a partial match for the request URL (including scheme, host, path, and query string)
URL string
// Headers is a map of expected headers and their values
Headers map[string]string
// BodyParts is a list of strings to be partially matched against the request body. All parts are ANDed
BodyParts []string
// Negate indicates whether the expectation is negated (i.e., the request should NOT be present)
Negate bool
}
Expectation represents a matcher for an expected HTTP request
type TestCase ¶
type TestCase struct {
Alert
// Expectations is the list of expectations to be validated against the received requests
Expectations []Expectation
}
TestCase represents a single alert test case with its expectations Note that all test cases are run together, meaning that all alerts are sent at once to Alertmanager before validating each TestCase expectations.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package main provides integration tests for default alertmanager routes
|
Package main provides integration tests for default alertmanager routes |
|
Package main provides integration tests for heartbeat alertmanager routes
|
Package main provides integration tests for heartbeat alertmanager routes |
|
Package main provides integration tests for pipeline-stable alertmanager routes
|
Package main provides integration tests for pipeline-stable alertmanager routes |
|
Package main provides integration tests for pipeline-stable-testing alertmanager routes
|
Package main provides integration tests for pipeline-stable-testing alertmanager routes |
|
Package main provides integration tests for pipeline-testing alertmanager routes
|
Package main provides integration tests for pipeline-testing alertmanager routes |
|
Package main provides integration tests for slack alertmanager routes
|
Package main provides integration tests for slack alertmanager routes |
|
Package main provides integration tests for ticket alertmanager routes
|
Package main provides integration tests for ticket alertmanager routes |