testbed

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 63 Imported by: 0

Documentation

Overview

Package testbed allows to easily set up a test that requires running the agent and a load generator, measure and define resource consumption expectations for the agent, fail tests automatically when expectations are exceeded.

Each test case requires a agent configuration file and (optionally) load generator spec file. Test cases are defined as regular Go tests.

Agent and load generator must be pre-built and their paths must be specified in test bed config file. The config file location must be provided in TESTBED_CONFIG env variable.

Index

Constants

View Source
const DefaultHost = "localhost"
View Source
const DefaultJaegerPort = 14250
View Source
const DefaultOCPort = 56565
View Source
const DefaultOTLPPort = 55680
View Source
const DefaultZipkinAddressPort = 9411

Variables

View Source
var ErrSkipTests = errors.New("skip tests")

ErrSkipTests indicates that the tests must be skipped.

Functions

func DoTestMain

func DoTestMain(m *testing.M, resultsSummary TestResultsSummary)

DoTestMain is intended to be run from TestMain somewhere in the test suit. This enables the testbed.

func GenerateSequentialSpanID added in v0.5.0

func GenerateSequentialSpanID(id uint64) []byte

func GenerateSequentialTraceID added in v0.5.0

func GenerateSequentialTraceID(id uint64) []byte

func GetAvailablePort

func GetAvailablePort(t *testing.T) int

func LoadConfig

func LoadConfig() error

LoadConfig loads test bed config.

func SaveResults

func SaveResults(resultsSummary TestResultsSummary)

func Start

func Start(resultsSummary TestResultsSummary) error

Types

type AssertionFailure added in v0.5.0

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

func (AssertionFailure) String added in v0.5.0

func (af AssertionFailure) String() string

type ChildProcess added in v0.5.0

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

ChildProcess implements the OtelcolRunner interface as a child process on the same machine executing the test. The process can be monitored and the output of which will be written to a log file.

func (*ChildProcess) GetProcessMon added in v0.5.0

func (cp *ChildProcess) GetProcessMon() *process.Process

func (*ChildProcess) GetResourceConsumption added in v0.5.0

func (cp *ChildProcess) GetResourceConsumption() string

GetResourceConsumption returns resource consumption as a string

func (*ChildProcess) GetTotalConsumption added in v0.5.0

func (cp *ChildProcess) GetTotalConsumption() *ResourceConsumption

GetTotalConsumption returns total resource consumption since start of process

func (*ChildProcess) PrepareConfig added in v0.5.0

func (cp *ChildProcess) PrepareConfig(configStr string) (configCleanup func(), err error)

func (*ChildProcess) Start added in v0.5.0

func (cp *ChildProcess) Start(params StartParams) (receiverAddr string, err error)

start a child process.

Parameters: name is the human readable name of the process (e.g. "Agent"), used for logging. logFilePath is the file path to write the standard output and standard error of the process to. cmd is the executable to run. cmdArgs is the command line arguments to pass to the process.

func (*ChildProcess) Stop added in v0.5.0

func (cp *ChildProcess) Stop() (stopped bool, err error)

func (*ChildProcess) WatchResourceConsumption added in v0.5.0

func (cp *ChildProcess) WatchResourceConsumption() error

type CorrectnessResults added in v0.5.0

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

CorrectnessResults implements the TestResultsSummary interface with fields suitable for reporting data translation correctness test results.

func (*CorrectnessResults) Add added in v0.5.0

func (r *CorrectnessResults) Add(testName string, result interface{})

func (*CorrectnessResults) Init added in v0.5.0

func (r *CorrectnessResults) Init(resultsDir string)

func (*CorrectnessResults) Save added in v0.5.0

func (r *CorrectnessResults) Save()

type CorrectnessTestResult added in v0.5.0

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

CorrectnessTestResult reports the results of a single correctness test.

type CorrectnessTestValidator added in v0.5.0

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

CorrectnessTestValidator implements TestCaseValidator for test suites using CorrectnessResults for summarizing results.

func NewCorrectTestValidator added in v0.5.0

func NewCorrectTestValidator(provider DataProvider) *CorrectnessTestValidator

func (*CorrectnessTestValidator) RecordResults added in v0.5.0

func (v *CorrectnessTestValidator) RecordResults(tc *TestCase)

func (*CorrectnessTestValidator) Validate added in v0.5.0

func (v *CorrectnessTestValidator) Validate(tc *TestCase)

type DataProvider added in v0.5.0

type DataProvider interface {
	// SetLoadGeneratorCounters supplies pointers to LoadGenerator counters.
	// The data provider implementation should increment these as it generates data.
	SetLoadGeneratorCounters(batchesGenerated *atomic.Uint64, dataItemsGenerated *atomic.Uint64)
	// GenerateTraces returns an internal Traces instance with an OTLP ResourceSpans slice populated with test data.
	GenerateTraces() (pdata.Traces, bool)
	// GenerateTracesOld returns a slice of OpenCensus Span instances populated with test data.
	GenerateTracesOld() ([]*tracepb.Span, bool)
	// GenerateMetrics returns an internal MetricData instance with an OTLP ResourceMetrics slice of test data.
	GenerateMetrics() (data.MetricData, bool)
	// GenerateMetricsOld returns a slice of OpenCensus Metric instances populated with test data.
	GenerateMetricsOld() ([]*metricspb.Metric, bool)
	// GetGeneratedSpan returns the generated Span matching the provided traceId and spanId or else nil if no match found.
	GetGeneratedSpan(traceID []byte, spanID []byte) *otlptrace.Span
}

DataProvider defines the interface for generators of test data used to drive various end-to-end tests.

type DataReceiver

type DataReceiver interface {
	Start(tc *MockTraceConsumer, mc *MockMetricConsumer) error
	Stop() error

	// Generate a config string to place in exporter part of collector config
	// so that it can send data to this receiver.
	GenConfigYAMLStr() string

	// Return protocol name to use in collector config pipeline.
	ProtocolName() string
}

DataReceiver allows to receive traces or metrics. This is an interface that must be implemented by all protocols that want to be used in MockBackend. Note the terminology: testbed.DataReceiver is something that can listen and receive data from Collector and the corresponding entity in the Collector that sends this data is an exporter.

type DataReceiverBase

type DataReceiverBase struct {
	// Port on which to listen.
	Port int
}

DataReceiverBase implement basic functions needed by all receivers.

func (*DataReceiverBase) GetExporters

func (*DataReceiverBase) GetExtensions

Return map of extensions. Only enabled and created extensions will be returned.

func (*DataReceiverBase) GetFactory

GetFactory of the specified kind. Returns the factory for a component type.

func (*DataReceiverBase) ReportFatalError

func (mb *DataReceiverBase) ReportFatalError(err error)

type DataSender

type DataSender interface {
	// Start sender and connect to the configured endpoint. Must be called before
	// sending data.
	Start() error

	// Send any accumulated data.
	Flush()

	// Return the port to which this sender will send data.
	GetCollectorPort() int

	// Generate a config string to place in receiver part of collector config
	// so that it can receive data from this sender.
	GenConfigYAMLStr() string

	// Return protocol name to use in collector config pipeline.
	ProtocolName() string
}

DataSender defines the interface that allows sending data. This is an interface that must be implemented by all protocols that want to be used in LoadGenerator. Note the terminology: testbed.DataSender is something that sends data to Collector and the corresponding entity that receives the data in the Collector is a receiver.

type DataSenderOverTraceExporter

type DataSenderOverTraceExporter struct {
	Host string
	Port int
	// contains filtered or unexported fields
}

DataSenderOverTraceExporter partially implements TraceDataSender via a TraceExporter.

func (*DataSenderOverTraceExporter) Flush

func (ds *DataSenderOverTraceExporter) Flush()

func (*DataSenderOverTraceExporter) GetCollectorPort

func (ds *DataSenderOverTraceExporter) GetCollectorPort() int

func (*DataSenderOverTraceExporter) SendSpans

func (ds *DataSenderOverTraceExporter) SendSpans(traces pdata.Traces) error

type DataSenderOverTraceExporterOld

type DataSenderOverTraceExporterOld struct {
	Host string
	Port int
	// contains filtered or unexported fields
}

DataSenderOverTraceExporter partially implements TraceDataSender via a TraceExporter.

func (*DataSenderOverTraceExporterOld) Flush

func (ds *DataSenderOverTraceExporterOld) Flush()

func (*DataSenderOverTraceExporterOld) GetCollectorPort

func (ds *DataSenderOverTraceExporterOld) GetCollectorPort() int

func (*DataSenderOverTraceExporterOld) SendSpans

type GlobalConfig

type GlobalConfig struct {
	Agent         string
	LoadGenerator string `mapstructure:"load-generator"`
}

GlobalConfig defines test bed configuration.

type GoldenDataProvider added in v0.5.0

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

GoldenDataProvider is an implementation of DataProvider for use in correctness tests. Provided data from the "Golden" dataset generated using pairwise combinatorial testing techniques.

func NewGoldenDataProvider added in v0.5.0

func NewGoldenDataProvider(tracePairsFile string, spanPairsFile string, randomSeed int64) *GoldenDataProvider

NewGoldenDataProvider creates a new instance of GoldenDataProvider which generates test data based on the pairwise combinations specified in the tracePairsFile and spanPairsFile input variables. The supplied randomSeed is used to initialize the random number generator used in generating tracing IDs.

func (*GoldenDataProvider) GenerateMetrics added in v0.5.0

func (dp *GoldenDataProvider) GenerateMetrics() (data.MetricData, bool)

func (*GoldenDataProvider) GenerateMetricsOld added in v0.5.0

func (dp *GoldenDataProvider) GenerateMetricsOld() ([]*metricspb.Metric, bool)

func (*GoldenDataProvider) GenerateTraces added in v0.5.0

func (dp *GoldenDataProvider) GenerateTraces() (pdata.Traces, bool)

func (*GoldenDataProvider) GenerateTracesOld added in v0.5.0

func (dp *GoldenDataProvider) GenerateTracesOld() ([]*tracepb.Span, bool)

func (*GoldenDataProvider) GetGeneratedSpan added in v0.5.0

func (dp *GoldenDataProvider) GetGeneratedSpan(traceID []byte, spanID []byte) *otlptrace.Span

func (*GoldenDataProvider) SetLoadGeneratorCounters added in v0.5.0

func (dp *GoldenDataProvider) SetLoadGeneratorCounters(batchesGenerated *atomic.Uint64, dataItemsGenerated *atomic.Uint64)

type InProcessCollector added in v0.5.0

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

InProcessCollector implements the OtelcolRunner interfaces running a single otelcol as a go routine within the same process as the test executor.

func NewInProcessCollector added in v0.5.0

func NewInProcessCollector(factories config.Factories, receiverPort int) *InProcessCollector

NewInProcessCollector crewtes a new InProcessCollector using the supplied component factories.

func (*InProcessCollector) GetProcessMon added in v0.5.0

func (ipp *InProcessCollector) GetProcessMon() *process.Process

func (*InProcessCollector) GetResourceConsumption added in v0.5.0

func (ipp *InProcessCollector) GetResourceConsumption() string

func (*InProcessCollector) GetTotalConsumption added in v0.5.0

func (ipp *InProcessCollector) GetTotalConsumption() *ResourceConsumption

func (*InProcessCollector) PrepareConfig added in v0.5.0

func (ipp *InProcessCollector) PrepareConfig(configStr string) (configCleanup func(), err error)

func (*InProcessCollector) Start added in v0.5.0

func (ipp *InProcessCollector) Start(args StartParams) (receiverAddr string, err error)

func (*InProcessCollector) Stop added in v0.5.0

func (ipp *InProcessCollector) Stop() (stopped bool, err error)

func (*InProcessCollector) WatchResourceConsumption added in v0.5.0

func (ipp *InProcessCollector) WatchResourceConsumption() error

type JaegerDataReceiver

type JaegerDataReceiver struct {
	DataReceiverBase
	// contains filtered or unexported fields
}

JaegerDataReceiver implements Jaeger format receiver.

func NewJaegerDataReceiver

func NewJaegerDataReceiver(port int) *JaegerDataReceiver

func (*JaegerDataReceiver) GenConfigYAMLStr

func (jr *JaegerDataReceiver) GenConfigYAMLStr() string

func (*JaegerDataReceiver) ProtocolName

func (jr *JaegerDataReceiver) ProtocolName() string

func (*JaegerDataReceiver) Start

func (*JaegerDataReceiver) Stop

func (jr *JaegerDataReceiver) Stop() error

type JaegerGRPCDataSender

type JaegerGRPCDataSender struct {
	DataSenderOverTraceExporter
}

JaegerGRPCDataSender implements TraceDataSender for Jaeger thrift_http protocol.

func NewJaegerGRPCDataSender

func NewJaegerGRPCDataSender(host string, port int) *JaegerGRPCDataSender

NewJaegerGRPCDataSender creates a new Jaeger protocol sender that will send to the specified port after Start is called.

func (*JaegerGRPCDataSender) GenConfigYAMLStr

func (je *JaegerGRPCDataSender) GenConfigYAMLStr() string

func (*JaegerGRPCDataSender) ProtocolName

func (je *JaegerGRPCDataSender) ProtocolName() string

func (*JaegerGRPCDataSender) Start

func (je *JaegerGRPCDataSender) Start() error

type LoadGenerator

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

LoadGenerator is a simple load generator.

func NewLoadGenerator

func NewLoadGenerator(dataProvider DataProvider, sender DataSender) (*LoadGenerator, error)

NewLoadGenerator creates a load generator that sends data using specified sender.

func (*LoadGenerator) DataItemsSent

func (lg *LoadGenerator) DataItemsSent() uint64

func (*LoadGenerator) GetStats

func (lg *LoadGenerator) GetStats() string

GetStats returns the stats as a printable string.

func (*LoadGenerator) IncDataItemsSent

func (lg *LoadGenerator) IncDataItemsSent()

IncDataItemsSent is used when a test bypasses the LoadGenerator and sends data directly via TestCases's Sender. This is necessary so that the total number of sent items in the end is correct, because the reports are printed from LoadGenerator's fields. This is not the best way, a better approach would be to refactor the reports to use their own counter and load generator and other sending sources to contribute to this counter. This could be done as a future improvement.

func (*LoadGenerator) Start

func (lg *LoadGenerator) Start(options LoadOptions)

Start the load.

func (*LoadGenerator) Stop

func (lg *LoadGenerator) Stop()

Stop the load.

type LoadOptions

type LoadOptions struct {
	// DataItemsPerSecond specifies how many spans or metric data points to generate each second.
	DataItemsPerSecond int

	// ItemsPerBatch specifies how many spans or metric data points per batch to generate.
	// Should be greater than zero. The number of batches generated per second will be
	// DataItemsPerSecond/ItemsPerBatch.
	ItemsPerBatch int

	// Attributes to add to each generated data item. Can be empty.
	Attributes map[string]string
}

LoadOptions defines the options to use for generating the load.

type MetricDataSender

type MetricDataSender interface {
	DataSender
	SendMetrics(metrics data.MetricData) error
}

MetricDataSender defines the interface that allows sending metric data. It adds ability to send a batch of Metrics to the DataSender interface.

type MetricDataSenderOld

type MetricDataSenderOld interface {
	DataSender
	SendMetrics(metrics consumerdata.MetricsData) error
}

MetricDataSender defines the interface that allows sending metric data. It adds ability to send a batch of Metrics to the DataSender interface.

type MockBackend

type MockBackend struct {
	ReceivedTraces     []pdata.Traces
	ReceivedMetrics    []pdata.Metrics
	ReceivedTracesOld  []consumerdata.TraceData
	ReceivedMetricsOld []consumerdata.MetricsData
	// contains filtered or unexported fields
}

MockBackend is a backend that allows receiving the data locally.

func NewMockBackend

func NewMockBackend(logFilePath string, receiver DataReceiver) *MockBackend

NewMockBackend creates a new mock backend that receives data using specified receiver.

func (*MockBackend) ClearReceivedItems

func (mb *MockBackend) ClearReceivedItems()

ClearReceivedItems clears the list of received traces and metrics. Note: counters return by DataItemsReceived() are not cleared, they are cumulative.

func (*MockBackend) ConsumeMetric

func (mb *MockBackend) ConsumeMetric(md pdata.Metrics)

func (*MockBackend) ConsumeMetricOld

func (mb *MockBackend) ConsumeMetricOld(md consumerdata.MetricsData)

ConsumeMetricOld consumes metric data in old representation

func (*MockBackend) ConsumeTrace

func (mb *MockBackend) ConsumeTrace(td pdata.Traces)

func (*MockBackend) ConsumeTraceOld

func (mb *MockBackend) ConsumeTraceOld(td consumerdata.TraceData)

ConsumeTraceOld consumes trace data in old representation

func (*MockBackend) DataItemsReceived

func (mb *MockBackend) DataItemsReceived() uint64

DataItemsReceived returns total number of received spans and metrics.

func (*MockBackend) EnableRecording

func (mb *MockBackend) EnableRecording()

EnableRecording enables recording of all data received by MockBackend.

func (*MockBackend) GetStats

func (mb *MockBackend) GetStats() string

func (*MockBackend) ReportFatalError

func (mb *MockBackend) ReportFatalError(err error)

func (*MockBackend) Start

func (mb *MockBackend) Start() error

Start a backend.

func (*MockBackend) Stop

func (mb *MockBackend) Stop()

Stop the backend

type MockMetricConsumer

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

func (*MockMetricConsumer) ConsumeMetrics

func (mc *MockMetricConsumer) ConsumeMetrics(_ context.Context, md pdata.Metrics) error

func (*MockMetricConsumer) ConsumeMetricsData

func (mc *MockMetricConsumer) ConsumeMetricsData(ctx context.Context, md consumerdata.MetricsData) error

type MockTraceConsumer

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

func (*MockTraceConsumer) ConsumeTraceData

func (tc *MockTraceConsumer) ConsumeTraceData(ctx context.Context, td consumerdata.TraceData) error

func (*MockTraceConsumer) ConsumeTraces

func (tc *MockTraceConsumer) ConsumeTraces(ctx context.Context, td pdata.Traces) error

type OCDataReceiver

type OCDataReceiver struct {
	DataReceiverBase
	// contains filtered or unexported fields
}

OCDataReceiver implements OpenCensus format receiver.

func NewOCDataReceiver

func NewOCDataReceiver(port int) *OCDataReceiver

NewOCDataReceiver creates a new OCDataReceiver that will listen on the specified port after Start is called.

func (*OCDataReceiver) GenConfigYAMLStr

func (or *OCDataReceiver) GenConfigYAMLStr() string

func (*OCDataReceiver) ProtocolName

func (or *OCDataReceiver) ProtocolName() string

func (*OCDataReceiver) Start

func (*OCDataReceiver) Stop

func (or *OCDataReceiver) Stop() error

type OCMetricsDataSender

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

OCMetricsDataSender implements MetricDataSender for OpenCensus metrics protocol.

func NewOCMetricDataSender

func NewOCMetricDataSender(host string, port int) *OCMetricsDataSender

NewOCMetricDataSender creates a new OpenCensus metric protocol sender that will send to the specified port after Start is called.

func (*OCMetricsDataSender) Flush

func (ome *OCMetricsDataSender) Flush()

func (*OCMetricsDataSender) GenConfigYAMLStr

func (ome *OCMetricsDataSender) GenConfigYAMLStr() string

func (*OCMetricsDataSender) GetCollectorPort

func (ome *OCMetricsDataSender) GetCollectorPort() int

func (*OCMetricsDataSender) ProtocolName

func (ome *OCMetricsDataSender) ProtocolName() string

func (*OCMetricsDataSender) SendMetrics

func (ome *OCMetricsDataSender) SendMetrics(metrics consumerdata.MetricsData) error

func (*OCMetricsDataSender) Start

func (ome *OCMetricsDataSender) Start() error

type OCTraceDataSender

type OCTraceDataSender struct {
	DataSenderOverTraceExporterOld
}

OCTraceDataSender implements TraceDataSender for OpenCensus trace protocol.

func NewOCTraceDataSender

func NewOCTraceDataSender(host string, port int) *OCTraceDataSender

NewOCTraceDataSender creates a new OCTraceDataSender that will send to the specified port after Start is called.

func (*OCTraceDataSender) GenConfigYAMLStr

func (ote *OCTraceDataSender) GenConfigYAMLStr() string

func (*OCTraceDataSender) ProtocolName

func (ote *OCTraceDataSender) ProtocolName() string

func (*OCTraceDataSender) Start

func (ote *OCTraceDataSender) Start() error

type OTLPDataReceiver

type OTLPDataReceiver struct {
	DataReceiverBase
	// contains filtered or unexported fields
}

OTLPDataReceiver implements OTLP format receiver.

func NewOTLPDataReceiver

func NewOTLPDataReceiver(port int) *OTLPDataReceiver

NewOTLPDataReceiver creates a new OTLPDataReceiver that will listen on the specified port after Start is called.

func (*OTLPDataReceiver) GenConfigYAMLStr

func (or *OTLPDataReceiver) GenConfigYAMLStr() string

func (*OTLPDataReceiver) ProtocolName

func (or *OTLPDataReceiver) ProtocolName() string

func (*OTLPDataReceiver) Start

func (*OTLPDataReceiver) Stop

func (or *OTLPDataReceiver) Stop() error

type OTLPMetricsDataSender

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

OTLPMetricsDataSender implements MetricDataSender for OpenCensus metrics protocol.

func NewOTLPMetricDataSender

func NewOTLPMetricDataSender(host string, port int) *OTLPMetricsDataSender

NewOTLPMetricDataSender creates a new OpenCensus metric protocol sender that will send to the specified port after Start is called.

func (*OTLPMetricsDataSender) Flush

func (ome *OTLPMetricsDataSender) Flush()

func (*OTLPMetricsDataSender) GenConfigYAMLStr

func (ome *OTLPMetricsDataSender) GenConfigYAMLStr() string

func (*OTLPMetricsDataSender) GetCollectorPort

func (ome *OTLPMetricsDataSender) GetCollectorPort() int

func (*OTLPMetricsDataSender) ProtocolName

func (ome *OTLPMetricsDataSender) ProtocolName() string

func (*OTLPMetricsDataSender) SendMetrics

func (ome *OTLPMetricsDataSender) SendMetrics(metrics data.MetricData) error

func (*OTLPMetricsDataSender) Start

func (ome *OTLPMetricsDataSender) Start() error

type OTLPTraceDataSender

type OTLPTraceDataSender struct {
	DataSenderOverTraceExporter
}

OTLPTraceDataSender implements TraceDataSender for OpenCensus trace protocol.

func NewOTLPTraceDataSender

func NewOTLPTraceDataSender(host string, port int) *OTLPTraceDataSender

NewOTLPTraceDataSender creates a new OTLPTraceDataSender that will send to the specified port after Start is called.

func (*OTLPTraceDataSender) GenConfigYAMLStr

func (ote *OTLPTraceDataSender) GenConfigYAMLStr() string

func (*OTLPTraceDataSender) ProtocolName

func (ote *OTLPTraceDataSender) ProtocolName() string

func (*OTLPTraceDataSender) Start

func (ote *OTLPTraceDataSender) Start() error

type OtelcolRunner added in v0.5.0

type OtelcolRunner interface {
	// PrepareConfig stores the provided YAML-based otelcol configuration file in the format needed by the otelcol
	// instance(s) this runner manages. If successful, it returns the cleanup config function to be executed after
	// the test is executed.
	PrepareConfig(configStr string) (configCleanup func(), err error)
	// Starts the otelcol instance(s) if not already running which is the subject of the test to be run.
	// It returns the host:port of the data receiver to post test data to.
	Start(args StartParams) (receiverAddr string, err error)
	// Stops the otelcol instance(s) which are the subject of the test just run if applicable. Returns whether
	// the instance was actually stopped or not.
	Stop() (stopped bool, err error)
	// WatchResourceConsumption toggles on the monitoring of resource consumpution by the otelcol instance under test.
	WatchResourceConsumption() error
	// GetProcessMon returns the Process being used to monitor resource consumption.
	GetProcessMon() *process.Process
	// GetTotalConsumption returns the data collected by the process monitor.
	GetTotalConsumption() *ResourceConsumption
	// GetResourceConsumption returns the data collected by the process monitor as a display string.
	GetResourceConsumption() string
}

OtelcolRunner defines the interface for configuring, starting and stopping one or more instances of otelcol which will be the subject of testing being executed.

type PerfTestDataProvider added in v0.5.0

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

PerfTestDataProvider in an implementation of the DataProvider for use in performance tests. Tracing IDs are based on the incremented batch and data items counters.

func NewPerfTestDataProvider added in v0.5.0

func NewPerfTestDataProvider(options LoadOptions) *PerfTestDataProvider

NewPerfTestDataProvider creates an instance of PerfTestDataProvider which generates test data based on the sizes specified in the supplied LoadOptions.

func (*PerfTestDataProvider) GenerateMetrics added in v0.5.0

func (dp *PerfTestDataProvider) GenerateMetrics() (data.MetricData, bool)

func (*PerfTestDataProvider) GenerateMetricsOld added in v0.5.0

func (dp *PerfTestDataProvider) GenerateMetricsOld() ([]*metricspb.Metric, bool)

func (*PerfTestDataProvider) GenerateTraces added in v0.5.0

func (dp *PerfTestDataProvider) GenerateTraces() (pdata.Traces, bool)

func (*PerfTestDataProvider) GenerateTracesOld added in v0.5.0

func (dp *PerfTestDataProvider) GenerateTracesOld() ([]*tracepb.Span, bool)

func (*PerfTestDataProvider) GetGeneratedSpan added in v0.5.0

func (dp *PerfTestDataProvider) GetGeneratedSpan(traceID []byte, spanID []byte) *otlptrace.Span

func (*PerfTestDataProvider) SetLoadGeneratorCounters added in v0.5.0

func (dp *PerfTestDataProvider) SetLoadGeneratorCounters(batchesGenerated *atomic.Uint64, dataItemsGenerated *atomic.Uint64)

type PerfTestValidator added in v0.5.0

type PerfTestValidator struct {
}

PerfTestValidator implements TestCaseValidator for test suites using PerformanceResults for summarizing results.

func (*PerfTestValidator) RecordResults added in v0.5.0

func (v *PerfTestValidator) RecordResults(tc *TestCase)

func (*PerfTestValidator) Validate added in v0.5.0

func (v *PerfTestValidator) Validate(tc *TestCase)

type PerformanceResults added in v0.5.0

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

PerformanceResults implements the TestResultsSummary interface with fields suitable for reporting performance test results.

func (*PerformanceResults) Add added in v0.5.0

func (r *PerformanceResults) Add(testName string, result interface{})

Add results for one test.

func (*PerformanceResults) Init added in v0.5.0

func (r *PerformanceResults) Init(resultsDir string)

func (*PerformanceResults) Save added in v0.5.0

func (r *PerformanceResults) Save()

Save the total results and close the file.

type PerformanceTestResult added in v0.5.0

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

PerformanceTestResult reports the results of a single performance test.

type ResourceConsumption

type ResourceConsumption struct {
	CPUPercentAvg float64
	CPUPercentMax float64
	RAMMiBAvg     uint32
	RAMMiBMax     uint32
}

type ResourceSpec

type ResourceSpec struct {
	// Percentage of one core the process is expected to consume at most.
	// Test is aborted and failed if consumption during
	// ResourceCheckPeriod exceeds this number. If 0 the CPU
	// consumption is not monitored and does not affect the test result.
	ExpectedMaxCPU uint32

	// Maximum RAM in MiB the process is expected to consume.
	// Test is aborted and failed if consumption exceeds this number.
	// If 0 memory consumption is not monitored and does not affect
	// the test result.
	ExpectedMaxRAM uint32

	// Period during which CPU and RAM of the process are measured.
	// Bigger numbers will result in more averaging of short spikes.
	ResourceCheckPeriod time.Duration
}

ResourceSpec is a resource consumption specification.

type StartParams added in v0.5.0

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

type TestCase

type TestCase struct {
	Sender   DataSender
	Receiver DataReceiver

	LoadGenerator *LoadGenerator
	MockBackend   *MockBackend

	// ErrorSignal indicates an error in the test case execution, e.g. process execution
	// failure or exceeding resource consumption, etc. The actual error message is already
	// logged, this is only an indicator on which you can wait to be informed.
	ErrorSignal chan struct{}

	// Duration is the requested duration of the tests. Configured via TESTBED_DURATION
	// env variable and defaults to 15 seconds if env variable is unspecified.
	Duration time.Duration
	// contains filtered or unexported fields
}

TestCase defines a running test case.

func NewTestCase

func NewTestCase(
	t *testing.T,
	dataProvider DataProvider,
	sender DataSender,
	receiver DataReceiver,
	agentProc OtelcolRunner,
	validator TestCaseValidator,
	resultsSummary TestResultsSummary,
	opts ...TestCaseOption,
) *TestCase

NewTestCase creates a new TestCase. It expects agent-config.yaml in the specified directory.

func (*TestCase) AgentMemoryInfo

func (tc *TestCase) AgentMemoryInfo() (uint32, uint32, error)

AgentMemoryInfo returns raw memory info struct about the agent as returned by github.com/shirou/gopsutil/process

func (*TestCase) EnableRecording

func (tc *TestCase) EnableRecording()

EnableRecording enables recording of all data received by MockBackend.

func (*TestCase) SetResourceLimits

func (tc *TestCase) SetResourceLimits(resourceSpec ResourceSpec)

SetResourceLimits sets expected limits for resource consmption. Error is signaled if consumption during ResourceCheckPeriod exceeds the limits. Limits are modified only for non-zero fields of resourceSpec, all zero-value fields fo resourceSpec are ignored and their previous values remain in effect.

func (*TestCase) Sleep

func (tc *TestCase) Sleep(d time.Duration)

Sleep for specified duration or until error is signaled.

func (*TestCase) StartAgent

func (tc *TestCase) StartAgent(args ...string)

StartAgent starts the agent and redirects its standard output and standard error to "agent.log" file located in the test directory.

func (*TestCase) StartBackend

func (tc *TestCase) StartBackend()

StartBackend starts the specified backend type.

func (*TestCase) StartLoad

func (tc *TestCase) StartLoad(options LoadOptions)

StartLoad starts the load generator and redirects its standard output and standard error to "load-generator.log" file located in the test directory.

func (*TestCase) Stop

func (tc *TestCase) Stop()

Stop stops the load generator, the agent and the backend.

func (*TestCase) StopAgent

func (tc *TestCase) StopAgent()

StopAgent stops agent process.

func (*TestCase) StopBackend

func (tc *TestCase) StopBackend()

StopBackend stops the backend.

func (*TestCase) StopLoad

func (tc *TestCase) StopLoad()

StopLoad stops load generator.

func (*TestCase) ValidateData

func (tc *TestCase) ValidateData()

ValidateData validates data received by mock backend against what was generated and sent to the collector instance(s) under test by the LoadGenerator.

func (*TestCase) WaitFor

func (tc *TestCase) WaitFor(cond func() bool, errMsg ...interface{}) bool

WaitFor is like WaitForN but with a fixed duration of 10 seconds

func (*TestCase) WaitForN

func (tc *TestCase) WaitForN(cond func() bool, duration time.Duration, errMsg ...interface{}) bool

WaitForN the specific condition for up to a specified duration. Records a test error if time is out and condition does not become true. If error is signaled while waiting the function will return false, but will not record additional test error (we assume that signaled error is already recorded in indicateError()).

type TestCaseOption

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

TestCaseOption defines a TestCase option.

func WithConfigFile

func WithConfigFile(file string) TestCaseOption

WithConfigFile allows a custom configuration file for TestCase.

func WithSkipResults

func WithSkipResults() TestCaseOption

WithSkipResults option disables writing out results file for a TestCase.

func (TestCaseOption) Apply

func (o TestCaseOption) Apply(t *TestCase)

Apply takes a TestCase and runs the option function on it.

type TestCaseValidator added in v0.5.0

type TestCaseValidator interface {
	// Validate executes validation routines and test assertions.
	Validate(tc *TestCase)
	// RecordResults updates the TestResultsSummary for the test suite with results of a single test.
	RecordResults(tc *TestCase)
}

TestCaseValidator defines the interface for validating and reporting test results.

type TestResultsSummary added in v0.5.0

type TestResultsSummary interface {
	// Create and open the file and write headers.
	Init(resultsDir string)
	// Add results for one test.
	Add(testName string, result interface{})
	// Save the total results and close the file.
	Save()
}

TestResultsSummary defines the interface to record results of one category of testing.

type TraceDataSender

type TraceDataSender interface {
	DataSender
	SendSpans(traces pdata.Traces) error
}

TraceDataSender defines the interface that allows sending trace data. It adds ability to send a batch of Spans to the DataSender interface.

type TraceDataSenderOld

type TraceDataSenderOld interface {
	DataSender
	SendSpans(traces consumerdata.TraceData) error
}

TraceDataSender defines the interface that allows sending trace data. It adds ability to send a batch of Spans to the DataSender interface.

type ZipkinDataReceiver

type ZipkinDataReceiver struct {
	DataReceiverBase
	// contains filtered or unexported fields
}

ZipkinDataReceiver implements Zipkin format receiver.

func NewZipkinDataReceiver

func NewZipkinDataReceiver(port int) *ZipkinDataReceiver

func (*ZipkinDataReceiver) GenConfigYAMLStr

func (zr *ZipkinDataReceiver) GenConfigYAMLStr() string

func (*ZipkinDataReceiver) ProtocolName

func (zr *ZipkinDataReceiver) ProtocolName() string

func (*ZipkinDataReceiver) Start

func (*ZipkinDataReceiver) Stop

func (zr *ZipkinDataReceiver) Stop() error

type ZipkinDataSender

type ZipkinDataSender struct {
	DataSenderOverTraceExporterOld
}

ZipkinDataSender implements TraceDataSender for Zipkin http protocol.

func NewZipkinDataSender

func NewZipkinDataSender(host string, port int) *ZipkinDataSender

NewZipkinDataSender creates a new Zipkin protocol sender that will send to the specified port after Start is called.

func (*ZipkinDataSender) GenConfigYAMLStr

func (zs *ZipkinDataSender) GenConfigYAMLStr() string

func (*ZipkinDataSender) ProtocolName

func (zs *ZipkinDataSender) ProtocolName() string

func (*ZipkinDataSender) Start

func (zs *ZipkinDataSender) Start() error

Jump to

Keyboard shortcuts

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