Documentation
¶
Index ¶
- type Client
- type PrometheusAPIV1QueryResponse
- type PrometheusAPIV1SeriesResponse
- type PrometheusQuerier
- type PrometheusWriter
- type QueryData
- type QueryOpts
- type QueryResult
- type Sample
- type ServesMetrics
- type Stopper
- type TestCase
- func (tc *TestCase) Client() *Client
- func (tc *TestCase) Dir() string
- func (tc *TestCase) MustStartVminsert(instance string, flags []string) *Vminsert
- func (tc *TestCase) MustStartVmselect(instance string, flags []string) *Vmselect
- func (tc *TestCase) MustStartVmsingle(instance string, flags []string) *Vmsingle
- func (tc *TestCase) MustStartVmstorage(instance string, flags []string) *Vmstorage
- func (tc *TestCase) Stop()
- type Vminsert
- type Vmselect
- func (app *Vmselect) ClusternativeListenAddr() string
- func (app *Vmselect) PrometheusAPIV1Query(t *testing.T, query, time, step string, opts QueryOpts) *PrometheusAPIV1QueryResponse
- func (app *Vmselect) PrometheusAPIV1QueryRange(t *testing.T, query, start, end, step string, opts QueryOpts) *PrometheusAPIV1QueryResponse
- func (app *Vmselect) PrometheusAPIV1Series(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1SeriesResponse
- func (app Vmselect) Stop()
- func (app *Vmselect) String() string
- type Vmsingle
- func (app *Vmsingle) ForceFlush(t *testing.T)
- func (app *Vmsingle) PrometheusAPIV1ImportPrometheus(t *testing.T, records []string, _ QueryOpts)
- func (app *Vmsingle) PrometheusAPIV1Query(t *testing.T, query, time, step string, opts QueryOpts) *PrometheusAPIV1QueryResponse
- func (app *Vmsingle) PrometheusAPIV1QueryRange(t *testing.T, query, start, end, step string, opts QueryOpts) *PrometheusAPIV1QueryResponse
- func (app *Vmsingle) PrometheusAPIV1Series(t *testing.T, matchQuery string, _ QueryOpts) *PrometheusAPIV1SeriesResponse
- func (app Vmsingle) Stop()
- func (app *Vmsingle) String() string
- type Vmstorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used for interacting with the apps over the network.
At the moment it only supports HTTP protocol but may be exptended to support RPCs, etc.
func (*Client) CloseConnections ¶
func (c *Client) CloseConnections()
CloseConnections closes client connections.
func (*Client) Get ¶
Get sends a HTTP GET request. Once the function receives a response, it checks whether the response status code matches the expected one and returns the response body to the caller.
func (*Client) Post ¶
Post sends a HTTP POST request. Once the function receives a response, it checks whether the response status code matches the expected one and returns the response body to the caller.
type PrometheusAPIV1QueryResponse ¶ added in v1.97.12
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.
type PrometheusAPIV1SeriesResponse ¶
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.
type PrometheusQuerier ¶ added in v1.97.12
type PrometheusQuerier interface {
PrometheusAPIV1Query(t *testing.T, query, time, step string, opts QueryOpts) *PrometheusAPIV1QueryResponse
PrometheusAPIV1QueryRange(t *testing.T, query, start, end, step string, opts QueryOpts) *PrometheusAPIV1QueryResponse
PrometheusAPIV1Series(t *testing.T, matchQuery string, opts QueryOpts) *PrometheusAPIV1SeriesResponse
}
PrometheusQuerier contains methods available to Prometheus-like HTTP API for Querying
type PrometheusWriter ¶ added in v1.97.12
type PrometheusWriter interface {
PrometheusAPIV1ImportPrometheus(t *testing.T, records []string, opts QueryOpts)
}
PrometheusWriter contains methods available to Prometheus-like HTTP API for Writing new 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
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
Sample is a timeseries value at a given timestamp.
func NewSample ¶ added in v1.97.12
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
UnmarshalJSON populates the sample fields from a JSON string.
type ServesMetrics ¶
type ServesMetrics struct {
// contains filtered or unexported fields
}
ServesMetrics is used to retrive the app's metrics.
This type is expected to be embdded 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.
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 TestCase ¶
type TestCase struct {
// contains filtered or unexported fields
}
TestCase holds the state and defines clean-up procedure common for all test cases.
func (*TestCase) Client ¶
Client returns an instance of the client that can be used for interacting with the app(s) under test.
func (*TestCase) Dir ¶
Dir returns the directory name that should be used by as the -storageDataDir.
func (*TestCase) MustStartVminsert ¶ added in v1.97.12
MustStartVminsert is a test helper function that starts an instance of vminsert and fails the test if the app fails to start.
func (*TestCase) MustStartVmselect ¶ added in v1.97.12
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
MustStartVmsingle 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
MustStartVmstorage 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.
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 ¶
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) 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/url-examples/#apiv1importprometheus
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 ¶
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) ClusternativeListenAddr ¶
ClusternativeListenAddr returns the address at which the vmselect process is listening for connections from other vmselect apps.
func (*Vmselect) PrometheusAPIV1Query ¶ added in v1.97.12
func (app *Vmselect) PrometheusAPIV1Query(t *testing.T, query, time, step 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/url-examples/#apiv1query
func (*Vmselect) PrometheusAPIV1QueryRange ¶ added in v1.97.12
func (app *Vmselect) PrometheusAPIV1QueryRange(t *testing.T, query, start, end, step 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/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/url-examples/#apiv1series
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 StartVmsingle ¶ added in v1.97.12
StartVmsingle 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) ForceFlush ¶ added in v1.97.12
ForceFlush is a test helper function that forces the flushing of inserted data, so it becomes available for searching immediately.
func (*Vmsingle) PrometheusAPIV1ImportPrometheus ¶ added in v1.97.12
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/url-examples/#apiv1importprometheus
func (*Vmsingle) PrometheusAPIV1Query ¶ added in v1.97.12
func (app *Vmsingle) PrometheusAPIV1Query(t *testing.T, query, time, step 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/url-examples/#apiv1query
func (*Vmsingle) PrometheusAPIV1QueryRange ¶ added in v1.97.12
func (app *Vmsingle) PrometheusAPIV1QueryRange(t *testing.T, query, start, end, step 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/url-examples/#apiv1query_range
func (*Vmsingle) PrometheusAPIV1Series ¶ added in v1.97.12
func (app *Vmsingle) PrometheusAPIV1Series(t *testing.T, matchQuery string, _ 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/url-examples/#apiv1series
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 StartVmstorage ¶
StartVmstorage 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
ForceFlush is a test helper function that forces the flushing of inserted data, so it becomes available for searching immediately.
func (Vmstorage) Stop ¶
func (app Vmstorage) Stop()
stop sends the app process a SIGINT signal and waits until it terminates gracefully.
func (*Vmstorage) VminsertAddr ¶
VminsertAddr returns the address at which the vmstorage process is listening for vminsert connections.
func (*Vmstorage) VmselectAddr ¶
VmselectAddr returns the address at which the vmstorage process is listening for vmselect connections.