testhelper

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testhelper provides test helpers for FODC agent components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFlightRecorder

func NewFlightRecorder(capacitySize int64) *flightrecorder.FlightRecorder

NewFlightRecorder creates a new FlightRecorder instance for testing.

func NewProxyClient

func NewProxyClient(
	proxyAddr string,
	nodeRole string,
	podName string,
	containerNames []string,
	labels map[string]string,
	heartbeatInterval time.Duration,
	reconnectInterval time.Duration,
	flightRecorder interface{},
	logger *logger.Logger,
) *proxy.Client

NewProxyClient creates a new ProxyClient instance for testing.

func NewProxyClientWithCollector

func NewProxyClientWithCollector(
	proxyAddr string,
	nodeRole string,
	podName string,
	containerNames []string,
	labels map[string]string,
	heartbeatInterval time.Duration,
	reconnectInterval time.Duration,
	flightRecorder interface{},
	collector *agentcluster.Collector,
	logger *logger.Logger,
) *proxy.Client

NewProxyClientWithCollector creates a new ProxyClient instance for testing with optional cluster collector.

func UpdateMetrics

func UpdateMetrics(fr interface{}, rawMetrics []RawMetric) error

UpdateMetrics updates the FlightRecorder with metrics. fr should be a *flightrecorder.FlightRecorder instance.

func ValidateMetricsBufferAlignment

func ValidateMetricsBufferAlignment(fr interface{}) error

ValidateMetricsBufferAlignment validates that the timestamps buffer length equals each metric buffer length.

Types

type Label

type Label struct {
	Name  string
	Value string
}

Label represents a metric label.

type ProxyClientWrapper

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

ProxyClientWrapper wraps ProxyClient methods for testing.

func NewProxyClientWrapper

func NewProxyClientWrapper(
	proxyAddr string,
	nodeRole string,
	podName string,
	containerNames []string,
	labels map[string]string,
	heartbeatInterval time.Duration,
	reconnectInterval time.Duration,
	flightRecorder interface{},
	logger *logger.Logger,
	reportDir string,
) *ProxyClientWrapper

NewProxyClientWrapper creates a wrapped ProxyClient for testing.

func (*ProxyClientWrapper) Connect

func (w *ProxyClientWrapper) Connect(ctx context.Context) error

Connect establishes a gRPC connection to Proxy.

func (*ProxyClientWrapper) Disconnect

func (w *ProxyClientWrapper) Disconnect() error

Disconnect closes connection to Proxy.

func (*ProxyClientWrapper) SetClusterTopology

func (w *ProxyClientWrapper) SetClusterTopology(nodes []*databasev1.Node, calls []*fodcv1.Call) error

SetClusterTopology seeds the wrapped client's cluster collector for testing.

func (*ProxyClientWrapper) Start

func (w *ProxyClientWrapper) Start(ctx context.Context) error

Start starts the proxy client with automatic connection and stream setup.

func (*ProxyClientWrapper) StartClusterStateStream

func (w *ProxyClientWrapper) StartClusterStateStream(ctx context.Context) error

StartClusterStateStream establishes bi-directional cluster state stream with Proxy.

func (*ProxyClientWrapper) StartConnManager

func (w *ProxyClientWrapper) StartConnManager(ctx context.Context)

StartConnManager starts the connection manager.

func (*ProxyClientWrapper) StartLifecycleStream added in v0.10.1

func (w *ProxyClientWrapper) StartLifecycleStream(ctx context.Context) error

StartLifecycleStream establishes bi-directional lifecycle stream with Proxy.

func (*ProxyClientWrapper) StartMetricsStream

func (w *ProxyClientWrapper) StartMetricsStream(ctx context.Context) error

StartMetricsStream establishes bi-directional metrics stream with Proxy.

func (*ProxyClientWrapper) StartRegistrationStream

func (w *ProxyClientWrapper) StartRegistrationStream(ctx context.Context) error

StartRegistrationStream establishes bi-directional registration stream with Proxy.

type RawMetric

type RawMetric struct {
	Desc   string
	Name   string
	Labels []Label
	Value  float64
}

RawMetric represents a metric for testing.

Jump to

Keyboard shortcuts

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