apptest

package
v1.125.1-cluster Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

README

App Integration Tests

The apptest package contains the integration tests for the VictoriaMetrics applications (such as vmstorage, vminsert, and vmselect).

An integration test aims at verifying the behavior of an application as a whole, as apposed to a unit test that verifies the behavior of a building block of an application.

To achieve that an integration test starts an application in a separate process and then issues HTTP requests to it and verifies the responses, examines the metrics the app exposes and/or files it creates, etc.

Note that an object of testing may be not just a single app, but several apps working together. A good example is VictoriaMetrics cluster. An integration test may reproduce an arbitrary cluster configuration and verify how the components work together as a system.

The package provides a collection of helpers to start applications and make queries to them:

  • app.go - contains the generic code for staring an application and should not be used by integration tests directly.
  • {vmstorage,vminsert,etc}.go - build on top of app.go and provide the code for staring a specific application.
  • client.go - provides helper functions for sending HTTP requests to applications.

The integration tests themselves reside in tests/*_test.go files. Apart from having the _test suffix, there are no strict rules of how to name a file, but the name should reflect the prevailing purpose of the tests located in that file. For example, sharding_test.go aims at testing data sharding.

Since integration tests start applications in a separate process, they require the application binary files to be built and put into the bin directory. The build rule used for running integration tests, make apptest, accounts for that, it builds all application binaries before running the tests. But if you want to run the tests without make, i.e. by executing go test ./app/apptest, you will need to build the binaries first (for example, by executing make all).

Not all binaries can be built from master branch, cluster binaries can be built only from cluster branch. Hence, not all test cases suitable to run in both branches:

  • If test is using binaries from cluster branch, then test name should be prefixed with TestCluster word
  • If test is using binaries from master branch, then test name should be prefixed with TestSingle word.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartVmbackup added in v1.102.23

func StartVmbackup(instance, storageDataPath, snapshotCreateURL, dst string, output io.Writer) error

StartVmbackup starts an instance of vmbackup with the given flags and waits until it exits.

func StartVmctl added in v1.102.23

func StartVmctl(instance string, flags []string, output io.Writer) error

StartVmctl starts an instance of vmctl cli with the given flags

func StartVmrestore added in v1.102.23

func StartVmrestore(instance, src, storageDataPath string, output io.Writer) error

StartVmrestore starts an instance of vmrestore with the given flags and waits until it exits.

Types

type APIV1AdminTSDBSnapshotResponse added in v1.102.18

type APIV1AdminTSDBSnapshotResponse struct {
	Status string
	Data   *SnapshotData
}

APIV1AdminTSDBSnapshotResponse is an in-memory representation of the json response returned by the /api/v1/admin/tsdb/snapshot endpoint.

type AdminTenantsResponse added in v1.102.24

type AdminTenantsResponse struct {
	Status string
	Data   []string
}

AdminTenantsResponse is an in-memory representation of the json response returned by the /api/v1/admin/tenants endpoint.

type AssertOptions added in v1.97.13

type AssertOptions struct {
	Msg        string
	Got        func() any
	Want       any
	CmpOpts    []cmp.Option
	DoNotRetry bool
	Retries    int
	Period     time.Duration
	FailNow    bool
}

AssertOptions hold the assertion params, such as got and wanted values as well as the message that should be included into the assertion error message in case of failure.

In VictoriaMetrics (especially the cluster version) the inserted data does not become visible for querying right away. Therefore, the first comparisons may fail. AssertOptions allow to configure how many times the actual result must be retrieved and compared with the expected one and for long to wait between the retries. If these two params (`Retries` and `Period`) are not set, the default values will be used.

If it is known that the data is available, then the retry functionality can be disabled by setting the `DoNotRetry` field.

AssertOptions are used by the TestCase.Assert() method, and this method uses cmp.Diff() from go-cmp package for comparing got and wanted values. AssertOptions, therefore, allows to pass cmp.Options to cmp.Diff() via `CmpOpts` field.

Finally the `FailNow` field controls whether the assertion should fail using `testing.T.Errorf()` or `testing.T.Fatalf()`.

type Client

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

Client is used for interacting with the apps over the network.

func NewClient

func NewClient() *Client

NewClient creates a new client.

func (*Client) CloseConnections

func (c *Client) CloseConnections()

CloseConnections closes client connections.

func (*Client) Delete added in v1.102.18

func (c *Client) Delete(t *testing.T, url string) (string, int)

Delete sends a HTTP DELETE request and returns the response body and status code to the caller.

func (*Client) Get

func (c *Client) Get(t *testing.T, url string) (string, int)

Get sends a HTTP GET request, returns the response body and status code to the caller.

func (*Client) Post

func (c *Client) Post(t *testing.T, url, contentType string, data []byte) (string, int)

Post sends a HTTP POST request, returns the response body and status code to the caller.

func (*Client) PostForm

func (c *Client) PostForm(t *testing.T, url string, data url.Values) (string, int)

PostForm sends a HTTP POST request containing the POST-form data, returns the response body and status code to the caller.

func (*Client) Write added in v1.102.20

func (c *Client) Write(t *testing.T, address string, data []string)

type ClusterOptions added in v1.97.15

type ClusterOptions struct {
	Vmstorage1Instance string
	Vmstorage1Binary   string
	Vmstorage1Flags    []string
	Vmstorage2Instance string
	Vmstorage2Binary   string
	Vmstorage2Flags    []string
	VminsertInstance   string
	VminsertFlags      []string
	VmselectInstance   string
	VmselectFlags      []string
}

ClusterOptions holds the params for simple cluster configuration suitable for most tests.

The cluster consists of two vmstorages, one vminsert and one vmselect, no data replication.

Such configuration is suitable for tests that don't verify the cluster-specific behavior (such as sharding, replication, or multilevel vmselect) but instead just need a typical cluster configuration to verify some business logic (such as API surface, or MetricsQL). Such cluster tests usually come paired with corresponding vmsingle tests.

type GraphiteMetricsIndexResponse added in v1.102.25

type GraphiteMetricsIndexResponse = []string

GraphiteMetricsIndexResponse is an in-memory representation of the json response returned by the /graphite/metrics/index.json endpoint.

type LogsQLQueryResponse added in v1.102.24

type LogsQLQueryResponse struct {
	LogLines []string
}

LogsQLQueryResponse is an in-memory representation of the /select/logsql/query response.

func NewLogsQLQueryResponse added in v1.102.24

func NewLogsQLQueryResponse(t *testing.T, s string) *LogsQLQueryResponse

NewLogsQLQueryResponse is a test helper function that creates a new instance of LogsQLQueryResponse by unmarshalling a json string.

type MetricNamesStatsRecord added in v1.102.16

type MetricNamesStatsRecord struct {
	MetricName         string
	QueryRequestsCount uint64
}

MetricNamesStatsRecord is a record item for MetricNamesStatsResponse

type MetricNamesStatsResponse added in v1.102.16

type MetricNamesStatsResponse struct {
	Records []MetricNamesStatsRecord
}

MetricNamesStatsResponse is an inmemory representation of the /api/v1/status/metric_names_stats API response

type PrometheusAPIV1LabelValuesResponse added in v1.102.26

type PrometheusAPIV1LabelValuesResponse struct {
	Status    string
	IsPartial bool
	Data      []string
	Trace     *Trace
	ErrorType string
	Error     string
}

PrometheusAPIV1LabelValuesResponse is an inmemory representation of the /prometheus/api/v1/labels/.../values response.

func NewPrometheusAPIV1LabelValuesResponse added in v1.102.26

func NewPrometheusAPIV1LabelValuesResponse(t *testing.T, s string) *PrometheusAPIV1LabelValuesResponse

NewPrometheusAPIV1LabelValuesResponse is a test helper function that creates a new instance of PrometheusAPIV1LabelValuesResponse by unmarshalling a json string.

type PrometheusAPIV1LabelsResponse added in v1.102.26

type PrometheusAPIV1LabelsResponse struct {
	Status    string
	IsPartial bool
	Data      []string
	Trace     *Trace
	ErrorType string
	Error     string
}

PrometheusAPIV1LabelsResponse is an inmemory representation of the /prometheus/api/v1/labels response.

func NewPrometheusAPIV1LabelsResponse added in v1.102.26

func NewPrometheusAPIV1LabelsResponse(t *testing.T, s string) *PrometheusAPIV1LabelsResponse

NewPrometheusAPIV1LabelsResponse is a test helper function that creates a new instance of PrometheusAPIV1LabelsResponse by unmarshalling a json string.

type PrometheusAPIV1QueryResponse added in v1.97.12

type PrometheusAPIV1QueryResponse struct {
	Status    string
	Data      *QueryData
	ErrorType string
	Error     string
	IsPartial bool
}

PrometheusAPIV1QueryResponse is an inmemory representation of the /prometheus/api/v1/query or /prometheus/api/v1/query_range response.

func NewPrometheusAPIV1QueryResponse added in v1.97.12

func NewPrometheusAPIV1QueryResponse(t *testing.T, s string) *PrometheusAPIV1QueryResponse

NewPrometheusAPIV1QueryResponse is a test helper function that creates a new instance of PrometheusAPIV1QueryResponse by unmarshalling a json string.

func (*PrometheusAPIV1QueryResponse) Sort added in v1.97.15

func (pqr *PrometheusAPIV1QueryResponse) Sort()

Sort performs data.Result sort by metric labels

type PrometheusAPIV1SeriesCountResponse added in v1.102.26

type PrometheusAPIV1SeriesCountResponse struct {
	Status    string
	IsPartial bool
	Data      []uint64
	Trace     *Trace
	ErrorType string
	Error     string
}

PrometheusAPIV1SeriesCountResponse is an inmemory representation of the /prometheus/api/v1/series/count response.

func NewPrometheusAPIV1SeriesCountResponse added in v1.102.26

func NewPrometheusAPIV1SeriesCountResponse(t *testing.T, s string) *PrometheusAPIV1SeriesCountResponse

NewPrometheusAPIV1SeriesCountResponse is a test helper function that creates a new instance of PrometheusAPIV1SeriesCountResponse by unmarshalling a json string.

type PrometheusAPIV1SeriesResponse

type PrometheusAPIV1SeriesResponse struct {
	Status    string
	IsPartial bool
	Data      []map[string]string
	Trace     *Trace
	ErrorType string
	Error     string
}

PrometheusAPIV1SeriesResponse is an inmemory representation of the /prometheus/api/v1/series response.

func NewPrometheusAPIV1SeriesResponse added in v1.97.12

func NewPrometheusAPIV1SeriesResponse(t *testing.T, s string) *PrometheusAPIV1SeriesResponse

NewPrometheusAPIV1SeriesResponse is a test helper function that creates a new instance of PrometheusAPIV1SeriesResponse by unmarshalling a json string.

func (*PrometheusAPIV1SeriesResponse) Sort added in v1.97.13

Sort sorts the response data.

type PrometheusQuerier added in v1.97.12

type PrometheusQuerier interface {
	PrometheusAPIV1Export(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse
	PrometheusAPIV1Query(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse
	PrometheusAPIV1QueryRange(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse
	PrometheusAPIV1Series(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1SeriesResponse
	PrometheusAPIV1SeriesCount(t *testing.T, opts QueryOpts) *PrometheusAPIV1SeriesCountResponse
	PrometheusAPIV1Labels(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1LabelsResponse
	PrometheusAPIV1LabelValues(t *testing.T, labelName, query string, opts QueryOpts) *PrometheusAPIV1LabelValuesResponse
	PrometheusAPIV1ExportNative(t *testing.T, query string, opts QueryOpts) []byte

	APIV1AdminTSDBDeleteSeries(t *testing.T, matchQuery string, opts QueryOpts)

	// TODO(@rtm0): Prometheus does not provide this API. Either move it to a
	// separate interface or rename this interface to allow for multiple querier
	// types.
	GraphiteMetricsIndex(t *testing.T, opts QueryOpts) GraphiteMetricsIndexResponse
}

PrometheusQuerier contains methods available to Prometheus-like HTTP API for Querying

type PrometheusWriteQuerier added in v1.97.13

type PrometheusWriteQuerier interface {
	Writer
	PrometheusQuerier
	StorageFlusher
	StorageMerger
}

PrometheusWriteQuerier encompasses the methods for writing, flushing and querying the data.

type QueryData added in v1.97.12

type QueryData struct {
	ResultType string
	Result     []*QueryResult
}

QueryData holds the query result along with its type.

type QueryOpts added in v1.97.12

type QueryOpts struct {
	Tenant         string
	Timeout        string
	Start          string
	End            string
	Time           string
	Step           string
	ExtraFilters   []string
	ExtraLabels    []string
	Trace          string
	ReduceMemUsage string
	MaxLookback    string
	LatencyOffset  string
	Format         string
}

QueryOpts contains various params used for querying or ingesting data

type QueryResult added in v1.97.12

type QueryResult struct {
	Metric  map[string]string
	Sample  *Sample   `json:"value"`
	Samples []*Sample `json:"values"`
}

QueryResult holds the metric name (in the form of label name-value collection) and its samples.

Sample or Samples field is set for /prometheus/api/v1/query or /prometheus/api/v1/query_range response respectively.

type Sample added in v1.97.12

type Sample struct {
	Timestamp int64
	Value     float64
}

Sample is a timeseries value at a given timestamp.

func NewSample added in v1.97.12

func NewSample(t *testing.T, timeStr string, value float64) *Sample

NewSample is a test helper function that creates a new sample out of time in RFC3339 format and a value.

func (*Sample) UnmarshalJSON added in v1.97.12

func (s *Sample) UnmarshalJSON(b []byte) error

UnmarshalJSON populates the sample fields from a JSON string.

type ServesMetrics

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

ServesMetrics is used to retrieve the app's metrics.

This type is expected to be embedded by the apps that serve metrics.

func (*ServesMetrics) GetIntMetric

func (app *ServesMetrics) GetIntMetric(t *testing.T, metricName string) int

GetIntMetric retrieves the value of a metric served by an app at /metrics URL. The value is then converted to int.

func (*ServesMetrics) GetMetric

func (app *ServesMetrics) GetMetric(t *testing.T, metricName string) float64

GetMetric retrieves the value of a metric served by an app at /metrics URL.

func (*ServesMetrics) GetMetricsByPrefix added in v1.97.13

func (app *ServesMetrics) GetMetricsByPrefix(t *testing.T, prefix string) []float64

GetMetricsByPrefix retrieves the values of all metrics that start with given prefix.

func (*ServesMetrics) GetMetricsByRegexp added in v1.110.16

func (app *ServesMetrics) GetMetricsByRegexp(t *testing.T, re *regexp.Regexp) []float64

type SnapshotCreateResponse added in v1.102.18

type SnapshotCreateResponse struct {
	Status   string
	Snapshot string
}

SnapshotCreateResponse is an in-memory representation of the json response returned by the /snapshot/create endpoint.

type SnapshotData added in v1.102.18

type SnapshotData struct {
	Name string
}

SnapshotData holds the info about the snapshot created via /api/v1/admin/tsdb/snapshot endpoint.

type SnapshotDeleteAllResponse added in v1.102.18

type SnapshotDeleteAllResponse struct {
	Status string
}

SnapshotDeleteAllResponse is an in-memory representation of the json response returned by the /snapshot/delete_all endpoint.

type SnapshotDeleteResponse added in v1.102.18

type SnapshotDeleteResponse struct {
	Status string
	Msg    string
}

SnapshotDeleteResponse is an in-memory representation of the json response returned by the /snapshot/delete endpoint.

type SnapshotListResponse added in v1.102.18

type SnapshotListResponse struct {
	Status    string
	Snapshots []string
}

SnapshotListResponse is an in-memory representation of the json response returned by the /snapshot/list endpoint.

type Stopper added in v1.97.12

type Stopper interface {
	Stop()
}

Stopper is an interface of objects that needs to be stopped via Stop() call

type StorageFlusher added in v1.97.13

type StorageFlusher interface {
	ForceFlush(t *testing.T)
}

StorageFlusher defines a method that forces the flushing of data inserted into the storage, so it becomes available for searching immediately.

type StorageMerger added in v1.102.17

type StorageMerger interface {
	ForceMerge(t *testing.T)
}

StorageMerger defines a method that forces the merging of data inserted into the storage.

type TSDBStatusResponse added in v1.102.19

type TSDBStatusResponse struct {
	IsPartial bool
	Data      TSDBStatusResponseData
}

TSDBStatusResponse is an in-memory representation of the json response returned by the /prometheus/api/v1/status/tsdb endpoint.

func (*TSDBStatusResponse) Sort added in v1.102.19

func (tsr *TSDBStatusResponse) Sort()

Sort performs sorting of stats entries

type TSDBStatusResponseData added in v1.102.19

type TSDBStatusResponseData struct {
	TotalSeries                  int
	TotalLabelValuePairs         int
	SeriesCountByMetricName      []TSDBStatusResponseMetricNameEntry
	SeriesCountByLabelName       []TSDBStatusResponseEntry
	SeriesCountByFocusLabelValue []TSDBStatusResponseEntry
	SeriesCountByLabelValuePair  []TSDBStatusResponseEntry
	LabelValueCountByLabelName   []TSDBStatusResponseEntry
}

TSDBStatusResponseData is a part of TSDBStatusResponse

type TSDBStatusResponseEntry added in v1.102.19

type TSDBStatusResponseEntry struct {
	Name  string
	Count int
}

TSDBStatusResponseEntry defines stats entry for TSDBStatusResponseData

type TSDBStatusResponseMetricNameEntry added in v1.102.19

type TSDBStatusResponseMetricNameEntry struct {
	Name                 string
	Count                int
	RequestsCount        int
	LastRequestTimestamp int
}

TSDBStatusResponseMetricNameEntry defines metric names stats entry for TSDBStatusResponseData

type TestCase

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

TestCase holds the state and defines clean-up procedure common for all test cases.

func NewTestCase

func NewTestCase(t *testing.T) *TestCase

NewTestCase creates a new test case.

func (*TestCase) Assert added in v1.97.13

func (tc *TestCase) Assert(opts *AssertOptions)

Assert compares the actual result with the expected one possibly multiple times in order to account for the fact that the inserted data does not become available for querying right away (especially in cluster version of VictoriaMetrics).

func (*TestCase) Client

func (tc *TestCase) Client() *Client

Client returns an instance of the client that can be used for interacting with the app(s) under test.

func (*TestCase) Dir

func (tc *TestCase) Dir() string

Dir returns the directory name that should be used by as the -storageDataDir.

func (*TestCase) ForceFlush added in v1.97.14

func (tc *TestCase) ForceFlush(apps ...*Vmstorage)

ForceFlush flushes zero or more storages.

func (*TestCase) MustStartCluster added in v1.97.15

func (tc *TestCase) MustStartCluster(opts *ClusterOptions) *Vmcluster

MustStartCluster starts a typical cluster configuration with custom flags.

func (*TestCase) MustStartDefaultCluster added in v1.97.13

func (tc *TestCase) MustStartDefaultCluster() *Vmcluster

MustStartDefaultCluster starts a typical cluster configuration with default flags.

func (*TestCase) MustStartDefaultVmsingle added in v1.97.13

func (tc *TestCase) MustStartDefaultVmsingle() *Vmsingle

MustStartDefaultVmsingle is a test helper function that starts an instance of vmsingle with defaults suitable for most tests.

func (*TestCase) MustStartVmagent added in v1.102.19

func (tc *TestCase) MustStartVmagent(instance string, flags []string, promScrapeConfigFileYAML string) *Vmagent

MustStartVmagent is a test helper function that starts an instance of vmagent and fails the test if the app fails to start.

func (*TestCase) MustStartVmauth added in v1.102.13

func (tc *TestCase) MustStartVmauth(instance string, flags []string, configFileYAML string) *Vmauth

MustStartVmauth is a test helper function that starts an instance of vmauth and fails the test if the app fails to start.

func (*TestCase) MustStartVmbackup added in v1.102.23

func (tc *TestCase) MustStartVmbackup(instance, storageDataPath, snapshotCreateURL, dst string)

MustStartVmbackup is a test helper that starts an instance of vmbackup and waits until the app exits. It fails the test if the app fails to start or exits with non zero code.

func (*TestCase) MustStartVmctl added in v1.102.23

func (tc *TestCase) MustStartVmctl(instance string, flags []string)

MustStartVmctl is a test helper function that starts an instance of vmctl

func (*TestCase) MustStartVminsert added in v1.97.12

func (tc *TestCase) MustStartVminsert(instance string, flags []string) *Vminsert

MustStartVminsert is a test helper function that starts an instance of vminsert and fails the test if the app fails to start.

func (*TestCase) MustStartVmrestore added in v1.102.23

func (tc *TestCase) MustStartVmrestore(instance, src, storageDataPath string)

MustStartVmrestore is a test helper that starts an instance of vmrestore and waits until the app exits. It fails the test if the app fails to start or exits with non zero code.

func (*TestCase) MustStartVmselect added in v1.97.12

func (tc *TestCase) MustStartVmselect(instance string, flags []string) *Vmselect

MustStartVmselect is a test helper function that starts an instance of vmselect and fails the test if the app fails to start.

func (*TestCase) MustStartVmsingle added in v1.97.12

func (tc *TestCase) MustStartVmsingle(instance string, flags []string) *Vmsingle

MustStartVmsingle is a test helper function that starts an instance of vmsingle located at ../../bin/victoria-metrics and fails the test if the app fails to start.

func (*TestCase) MustStartVmsingleAt added in v1.102.26

func (tc *TestCase) MustStartVmsingleAt(instance, binary string, flags []string) *Vmsingle

MustStartVmsingleAt is a test helper function that starts an instance of vmsingle and fails the test if the app fails to start.

func (*TestCase) MustStartVmstorage added in v1.97.12

func (tc *TestCase) MustStartVmstorage(instance string, flags []string) *Vmstorage

MustStartVmstorage is a test helper function that starts an instance of vmstorage located at ../../bin/vmstorage and fails the test if the app fails to start.

func (*TestCase) MustStartVmstorageAt added in v1.102.26

func (tc *TestCase) MustStartVmstorageAt(instance string, binary string, flags []string) *Vmstorage

MustStartVmstorageAt is a test helper function that starts an instance of vmstorage and fails the test if the app fails to start.

func (*TestCase) Stop added in v1.97.12

func (tc *TestCase) Stop()

Stop performs the test case clean up, such as closing all client connections and removing the -storageDataDir directory.

Note that the -storageDataDir is not removed in case of test case failure to allow for further manual debugging.

func (*TestCase) StopApp added in v1.97.14

func (tc *TestCase) StopApp(instance string)

StopApp stops the app identified by the `instance` name and removes it from the collection of started apps.

func (*TestCase) StopPrometheusWriteQuerier added in v1.102.14

func (tc *TestCase) StopPrometheusWriteQuerier(pwq PrometheusWriteQuerier)

StopPrometheusWriteQuerier stop all apps that are a part of the pwq.

func (*TestCase) T added in v1.97.14

func (tc *TestCase) T() *testing.T

T returns the test state.

type Trace added in v1.97.14

type Trace struct {
	DurationMsec float64 `json:"duration_msec"`
	Message      string
	Children     []*Trace
}

Trace provides the description and the duration of some unit of work that has been performed during the request processing.

func (*Trace) Contains added in v1.97.14

func (t *Trace) Contains(s string) int

Contains counts how many trace messages contain substring s.

func (*Trace) String added in v1.97.14

func (t *Trace) String() string

String returns string representation of the trace.

type Vmagent added in v1.102.19

type Vmagent struct {
	*ServesMetrics
	// contains filtered or unexported fields
}

Vmagent holds the state of a vmagent app and provides vmagent-specific functions

func StartVmagent added in v1.102.19

func StartVmagent(instance string, flags []string, cli *Client, promScrapeConfigFilePath string, output io.Writer) (*Vmagent, error)

StartVmagent starts an instance of vmagent with the given flags. It also sets the default flags and populates the app instance state with runtime values extracted from the application log (such as httpListenAddr)

func (*Vmagent) APIV1ImportPrometheus added in v1.102.19

func (app *Vmagent) APIV1ImportPrometheus(t *testing.T, records []string, opts QueryOpts)

APIV1ImportPrometheus is a test helper function that inserts a collection of records in Prometheus text exposition format for the given tenant by sending a HTTP POST request to /api/v1/import/prometheus vmagent endpoint.

The call is blocked until the data is flushed to vmstorage or the timeout is reached.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1importprometheus

func (*Vmagent) APIV1ImportPrometheusNoWaitFlush added in v1.102.19

func (app *Vmagent) APIV1ImportPrometheusNoWaitFlush(t *testing.T, records []string, _ QueryOpts)

APIV1ImportPrometheusNoWaitFlush is a test helper function that inserts a collection of records in Prometheus text exposition format for the given tenant by sending a HTTP POST request to /api/v1/import/prometheus vmagent endpoint.

The call accepts the records but does not guarantee successful flush to vmstorage. Flushing may still be in progress on the function return.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1importprometheus

func (Vmagent) Name added in v1.102.19

func (app Vmagent) Name() string

Name returns the application instance name.

func (*Vmagent) ReloadRelabelConfigs added in v1.102.24

func (app *Vmagent) ReloadRelabelConfigs(t *testing.T)

ReloadRelabelConfigs sends SIGHUP to trigger relabel config reload and waits until vmagent_relabel_config_reloads_total increases. Fails the test if no reload is detected within 3 seconds.

func (*Vmagent) RemoteWritePacketsDroppedTotal added in v1.102.19

func (app *Vmagent) RemoteWritePacketsDroppedTotal(t *testing.T) int

RemoteWritePacketsDroppedTotal sums up the total number of dropped remote write packets.

func (*Vmagent) RemoteWritePendingInmemoryBlocks added in v1.110.16

func (app *Vmagent) RemoteWritePendingInmemoryBlocks(t *testing.T, url string) int

RemoteWritePendingInmemoryBlocks sums up the total number of pending in-memory blocks for given remote write URL.

func (*Vmagent) RemoteWriteRequests added in v1.110.16

func (app *Vmagent) RemoteWriteRequests(t *testing.T, url string) int

RemoteWriteRequests sums up the total number of sending requests for given remote write URL.

func (*Vmagent) RemoteWriteRequestsRetriesCountTotal added in v1.102.19

func (app *Vmagent) RemoteWriteRequestsRetriesCountTotal(t *testing.T) int

RemoteWriteRequestsRetriesCountTotal sums up the total retries for remote write requests.

func (*Vmagent) RemoteWriteSamplesDropped added in v1.110.16

func (app *Vmagent) RemoteWriteSamplesDropped(t *testing.T, url string) int

RemoteWriteSamplesDropped sums up the total number of dropped remote write samples for given remote write URL.

func (Vmagent) Stop added in v1.102.19

func (app Vmagent) Stop()

Stop sends the app process a SIGINT signal and waits until it terminates gracefully.

func (Vmagent) String added in v1.102.19

func (app Vmagent) String() string

String returns the string representation of the app state.

type Vmauth added in v1.102.13

type Vmauth struct {
	*ServesMetrics
	// contains filtered or unexported fields
}

Vmauth holds the state of a vmauth app and provides vmauth-specific functions.

func StartVmauth added in v1.102.13

func StartVmauth(instance string, flags []string, cli *Client, configFilePath string, output io.Writer) (*Vmauth, error)

StartVmauth starts an instance of vmauth with the given flags. It also sets the default flags and populates the app instance state with runtime values extracted from the application log (such as httpListenAddr)

func (*Vmauth) GetHTTPListenAddr added in v1.102.13

func (app *Vmauth) GetHTTPListenAddr() string

GetHTTPListenAddr returns listen http addr

func (Vmauth) Name added in v1.102.13

func (app Vmauth) Name() string

Name returns the application instance name.

func (Vmauth) Stop added in v1.102.13

func (app Vmauth) Stop()

Stop sends the app process a SIGINT signal and waits until it terminates gracefully.

func (Vmauth) String added in v1.102.13

func (app Vmauth) String() string

String returns the string representation of the app state.

func (*Vmauth) UpdateConfiguration added in v1.102.13

func (app *Vmauth) UpdateConfiguration(t *testing.T, configFileYAML string)

UpdateConfiguration updates the vmauth configuration file with the provided YAML content, sends SIGHUP to trigger config reload and waits until vmauth_config_last_reload_total increases. Fails the test if no reload is detected within 2 seconds.

type Vmcluster added in v1.102.14

type Vmcluster struct {
	*Vminsert
	*Vmselect
	Vmstorages []*Vmstorage
}

Vmcluster represents a typical cluster setup: several vmstorage replicas, one vminsert, and one vmselect.

Both Vmsingle and Vmcluster implement the PrometheusWriteQuerier used in business logic tests to abstract out the infrastructure.

This type is not suitable for infrastructure tests where custom cluster setups are often required.

func (*Vmcluster) ForceFlush added in v1.102.14

func (c *Vmcluster) ForceFlush(t *testing.T)

ForceFlush forces the ingested data to become visible for searching immediately.

func (*Vmcluster) ForceMerge added in v1.102.17

func (c *Vmcluster) ForceMerge(t *testing.T)

ForceMerge is a test helper function that forces the merging of parts.

type Vminsert

type Vminsert struct {
	*ServesMetrics
	// contains filtered or unexported fields
}

Vminsert holds the state of a vminsert app and provides vminsert-specific functions.

func StartVminsert

func StartVminsert(instance string, flags []string, cli *Client, output io.Writer) (*Vminsert, error)

StartVminsert starts an instance of vminsert with the given flags. It also sets the default flags and populates the app instance state with runtime values extracted from the application log (such as httpListenAddr)

func (*Vminsert) ClusternativeListenAddr added in v1.97.14

func (app *Vminsert) ClusternativeListenAddr() string

ClusternativeListenAddr returns the address at which the vminsert process is listening for connections from other vminsert apps.

func (*Vminsert) GraphiteWrite added in v1.102.20

func (app *Vminsert) GraphiteWrite(t *testing.T, records []string, _ QueryOpts)

GraphiteWrite is a test helper function that sends a collection of records to graphiteListenAddr port.

See https://docs.victoriametrics.com/victoriametrics/integrations/graphite/#ingesting

func (*Vminsert) HTTPAddr added in v1.102.23

func (app *Vminsert) HTTPAddr() string

HTTPAddr returns the address at which the vminsert process is listening for incoming HTTP requests.

func (*Vminsert) InfluxWrite added in v1.97.15

func (app *Vminsert) InfluxWrite(t *testing.T, records []string, opts QueryOpts)

InfluxWrite is a test helper function that inserts a collection of records in Influx line format by sending a HTTP POST request to /influx/write vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#influxwrite

func (Vminsert) Name added in v1.97.14

func (app Vminsert) Name() string

Name returns the application instance name.

func (*Vminsert) OpenTSDBAPIPut added in v1.102.20

func (app *Vminsert) OpenTSDBAPIPut(t *testing.T, records []string, opts QueryOpts)

OpenTSDBAPIPut is a test helper function that inserts a collection of records in OpenTSDB format for the given tenant by sending an HTTP POST request to /opentsdb/api/put vminsert endpoint.

See https://docs.victoriametrics.com/cluster-victoriametrics/#url-format

func (*Vminsert) PrometheusAPIV1ImportCSV added in v1.102.20

func (app *Vminsert) PrometheusAPIV1ImportCSV(t *testing.T, records []string, opts QueryOpts)

PrometheusAPIV1ImportCSV is a test helper function that inserts a collection of records in CSV format for the given tenant by sending an HTTP POST request to prometheus/api/v1/import/csv vminsert endpoint.

See https://docs.victoriametrics.com/cluster-victoriametrics/#url-format

func (*Vminsert) PrometheusAPIV1ImportNative added in v1.102.23

func (app *Vminsert) PrometheusAPIV1ImportNative(t *testing.T, data []byte, opts QueryOpts)

PrometheusAPIV1ImportNative is a test helper function that inserts a collection of records in Native format for the given tenant by sending an HTTP POST request to prometheus/api/v1/import/native vminsert endpoint.

See https://docs.victoriametrics.com/cluster-victoriametrics/#url-format

func (*Vminsert) PrometheusAPIV1ImportPrometheus

func (app *Vminsert) PrometheusAPIV1ImportPrometheus(t *testing.T, records []string, opts QueryOpts)

PrometheusAPIV1ImportPrometheus is a test helper function that inserts a collection of records in Prometheus text exposition format for the given tenant by sending a HTTP POST request to /prometheus/api/v1/import/prometheus vminsert endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1importprometheus

func (*Vminsert) PrometheusAPIV1Write added in v1.97.13

func (app *Vminsert) PrometheusAPIV1Write(t *testing.T, records []prompb.TimeSeries, opts QueryOpts)

PrometheusAPIV1Write is a test helper function that inserts a collection of records in Prometheus remote-write format by sending a HTTP POST request to /prometheus/api/v1/write vminsert endpoint.

func (Vminsert) Stop

func (app Vminsert) Stop()

Stop sends the app process a SIGINT signal and waits until it terminates gracefully.

func (*Vminsert) String

func (app *Vminsert) String() string

String returns the string representation of the vminsert app state.

type Vmselect

type Vmselect struct {
	*ServesMetrics
	// contains filtered or unexported fields
}

Vmselect holds the state of a vmselect app and provides vmselect-specific functions.

func StartVmselect

func StartVmselect(instance string, flags []string, cli *Client, output io.Writer) (*Vmselect, error)

StartVmselect starts an instance of vmselect with the given flags. It also sets the default flags and populates the app instance state with runtime values extracted from the application log (such as httpListenAddr)

func (*Vmselect) APIV1AdminTSDBDeleteSeries added in v1.102.26

func (app *Vmselect) APIV1AdminTSDBDeleteSeries(t *testing.T, matchQuery string, opts QueryOpts)

APIV1AdminTSDBDeleteSeries deletes the series that match the query by sending a request to /api/v1/admin/tsdb/delete_series.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1admintsdbdelete_series

func (*Vmselect) APIV1AdminTenants added in v1.102.24

func (app *Vmselect) APIV1AdminTenants(t *testing.T) *AdminTenantsResponse

APIV1AdminTenants sends a query to a /admin/tenants endpoint

func (*Vmselect) APIV1StatusTSDB added in v1.102.19

func (app *Vmselect) APIV1StatusTSDB(t *testing.T, matchQuery string, date string, topN string, opts QueryOpts) TSDBStatusResponse

APIV1StatusTSDB sends a query to a /prometheus/api/v1/status/tsdb // See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#tsdb-stats

func (*Vmselect) ClusternativeListenAddr

func (app *Vmselect) ClusternativeListenAddr() string

ClusternativeListenAddr returns the address at which the vmselect process is listening for connections from other vmselect apps.

func (*Vmselect) GraphiteMetricsIndex added in v1.102.25

func (app *Vmselect) GraphiteMetricsIndex(t *testing.T, opts QueryOpts) GraphiteMetricsIndexResponse

GraphiteMetricsIndex sends a query to a /graphite/metrics/index.json

See https://docs.victoriametrics.com/victoriametrics/integrations/graphite/#metrics-api

func (*Vmselect) HTTPAddr added in v1.102.24

func (app *Vmselect) HTTPAddr() string

HTTPAddr returns the address at which the vmselect process is listening for incoming HTTP requests.

func (*Vmselect) MetricNamesStats added in v1.102.16

func (app *Vmselect) MetricNamesStats(t *testing.T, limit, le, matchPattern string, opts QueryOpts) MetricNamesStatsResponse

MetricNamesStats sends a query to a /select/tenant/prometheus/api/v1/status/metric_names_stats endpoint and returns the statistics response for given params.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#track-ingested-metrics-usage

func (*Vmselect) MetricNamesStatsReset added in v1.102.16

func (app *Vmselect) MetricNamesStatsReset(t *testing.T, opts QueryOpts)

MetricNamesStatsReset sends a query to a /admin/api/v1/status/metric_names_stats/reset endpoint

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#track-ingested-metrics-usage

func (Vmselect) Name added in v1.97.14

func (app Vmselect) Name() string

Name returns the application instance name.

func (*Vmselect) PrometheusAPIV1Export added in v1.97.13

func (app *Vmselect) PrometheusAPIV1Export(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse

PrometheusAPIV1Export is a test helper function that performs the export of raw samples in JSON line format by sending a HTTP POST request to /prometheus/api/v1/export vmselect endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1export

func (*Vmselect) PrometheusAPIV1ExportNative added in v1.102.23

func (app *Vmselect) PrometheusAPIV1ExportNative(t *testing.T, query string, opts QueryOpts) []byte

PrometheusAPIV1ExportNative is a test helper function that performs the export of raw samples in native binary format by sending an HTTP POST request to /prometheus/api/v1/export/native vmselect endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1exportnative

func (*Vmselect) PrometheusAPIV1LabelValues added in v1.102.26

func (app *Vmselect) PrometheusAPIV1LabelValues(t *testing.T, labelName, matchQuery string, opts QueryOpts) *PrometheusAPIV1LabelValuesResponse

PrometheusAPIV1LabelValues sends a query to a /prometheus/api/v1/label/.../values endpoint and returns the label names list of time series that match the query.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1labelvalues

func (*Vmselect) PrometheusAPIV1Labels added in v1.102.26

func (app *Vmselect) PrometheusAPIV1Labels(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1LabelsResponse

PrometheusAPIV1Labels sends a query to a /prometheus/api/v1/labels endpoint and returns the label names list of time series that match the query.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1labels

func (*Vmselect) PrometheusAPIV1Query added in v1.97.12

func (app *Vmselect) PrometheusAPIV1Query(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse

PrometheusAPIV1Query is a test helper function that performs PromQL/MetricsQL instant query by sending a HTTP POST request to /prometheus/api/v1/query vmselect endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1query

func (*Vmselect) PrometheusAPIV1QueryRange added in v1.97.12

func (app *Vmselect) PrometheusAPIV1QueryRange(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse

PrometheusAPIV1QueryRange is a test helper function that performs PromQL/MetricsQL range query by sending a HTTP POST request to /prometheus/api/v1/query_range vmselect endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1query_range

func (*Vmselect) PrometheusAPIV1Series

func (app *Vmselect) PrometheusAPIV1Series(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1SeriesResponse

PrometheusAPIV1Series sends a query to a /prometheus/api/v1/series endpoint and returns the list of time series that match the query.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1series

func (*Vmselect) PrometheusAPIV1SeriesCount added in v1.102.26

func (app *Vmselect) PrometheusAPIV1SeriesCount(t *testing.T, opts QueryOpts) *PrometheusAPIV1SeriesCountResponse

PrometheusAPIV1SeriesCount sends a query to a /prometheus/api/v1/series/count endpoint and returns the total number of time series.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1series

func (Vmselect) Stop

func (app Vmselect) Stop()

Stop sends the app process a SIGINT signal and waits until it terminates gracefully.

func (*Vmselect) String

func (app *Vmselect) String() string

String returns the string representation of the vmselect app state.

type Vmsingle added in v1.97.12

type Vmsingle struct {
	*ServesMetrics
	// contains filtered or unexported fields
}

Vmsingle holds the state of a vmsingle app and provides vmsingle-specific functions.

func StartVmsingleAt added in v1.102.26

func StartVmsingleAt(instance, binary string, flags []string, cli *Client, output io.Writer) (*Vmsingle, error)

StartVmsingleAt starts an instance of vmsingle with the given flags. It also sets the default flags and populates the app instance state with runtime values extracted from the application log (such as httpListenAddr).

func (*Vmsingle) APIV1AdminStatusMetricNamesStatsReset added in v1.102.16

func (app *Vmsingle) APIV1AdminStatusMetricNamesStatsReset(t *testing.T, opts QueryOpts)

APIV1AdminStatusMetricNamesStatsReset sends a query to a /api/v1/admin/status/metric_names_stats/reset endpoint

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#track-ingested-metrics-usage

func (*Vmsingle) APIV1AdminTSDBDeleteSeries added in v1.102.26

func (app *Vmsingle) APIV1AdminTSDBDeleteSeries(t *testing.T, matchQuery string, opts QueryOpts)

APIV1AdminTSDBDeleteSeries deletes the series that match the query by sending a request to /api/v1/admin/tsdb/delete_series.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1admintsdbdelete_series

func (*Vmsingle) APIV1AdminTSDBSnapshot added in v1.102.18

func (app *Vmsingle) APIV1AdminTSDBSnapshot(t *testing.T) *APIV1AdminTSDBSnapshotResponse

APIV1AdminTSDBSnapshot creates a database snapshot by sending a query to the /api/v1/admin/tsdb/snapshot endpoint.

See https://prometheus.io/docs/prometheus/latest/querying/api/#snapshot.

func (*Vmsingle) APIV1StatusMetricNamesStats added in v1.102.16

func (app *Vmsingle) APIV1StatusMetricNamesStats(t *testing.T, limit, le, matchPattern string, opts QueryOpts) MetricNamesStatsResponse

APIV1StatusMetricNamesStats sends a query to a /api/v1/status/metric_names_stats endpoint and returns the statistics response for given params.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#track-ingested-metrics-usage

func (*Vmsingle) APIV1StatusTSDB added in v1.102.19

func (app *Vmsingle) APIV1StatusTSDB(t *testing.T, matchQuery string, date string, topN string, opts QueryOpts) TSDBStatusResponse

APIV1StatusTSDB sends a query to a /prometheus/api/v1/status/tsdb // See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#tsdb-stats

func (*Vmsingle) ForceFlush added in v1.97.12

func (app *Vmsingle) ForceFlush(t *testing.T)

ForceFlush is a test helper function that forces the flushing of inserted data, so it becomes available for searching immediately.

func (*Vmsingle) ForceMerge added in v1.102.17

func (app *Vmsingle) ForceMerge(t *testing.T)

ForceMerge is a test helper function that forces the merging of parts.

func (*Vmsingle) GraphiteMetricsIndex added in v1.102.25

func (app *Vmsingle) GraphiteMetricsIndex(t *testing.T, _ QueryOpts) GraphiteMetricsIndexResponse

GraphiteMetricsIndex sends a query to a /metrics/index.json

See https://docs.victoriametrics.com/victoriametrics/integrations/graphite/#metrics-api

func (*Vmsingle) GraphiteWrite added in v1.102.20

func (app *Vmsingle) GraphiteWrite(t *testing.T, records []string, _ QueryOpts)

GraphiteWrite is a test helper function that sends a collection of records to graphiteListenAddr port.

See https://docs.victoriametrics.com/victoriametrics/integrations/graphite/#ingesting

func (*Vmsingle) HTTPAddr added in v1.102.19

func (app *Vmsingle) HTTPAddr() string

HTTPAddr returns the address at which the vmstorage process is listening for http connections.

func (*Vmsingle) InfluxWrite added in v1.97.15

func (app *Vmsingle) InfluxWrite(t *testing.T, records []string, opts QueryOpts)

InfluxWrite is a test helper function that inserts a collection of records in Influx line format by sending a HTTP POST request to /influx/write vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#influxwrite

func (Vmsingle) Name added in v1.97.14

func (app Vmsingle) Name() string

Name returns the application instance name.

func (*Vmsingle) OpenTSDBAPIPut added in v1.102.20

func (app *Vmsingle) OpenTSDBAPIPut(t *testing.T, records []string, opts QueryOpts)

OpenTSDBAPIPut is a test helper function that inserts a collection of records in OpenTSDB format for the given tenant by sending an HTTP POST request to /api/put vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/integrations/opentsdb/#sending-data-via-http

func (*Vmsingle) PrometheusAPIV1Export added in v1.97.13

func (app *Vmsingle) PrometheusAPIV1Export(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse

PrometheusAPIV1Export is a test helper function that performs the export of raw samples in JSON line format by sending a HTTP POST request to /prometheus/api/v1/export vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1export

func (*Vmsingle) PrometheusAPIV1ExportNative added in v1.102.23

func (app *Vmsingle) PrometheusAPIV1ExportNative(t *testing.T, query string, opts QueryOpts) []byte

PrometheusAPIV1ExportNative is a test helper function that performs the export of raw samples in native binary format by sending an HTTP POST request to /prometheus/api/v1/export/native vmselect endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1exportnative

func (*Vmsingle) PrometheusAPIV1ImportCSV added in v1.102.20

func (app *Vmsingle) PrometheusAPIV1ImportCSV(t *testing.T, records []string, opts QueryOpts)

PrometheusAPIV1ImportCSV is a test helper function that inserts a collection of records in CSV format for the given tenant by sending an HTTP POST request to /api/v1/import/csv vmsingle endpoint.

See https://docs.victoriametrics.com/single-server-victoriametrics/#how-to-import-csv-data

func (*Vmsingle) PrometheusAPIV1ImportNative added in v1.102.23

func (app *Vmsingle) PrometheusAPIV1ImportNative(t *testing.T, data []byte, opts QueryOpts)

PrometheusAPIV1ImportNative is a test helper function that inserts a collection of records in native format for the given tenant by sending an HTTP POST request to /api/v1/import/native vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-import-data-in-native-format

func (*Vmsingle) PrometheusAPIV1ImportPrometheus added in v1.97.12

func (app *Vmsingle) PrometheusAPIV1ImportPrometheus(t *testing.T, records []string, opts QueryOpts)

PrometheusAPIV1ImportPrometheus is a test helper function that inserts a collection of records in Prometheus text exposition format by sending a HTTP POST request to /prometheus/api/v1/import/prometheus vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1importprometheus

func (*Vmsingle) PrometheusAPIV1LabelValues added in v1.102.26

func (app *Vmsingle) PrometheusAPIV1LabelValues(t *testing.T, labelName, matchQuery string, opts QueryOpts) *PrometheusAPIV1LabelValuesResponse

PrometheusAPIV1LabelValues sends a query to a /prometheus/api/v1/label/.../values endpoint and returns the label names list of time series that match the query.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1labelvalues

func (*Vmsingle) PrometheusAPIV1Labels added in v1.102.26

func (app *Vmsingle) PrometheusAPIV1Labels(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1LabelsResponse

PrometheusAPIV1Labels sends a query to a /prometheus/api/v1/labels endpoint and returns the label names list of time series that match the query.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1labels

func (*Vmsingle) PrometheusAPIV1Query added in v1.97.12

func (app *Vmsingle) PrometheusAPIV1Query(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse

PrometheusAPIV1Query is a test helper function that performs PromQL/MetricsQL instant query by sending a HTTP POST request to /prometheus/api/v1/query vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1query

func (*Vmsingle) PrometheusAPIV1QueryRange added in v1.97.12

func (app *Vmsingle) PrometheusAPIV1QueryRange(t *testing.T, query string, opts QueryOpts) *PrometheusAPIV1QueryResponse

PrometheusAPIV1QueryRange is a test helper function that performs PromQL/MetricsQL range query by sending a HTTP POST request to /prometheus/api/v1/query_range vmsingle endpoint.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1query_range

func (*Vmsingle) PrometheusAPIV1Series added in v1.97.12

func (app *Vmsingle) PrometheusAPIV1Series(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1SeriesResponse

PrometheusAPIV1Series sends a query to a /prometheus/api/v1/series endpoint and returns the list of time series that match the query.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1series

func (*Vmsingle) PrometheusAPIV1SeriesCount added in v1.102.26

func (app *Vmsingle) PrometheusAPIV1SeriesCount(t *testing.T, opts QueryOpts) *PrometheusAPIV1SeriesCountResponse

PrometheusAPIV1SeriesCount sends a query to a /prometheus/api/v1/series/count endpoint and returns the total number of time series.

See https://docs.victoriametrics.com/victoriametrics/url-examples/#apiv1series

func (*Vmsingle) PrometheusAPIV1Write added in v1.97.13

func (app *Vmsingle) PrometheusAPIV1Write(t *testing.T, records []prompb.TimeSeries, _ QueryOpts)

PrometheusAPIV1Write is a test helper function that inserts a collection of records in Prometheus remote-write format by sending a HTTP POST request to /prometheus/api/v1/write vmsingle endpoint.

func (*Vmsingle) SnapshotCreate added in v1.102.18

func (app *Vmsingle) SnapshotCreate(t *testing.T) *SnapshotCreateResponse

SnapshotCreate creates a database snapshot by sending a query to the /snapshot/create endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (*Vmsingle) SnapshotCreateURL added in v1.102.23

func (app *Vmsingle) SnapshotCreateURL() string

SnapshotCreateURL returns the URL for creating snapshots.

func (*Vmsingle) SnapshotDelete added in v1.102.18

func (app *Vmsingle) SnapshotDelete(t *testing.T, snapshotName string) *SnapshotDeleteResponse

SnapshotDelete deletes a snapshot by sending a query to the /snapshot/delete endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (*Vmsingle) SnapshotDeleteAll added in v1.102.18

func (app *Vmsingle) SnapshotDeleteAll(t *testing.T) *SnapshotDeleteAllResponse

SnapshotDeleteAll deletes all snapshots by sending a query to the /snapshot/delete_all endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (*Vmsingle) SnapshotList added in v1.102.18

func (app *Vmsingle) SnapshotList(t *testing.T) *SnapshotListResponse

SnapshotList lists existing database snapshots by sending a query to the /snapshot/list endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (Vmsingle) Stop added in v1.97.12

func (app Vmsingle) Stop()

Stop sends the app process a SIGINT signal and waits until it terminates gracefully.

func (*Vmsingle) String added in v1.97.12

func (app *Vmsingle) String() string

String returns the string representation of the vmsingle app state.

type Vmstorage

type Vmstorage struct {
	*ServesMetrics
	// contains filtered or unexported fields
}

Vmstorage holds the state of a vmstorage app and provides vmstorage-specific functions.

func StartVmstorageAt added in v1.102.26

func StartVmstorageAt(instance, binary string, flags []string, cli *Client, output io.Writer) (*Vmstorage, error)

StartVmstorageAt starts an instance of vmstorage with the given flags. It also sets the default flags and populates the app instance state with runtime values extracted from the application log (such as httpListenAddr)

func (*Vmstorage) ForceFlush added in v1.97.12

func (app *Vmstorage) ForceFlush(t *testing.T)

ForceFlush is a test helper function that forces the flushing of inserted data, so it becomes available for searching immediately.

func (*Vmstorage) ForceMerge added in v1.102.17

func (app *Vmstorage) ForceMerge(t *testing.T)

ForceMerge is a test helper function that forces the merging of parts.

func (Vmstorage) Name added in v1.97.14

func (app Vmstorage) Name() string

Name returns the application instance name.

func (*Vmstorage) SnapshotCreate added in v1.102.18

func (app *Vmstorage) SnapshotCreate(t *testing.T) *SnapshotCreateResponse

SnapshotCreate creates a database snapshot by sending a query to the /snapshot/create endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (*Vmstorage) SnapshotCreateURL added in v1.102.23

func (app *Vmstorage) SnapshotCreateURL() string

SnapshotCreateURL returns the URL for creating snapshots.

func (*Vmstorage) SnapshotDelete added in v1.102.18

func (app *Vmstorage) SnapshotDelete(t *testing.T, snapshotName string) *SnapshotDeleteResponse

SnapshotDelete deletes a snapshot by sending a query to the /snapshot/delete endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (*Vmstorage) SnapshotDeleteAll added in v1.102.18

func (app *Vmstorage) SnapshotDeleteAll(t *testing.T) *SnapshotDeleteAllResponse

SnapshotDeleteAll deletes all snapshots by sending a query to the /snapshot/delete_all endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (*Vmstorage) SnapshotList added in v1.102.18

func (app *Vmstorage) SnapshotList(t *testing.T) *SnapshotListResponse

SnapshotList lists existing database snapshots by sending a query to the /snapshot/list endpoint.

See https://docs.victoriametrics.com/victoriametrics/single-server-victoriametrics/#how-to-work-with-snapshots

func (Vmstorage) Stop

func (app Vmstorage) Stop()

Stop sends the app process a SIGINT signal and waits until it terminates gracefully.

func (*Vmstorage) String

func (app *Vmstorage) String() string

String returns the string representation of the vmstorage app state.

func (*Vmstorage) VminsertAddr

func (app *Vmstorage) VminsertAddr() string

VminsertAddr returns the address at which the vmstorage process is listening for vminsert connections.

func (*Vmstorage) VmselectAddr

func (app *Vmstorage) VmselectAddr() string

VmselectAddr returns the address at which the vmstorage process is listening for vmselect connections.

type Writer added in v1.102.20

type Writer interface {
	// Prometheus APIs
	PrometheusAPIV1Write(t *testing.T, records []prompb.TimeSeries, opts QueryOpts)
	PrometheusAPIV1ImportPrometheus(t *testing.T, records []string, opts QueryOpts)
	PrometheusAPIV1ImportCSV(t *testing.T, records []string, opts QueryOpts)
	PrometheusAPIV1ImportNative(t *testing.T, data []byte, opts QueryOpts)

	// Graphit APIs
	GraphiteWrite(t *testing.T, records []string, opts QueryOpts)

	// OpenTSDB APIs
	OpenTSDBAPIPut(t *testing.T, records []string, opts QueryOpts)
}

Writer contains methods for writing new data

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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