test

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	At         = testutils.At
	Between    = testutils.Between
	Alert      = testutils.Alert
	NewWebhook = testutils.NewWebhook
)
View Source
var CompareCollectors = testutils.CompareCollectors

Functions

func AmtoolOk

func AmtoolOk() (bool, error)

AmtoolOk verifies that the "amtool" file exists in the correct location for testing, and is a regular file.

func Version

func Version() (string, error)

Version runs the 'amtool' command with the --version option and checks for appropriate output.

Types

type AcceptanceOpts

type AcceptanceOpts = testutils.AcceptanceOpts

Re-export common types from testutils.

type AcceptanceTest

type AcceptanceTest struct {
	*testutils.AcceptanceTest
}

AcceptanceTest wraps testutils.AcceptanceTest for CLI-based testing.

func NewAcceptanceTest

func NewAcceptanceTest(t *testing.T, opts *AcceptanceOpts) *AcceptanceTest

NewAcceptanceTest returns a new acceptance test.

func (*AcceptanceTest) AlertmanagerCluster

func (t *AcceptanceTest) AlertmanagerCluster(conf string, size int) *AlertmanagerCluster

AlertmanagerCluster returns a new AlertmanagerCluster.

type Alertmanager

type Alertmanager struct {
	*testutils.Alertmanager
}

Alertmanager wraps testutils.Alertmanager and adds CLI-specific methods.

func (*Alertmanager) AddAlerts

func (am *Alertmanager) AddAlerts(omitEquals bool, alerts ...*TestAlert)

AddAlerts declares alerts that are to be added to the Alertmanager server. The omitEquals option omits alertname= from the command line args passed to amtool and instead uses the alertname value as the first argument to the command. For example `amtool alert add foo` instead of `amtool alert add alertname=foo`. This has been added to allow certain tests to test adding alerts both with and without alertname=. All other tests that use AddAlerts as a fixture can set this to false.

func (*Alertmanager) AddAlertsAt

func (am *Alertmanager) AddAlertsAt(omitEquals bool, 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) ExpireSilenceByID added in v0.30.0

func (am *Alertmanager) ExpireSilenceByID(id string) ([]byte, error)

ExpireSilenceByID expires a silence by its ID using 'amtool silence expire'.

func (*Alertmanager) ExportSilences added in v0.30.0

func (am *Alertmanager) ExportSilences() ([]byte, error)

ExportSilences exports all silences to JSON format using 'amtool silence query -o json'.

func (*Alertmanager) ImportSilences added in v0.30.0

func (am *Alertmanager) ImportSilences(filename string) ([]byte, error)

ImportSilences imports silences from a JSON file using 'amtool silence import'.

func (*Alertmanager) QueryAlerts

func (am *Alertmanager) QueryAlerts(match ...string) ([]TestAlert, error)

QueryAlerts uses the amtool cli to query alerts.

func (*Alertmanager) QueryExpiredSilence added in v0.30.0

func (am *Alertmanager) QueryExpiredSilence(match ...string) ([]TestSilence, error)

QueryExpiredSilence queries expired silences using the 'amtool silence query --expired --within' command.

func (*Alertmanager) QuerySilence

func (am *Alertmanager) QuerySilence(match ...string) ([]TestSilence, error)

QuerySilence queries the current silences using the 'amtool silence query' command.

func (*Alertmanager) SetSilence

func (am *Alertmanager) SetSilence(at float64, sil *TestSilence)

SetSilence updates or creates the given Silence.

func (*Alertmanager) ShowRoute added in v0.27.0

func (am *Alertmanager) ShowRoute() ([]byte, error)

ShowRoute shows the routing tree using 'amtool config routes show'.

func (*Alertmanager) TestRoute added in v0.27.0

func (am *Alertmanager) TestRoute(labels ...string) ([]byte, error)

TestRoute tests label matching against the routing tree using 'amtool config routes test'.

type AlertmanagerCluster

type AlertmanagerCluster struct {
	*testutils.AlertmanagerCluster
}

AlertmanagerCluster wraps testutils.AlertmanagerCluster and adds CLI-specific methods.

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 Alertmanager instances wrapped for CLI testing.

func (*AlertmanagerCluster) SetSilence

func (amc *AlertmanagerCluster) SetSilence(at float64, sil *TestSilence)

SetSilence updates or creates the given Silence.

type Collector

type Collector = testutils.Collector

Re-export common types from testutils.

type Interval

type Interval = testutils.Interval

Re-export common types and functions from testutils.

type MockWebhook

type MockWebhook = testutils.MockWebhook

Re-export common types and functions from testutils.

type TestAlert

type TestAlert = testutils.TestAlert

Re-export common types and functions from testutils.

type TestSilence

type TestSilence struct {
	// contains filtered or unexported fields
}

TestSilence models a model.Silence with relative times. This is the CLI-specific version with additional fields.

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) EndsAt added in v0.30.0

func (s *TestSilence) EndsAt() float64

EndsAt gets the silence end time.

func (*TestSilence) GetMatchREs added in v0.27.0

func (s *TestSilence) GetMatchREs() []string

GetMatchREs returns the regex matchers for the silence.

func (TestSilence) GetMatches added in v0.27.0

func (s TestSilence) GetMatches() []string

GetMatches returns the plain matchers for the silence.

func (*TestSilence) ID

func (s *TestSilence) ID() string

ID gets the silence ID.

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.

func (*TestSilence) SetID

func (s *TestSilence) SetID(ID string)

SetID sets the silence ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL