Documentation
¶
Index ¶
- Constants
- func ContainsLabelValue(mf *dto.MetricFamily, labelName, substring string) bool
- func CountMetrics(mf *dto.MetricFamily) int
- func FindMetricWithLabels(mf *dto.MetricFamily, labels map[string]string) *dto.Metric
- func FindMetricsWithLabelSubstring(mf *dto.MetricFamily, labelName, substring string) []*dto.Metric
- func GetAllLabelValues(mf *dto.MetricFamily, labelName string) []string
- func GetCounterValue(metric *dto.Metric) float64
- func GetGaugeValue(metric *dto.Metric) float64
- func GetLabelValue(metric *dto.Metric, labelName string) string
- func GetMetricFamily(families map[string]*dto.MetricFamily, name string) (*dto.MetricFamily, bool)
- func GetMetricType(mf *dto.MetricFamily) string
- func HasMetric(families map[string]*dto.MetricFamily, name string) bool
- func RetryForDuration(retryFunc func() error, dur time.Duration) error
- type CadvisorActions
- type ContainerdActions
- type ContainerdRunArgs
- type CrioActions
- type CrioRunArgs
- type DockerActions
- type DockerRunArgs
- type Framework
- type HostnameInfo
- type MetricsClient
- type ShellActions
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ContainsLabelValue ¶ added in v0.57.0
func ContainsLabelValue(mf *dto.MetricFamily, labelName, substring string) bool
ContainsLabelValue checks if any metric in the family has the label containing the given substring.
func CountMetrics ¶ added in v0.57.0
func CountMetrics(mf *dto.MetricFamily) int
CountMetrics returns the number of metric samples in a metric family.
func FindMetricWithLabels ¶ added in v0.57.0
FindMetricWithLabels finds a metric matching all specified labels. Returns nil if no matching metric is found.
func FindMetricsWithLabelSubstring ¶ added in v0.57.0
func FindMetricsWithLabelSubstring(mf *dto.MetricFamily, labelName, substring string) []*dto.Metric
FindMetricsWithLabelSubstring finds all metrics where the specified label contains the given substring.
func GetAllLabelValues ¶ added in v0.57.0
func GetAllLabelValues(mf *dto.MetricFamily, labelName string) []string
GetAllLabelValues returns all unique values for a given label name across all metrics in the family.
func GetCounterValue ¶ added in v0.57.0
GetCounterValue extracts the value from a counter metric.
func GetGaugeValue ¶ added in v0.57.0
GetGaugeValue extracts the value from a gauge metric.
func GetLabelValue ¶ added in v0.57.0
GetLabelValue returns the value of a specific label from a metric. Returns empty string if label is not found.
func GetMetricFamily ¶ added in v0.57.0
func GetMetricFamily(families map[string]*dto.MetricFamily, name string) (*dto.MetricFamily, bool)
GetMetricFamily returns a specific metric family by name.
func GetMetricType ¶ added in v0.57.0
func GetMetricType(mf *dto.MetricFamily) string
GetMetricType returns the type of a metric family as a string.
Types ¶
type CadvisorActions ¶
type ContainerdActions ¶ added in v0.57.0
type ContainerdActions interface {
// Run the no-op pause containerd container and return its ID.
RunPause() string
// Run the specified command in a containerd busybox container and return its ID.
RunBusybox(cmd ...string) string
// Runs a containerd container in the background. Uses the specified ContainerdRunArgs and command.
// Returns the ID of the new container.
Run(args ContainerdRunArgs, cmd ...string) string
}
ContainerdActions provides methods for managing containerd containers in tests. Containerd containers are created directly using the ctr CLI tool.
type ContainerdRunArgs ¶ added in v0.57.0
type ContainerdRunArgs struct {
// Image to use.
Image string
// Container name (optional, auto-generated if empty).
Name string
// Labels to add to the container.
Labels map[string]string
}
ContainerdRunArgs contains arguments for running a containerd container.
type CrioActions ¶ added in v0.55.0
type CrioActions interface {
// Run the no-op pause CRI-O container and return its ID.
RunPause() string
// Run the specified command in a CRI-O busybox container and return its ID.
RunBusybox(cmd ...string) string
// Runs a CRI-O container in the background. Uses the specified CrioRunArgs and command.
// Returns the ID of the new container.
Run(args CrioRunArgs, cmd ...string) string
}
CrioActions provides methods for managing CRI-O containers in tests. CRI-O containers run inside pod sandboxes, so each container requires a pod to be created first.
type CrioRunArgs ¶ added in v0.55.0
type CrioRunArgs struct {
// Image to use.
Image string
// Container name (optional, auto-generated if empty).
Name string
}
CrioRunArgs contains arguments for running a CRI-O container.
type DockerActions ¶
type DockerActions interface {
// Run the no-op pause Docker container and return its ID.
RunPause() string
// Run the specified command in a Docker busybox container and return its ID.
RunBusybox(cmd ...string) string
// Runs a Docker container in the background. Uses the specified DockerRunArgs and command.
// Returns the ID of the new container.
//
// e.g.:
// Run(DockerRunArgs{Image: "busybox"}, "ping", "www.google.com")
// -> docker run busybox ping www.google.com
Run(args DockerRunArgs, cmd ...string) string
RunStress(args DockerRunArgs, cmd ...string) string
Version() []string
StorageDriver() string
}
type DockerRunArgs ¶
type Framework ¶
type Framework interface {
// Clean the framework state.
Cleanup()
// The testing.T used by the framework and the current test.
T() *testing.T
// Returns the hostname being tested.
Hostname() HostnameInfo
// Returns the Docker actions for the test framework.
Docker() DockerActions
// Returns the CRI-O actions for the test framework.
Crio() CrioActions
// Returns the containerd actions for the test framework.
Containerd() ContainerdActions
// Returns the shell actions for the test framework.
Shell() ShellActions
// Returns the cAdvisor actions for the test framework.
Cadvisor() CadvisorActions
}
Integration test framework.
type HostnameInfo ¶
func (HostnameInfo) FullHostname ¶
func (h HostnameInfo) FullHostname() string
Returns: http://<host>:<port>/
type MetricsClient ¶ added in v0.57.0
type MetricsClient struct {
// contains filtered or unexported fields
}
MetricsClient provides methods for fetching and parsing Prometheus metrics from cAdvisor's /metrics endpoint.
func NewMetricsClient ¶ added in v0.57.0
func NewMetricsClient(hostname HostnameInfo) *MetricsClient
NewMetricsClient creates a new client for the /metrics endpoint.
func (*MetricsClient) Fetch ¶ added in v0.57.0
func (m *MetricsClient) Fetch() (string, error)
Fetch retrieves raw metrics text from the /metrics endpoint.
func (*MetricsClient) FetchAndParse ¶ added in v0.57.0
func (m *MetricsClient) FetchAndParse() (map[string]*dto.MetricFamily, error)
FetchAndParse combines Fetch and Parse into one call.
func (*MetricsClient) FetchWithParams ¶ added in v0.57.0
func (m *MetricsClient) FetchWithParams(params string) (string, error)
FetchWithParams retrieves metrics with optional query parameters. Parameters can be "type=docker" or "type=name" to filter containers.
func (*MetricsClient) Parse ¶ added in v0.57.0
func (m *MetricsClient) Parse(metricsText string) (map[string]*dto.MetricFamily, error)
Parse converts Prometheus text format to metric families.