metricstest

package
v1.52.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package metricstest hosts an in-process fake Cloud Monitoring server used by both bigtable/internal/metrics/*_test.go and the top-level bigtable/metrics_test.go integration tests. Kept in a dedicated package so both callers share one implementation instead of duplicating ~200 lines of gRPC test scaffolding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Endpoint string

	RetryCount int
	// contains filtered or unexported fields
}

Server is an in-process fake implementation of google.monitoring.v3.MetricService. Tests use it to capture the CreateServiceTimeSeries / CreateMetricDescriptor calls the metrics exporter would otherwise send to Cloud Monitoring.

func NewServer

func NewServer() (*Server, error)

NewServer stands up a fresh in-process fake Cloud Monitoring server on 127.0.0.1:<random-free-port>. Call Serve() from a goroutine and Shutdown() from a defer.

func (*Server) CreateServiceTimeSeriesRequests

func (m *Server) CreateServiceTimeSeriesRequests() []*monitoringpb.CreateTimeSeriesRequest

CreateServiceTimeSeriesRequests pops the CreateTimeSeriesRequest batches captured so far.

func (*Server) Serve

func (m *Server) Serve() error

Serve blocks serving the gRPC listener; call from a goroutine.

func (*Server) Shutdown

func (m *Server) Shutdown()

Shutdown gracefully stops the fake server.

func (*Server) UserAgent

func (m *Server) UserAgent() string

UserAgent returns (and clears) the most recently observed user-agent header from a CreateServiceTimeSeries call.

func (*Server) WaitForRequests

func (m *Server) WaitForRequests(ctx context.Context, count int, timeout time.Duration) error

WaitForRequests blocks until `count` CreateServiceTimeSeries calls have arrived, or ctx cancels, or `timeout` elapses.

Jump to

Keyboard shortcuts

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