testbed

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: Apache-2.0 Imports: 69 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. RUN_TESTBED env variable must be defined for tests to run.

Index

Constants

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

Variables

View Source
var GlobalConfig = struct {
	// Relative path to default agent executable to test.
	// Can be set in the contrib repo to use a different executable name.
	// Set this before calling DoTestMain().
	//
	// If used in the path, {{.GOOS}} and {{.GOARCH}} will be expanded to the current
	// OS and ARCH correspondingly.
	//
	// Individual tests can override this by setting the AgentExePath of ChildProcess
	// that is passed to the TestCase.
	DefaultAgentExeRelativeFile string
}{

	DefaultAgentExeRelativeFile: "../../bin/otelcol_{{.GOOS}}_{{.GOARCH}}",
}

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) pdata.SpanID

func GenerateSequentialTraceID added in v0.5.0

func GenerateSequentialTraceID(id uint64) pdata.TraceID

func GetAvailablePort

func GetAvailablePort(t *testing.T) int

func SaveResults

func SaveResults(resultsSummary TestResultsSummary)

func Start

func Start(resultsSummary TestResultsSummary) error

Types

type ChildProcess added in v0.5.0

type ChildProcess struct {
	// Path to agent executable. If unset the default executable in
	// bin/otelcol_{{.GOOS}}_{{.GOARCH}} will be used.
	// Can be set for example to use the unstable executable for a specific test.
	AgentExePath string
	// 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) error

start a child process.

cp.AgentExePath defines the executable to run. If unspecified "../../bin/otelcol_{{.GOOS}}_{{.GOARCH}}" will be used. {{.GOOS}} and {{.GOARCH}} will be expanded to the current OS and ARCH correspondingly.

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. 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(_ 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)
	// GenerateMetrics returns an internal MetricData instance with an OTLP ResourceMetrics slice of test data.
	GenerateMetrics() (pdata.Metrics, bool)
	// GetGeneratedSpan returns the generated Span matching the provided traceId and spanId or else nil if no match found.
	GetGeneratedSpan(traceID pdata.TraceID, spanID pdata.SpanID) *otlptrace.Span
	// GenerateLogs returns the internal pdata.Logs format
	GenerateLogs() (pdata.Logs, bool)
}

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

type DataReceiver

type DataReceiver interface {
	Start(tc consumer.TracesConsumer, mc consumer.MetricsConsumer, lc consumer.LogsConsumer) 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 exporterType 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.

func NewOTLPDataReceiver

func NewOTLPDataReceiver(port int) DataReceiver

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

func NewOTLPHTTPDataReceiver added in v0.14.0

func NewOTLPHTTPDataReceiver(port int) DataReceiver

NewOTLPDataReceiver creates a new OTLP/HTTP DataReceiver that will listen on the specified port after Start is called.

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.
	GetEndpoint() string

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

	// Return exporterType 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 DataSenderBase added in v0.13.0

type DataSenderBase struct {
	Port int
	Host string
}

func (*DataSenderBase) Flush added in v0.13.0

func (dsb *DataSenderBase) Flush()

func (*DataSenderBase) GetEndpoint added in v0.13.0

func (dsb *DataSenderBase) GetEndpoint() string

func (*DataSenderBase) GetExporters added in v0.13.0

func (*DataSenderBase) GetExtensions added in v0.13.0

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

func (*DataSenderBase) GetFactory added in v0.13.0

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

func (*DataSenderBase) ReportFatalError added in v0.13.0

func (dsb *DataSenderBase) ReportFatalError(err error)

type FileDataProvider added in v0.20.0

type FileDataProvider struct {
	ItemsPerBatch int
	// contains filtered or unexported fields
}

FileDataProvider in an implementation of the DataProvider for use in performance tests. The data to send is loaded from a file. The file should contain one JSON-encoded Export*ServiceRequest Protobuf message. The file can be recorded using the "file" exporter (note: "file" exporter writes one JSON message per line, FileDataProvider expects just a single JSON message in the entire file).

func NewFileDataProvider added in v0.20.0

func NewFileDataProvider(filePath string, dataType configmodels.DataType) (*FileDataProvider, error)

NewFileDataProvider creates an instance of FileDataProvider which generates test data loaded from a file.

func (*FileDataProvider) GenerateLogs added in v0.20.0

func (dp *FileDataProvider) GenerateLogs() (pdata.Logs, bool)

func (*FileDataProvider) GenerateMetrics added in v0.20.0

func (dp *FileDataProvider) GenerateMetrics() (pdata.Metrics, bool)

func (*FileDataProvider) GenerateTraces added in v0.20.0

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

func (*FileDataProvider) GetGeneratedSpan added in v0.20.0

func (dp *FileDataProvider) GetGeneratedSpan(pdata.TraceID, pdata.SpanID) *otlptrace.Span

func (*FileDataProvider) SetLoadGeneratorCounters added in v0.20.0

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

type FluentBitFileLogWriter added in v0.9.0

type FluentBitFileLogWriter struct {
	DataSenderBase
	// contains filtered or unexported fields
}

func NewFluentBitFileLogWriter added in v0.9.0

func NewFluentBitFileLogWriter(host string, port int) *FluentBitFileLogWriter

NewFluentBitFileLogWriter creates a new data sender that will write log entries to a file, to be tailed by FluentBit and sent to the collector.

func (*FluentBitFileLogWriter) ConsumeLogs added in v0.13.0

func (f *FluentBitFileLogWriter) ConsumeLogs(_ context.Context, logs pdata.Logs) error

func (*FluentBitFileLogWriter) Extensions added in v0.9.0

func (f *FluentBitFileLogWriter) Extensions() map[string]string

func (*FluentBitFileLogWriter) Flush added in v0.9.0

func (f *FluentBitFileLogWriter) Flush()

func (*FluentBitFileLogWriter) GenConfigYAMLStr added in v0.9.0

func (f *FluentBitFileLogWriter) GenConfigYAMLStr() string

func (*FluentBitFileLogWriter) ProtocolName added in v0.9.0

func (f *FluentBitFileLogWriter) ProtocolName() string

func (*FluentBitFileLogWriter) Start added in v0.9.0

func (f *FluentBitFileLogWriter) Start() error

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, metricPairsFile 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) GenerateLogs added in v0.9.0

func (dp *GoldenDataProvider) GenerateLogs() (pdata.Logs, bool)

func (*GoldenDataProvider) GenerateMetrics added in v0.5.0

func (dp *GoldenDataProvider) GenerateMetrics() (pdata.Metrics, bool)

func (*GoldenDataProvider) GenerateTraces added in v0.5.0

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

func (*GoldenDataProvider) GetGeneratedSpan added in v0.5.0

func (dp *GoldenDataProvider) GetGeneratedSpan(traceID pdata.TraceID, spanID pdata.SpanID) *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 component.Factories) *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) 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 {
	DataSenderBase
	consumer.TracesConsumer
}

JaegerGRPCDataSender implements TraceDataSender for Jaeger thrift_http exporterType.

func NewJaegerGRPCDataSender

func NewJaegerGRPCDataSender(host string, port int) *JaegerGRPCDataSender

NewJaegerGRPCDataSender creates a new Jaeger exporterType 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, metric data points, or log
	// records to generate each second.
	DataItemsPerSecond int

	// ItemsPerBatch specifies how many spans, metric data points, or log
	// records 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

	// Parallel specifies how many goroutines to send from.
	Parallel int
}

LoadOptions defines the options to use for generating the load.

type LogDataSender added in v0.9.0

type LogDataSender interface {
	DataSender
	consumer.LogsConsumer
}

LogDataSender defines the interface that allows sending log data. It adds ability to send a batch of Logs to the DataSender interface.

type MetricDataSender

type MetricDataSender interface {
	DataSender
	consumer.MetricsConsumer
}

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
	ReceivedLogs    []pdata.Logs
	// 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) ConsumeLogs added in v0.9.0

func (mb *MockBackend) ConsumeLogs(ld pdata.Logs)

func (*MockBackend) ConsumeMetric

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

func (*MockBackend) ConsumeTrace

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

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 MockLogConsumer added in v0.9.0

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

func (*MockLogConsumer) ConsumeLogs added in v0.9.0

func (mc *MockLogConsumer) ConsumeLogs(_ context.Context, ld pdata.Logs) error

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) MockConsumeMetricData added in v0.9.0

func (mc *MockMetricConsumer) MockConsumeMetricData(metricsCount int) error

type MockMetricDataConsumer added in v0.9.0

type MockMetricDataConsumer interface {
	// MockConsumeMetricData receives metrics and counts the number of events received.
	MockConsumeMetricData(metricsCount int) error
}

type MockTraceConsumer

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

func (*MockTraceConsumer) ConsumeTraces

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

func (*MockTraceConsumer) MockConsumeTraceData added in v0.9.0

func (tc *MockTraceConsumer) MockConsumeTraceData(spansCount int) error

type MockTraceDataConsumer added in v0.9.0

type MockTraceDataConsumer interface {
	// MockConsumeTraceData receives traces and counts the number of events received.
	MockConsumeTraceData(spansCount int) error
}

MockDataConsumer is an interface that keeps the count of number of events received by mock receiver. This is mainly useful for the Exporters that are not have the matching receiver

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 {
	consumer.MetricsConsumer
	// contains filtered or unexported fields
}

OCMetricsDataSender implements MetricDataSender for OpenCensus metrics exporterType.

func NewOCMetricDataSender

func NewOCMetricDataSender(host string, port int) *OCMetricsDataSender

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

func (*OCMetricsDataSender) GenConfigYAMLStr

func (ods *OCMetricsDataSender) GenConfigYAMLStr() string

func (*OCMetricsDataSender) ProtocolName

func (ods *OCMetricsDataSender) ProtocolName() string

func (*OCMetricsDataSender) Start

func (ome *OCMetricsDataSender) Start() error

type OCTraceDataSender

type OCTraceDataSender struct {
	consumer.TracesConsumer
	// contains filtered or unexported fields
}

OCTraceDataSender implements TraceDataSender for OpenCensus trace exporterType.

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 (ods *OCTraceDataSender) GenConfigYAMLStr() string

func (*OCTraceDataSender) ProtocolName

func (ods *OCTraceDataSender) ProtocolName() string

func (*OCTraceDataSender) Start

func (ote *OCTraceDataSender) Start() error

type OTLPHTTPLogsDataSender added in v0.14.0

type OTLPHTTPLogsDataSender struct {
	consumer.LogsConsumer
	// contains filtered or unexported fields
}

OTLPHTTPLogsDataSender implements LogsDataSender for OTLP/HTTP logs exporterType.

func NewOTLPHTTPLogsDataSender added in v0.14.0

func NewOTLPHTTPLogsDataSender(host string, port int) *OTLPHTTPLogsDataSender

NewOTLPMetricDataSender creates a new OTLP/HTTP metric exporterType sender that will send to the specified port after Start is called.

func (*OTLPHTTPLogsDataSender) GenConfigYAMLStr added in v0.14.0

func (ods *OTLPHTTPLogsDataSender) GenConfigYAMLStr() string

func (*OTLPHTTPLogsDataSender) ProtocolName added in v0.14.0

func (ods *OTLPHTTPLogsDataSender) ProtocolName() string

func (*OTLPHTTPLogsDataSender) Start added in v0.14.0

func (olds *OTLPHTTPLogsDataSender) Start() error

type OTLPHTTPMetricsDataSender added in v0.14.0

type OTLPHTTPMetricsDataSender struct {
	consumer.MetricsConsumer
	// contains filtered or unexported fields
}

OTLPHTTPMetricsDataSender implements MetricDataSender for OTLP/HTTP metrics exporterType.

func NewOTLPHTTPMetricDataSender added in v0.14.0

func NewOTLPHTTPMetricDataSender(host string, port int) *OTLPHTTPMetricsDataSender

NewOTLPHTTPMetricDataSender creates a new OTLP/HTTP metric exporterType sender that will send to the specified port after Start is called.

func (*OTLPHTTPMetricsDataSender) GenConfigYAMLStr added in v0.14.0

func (ods *OTLPHTTPMetricsDataSender) GenConfigYAMLStr() string

func (*OTLPHTTPMetricsDataSender) ProtocolName added in v0.14.0

func (ods *OTLPHTTPMetricsDataSender) ProtocolName() string

func (*OTLPHTTPMetricsDataSender) Start added in v0.14.0

func (ome *OTLPHTTPMetricsDataSender) Start() error

type OTLPHTTPTraceDataSender added in v0.14.0

type OTLPHTTPTraceDataSender struct {
	consumer.TracesConsumer
	// contains filtered or unexported fields
}

OTLPHTTPTraceDataSender implements TraceDataSender for OTLP/HTTP trace exporterType.

func NewOTLPHTTPTraceDataSender added in v0.14.0

func NewOTLPHTTPTraceDataSender(host string, port int) *OTLPHTTPTraceDataSender

NewOTLPHTTPTraceDataSender creates a new TraceDataSender for OTLP/HTTP traces exporterType.

func (*OTLPHTTPTraceDataSender) GenConfigYAMLStr added in v0.14.0

func (ods *OTLPHTTPTraceDataSender) GenConfigYAMLStr() string

func (*OTLPHTTPTraceDataSender) ProtocolName added in v0.14.0

func (ods *OTLPHTTPTraceDataSender) ProtocolName() string

func (*OTLPHTTPTraceDataSender) Start added in v0.14.0

func (ote *OTLPHTTPTraceDataSender) Start() error

type OTLPLogsDataSender added in v0.13.0

type OTLPLogsDataSender struct {
	consumer.LogsConsumer
	// contains filtered or unexported fields
}

OTLPLogsDataSender implements LogsDataSender for OTLP logs exporterType.

func NewOTLPLogsDataSender added in v0.13.0

func NewOTLPLogsDataSender(host string, port int) *OTLPLogsDataSender

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

func (*OTLPLogsDataSender) GenConfigYAMLStr added in v0.13.0

func (ods *OTLPLogsDataSender) GenConfigYAMLStr() string

func (*OTLPLogsDataSender) ProtocolName added in v0.13.0

func (ods *OTLPLogsDataSender) ProtocolName() string

func (*OTLPLogsDataSender) Start added in v0.13.0

func (olds *OTLPLogsDataSender) Start() error

type OTLPMetricsDataSender

type OTLPMetricsDataSender struct {
	consumer.MetricsConsumer
	// contains filtered or unexported fields
}

OTLPMetricsDataSender implements MetricDataSender for OTLP metrics exporterType.

func NewOTLPMetricDataSender

func NewOTLPMetricDataSender(host string, port int) *OTLPMetricsDataSender

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

func (*OTLPMetricsDataSender) GenConfigYAMLStr

func (ods *OTLPMetricsDataSender) GenConfigYAMLStr() string

func (*OTLPMetricsDataSender) ProtocolName

func (ods *OTLPMetricsDataSender) ProtocolName() string

func (*OTLPMetricsDataSender) Start

func (ome *OTLPMetricsDataSender) Start() error

type OTLPTraceDataSender

type OTLPTraceDataSender struct {
	consumer.TracesConsumer
	// contains filtered or unexported fields
}

OTLPTraceDataSender implements TraceDataSender for OTLP trace exporterType.

func NewOTLPTraceDataSender

func NewOTLPTraceDataSender(host string, port int) *OTLPTraceDataSender

NewOTLPTraceDataSender creates a new TraceDataSender for OTLP traces exporterType.

func (*OTLPTraceDataSender) GenConfigYAMLStr

func (ods *OTLPTraceDataSender) GenConfigYAMLStr() string

func (*OTLPTraceDataSender) ProtocolName

func (ods *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) 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) GenerateLogs added in v0.9.0

func (dp *PerfTestDataProvider) GenerateLogs() (pdata.Logs, bool)

func (*PerfTestDataProvider) GenerateMetrics added in v0.5.0

func (dp *PerfTestDataProvider) GenerateMetrics() (pdata.Metrics, bool)

func (*PerfTestDataProvider) GenerateTraces added in v0.5.0

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

func (*PerfTestDataProvider) GetGeneratedSpan added in v0.5.0

func (dp *PerfTestDataProvider) GetGeneratedSpan(pdata.TraceID, pdata.SpanID) *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(_ 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 PrometheusDataReceiver added in v0.9.0

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

func NewPrometheusDataReceiver added in v0.9.0

func NewPrometheusDataReceiver(port int) *PrometheusDataReceiver

func (*PrometheusDataReceiver) GenConfigYAMLStr added in v0.9.0

func (dr *PrometheusDataReceiver) GenConfigYAMLStr() string

Generate exporter yaml

func (*PrometheusDataReceiver) ProtocolName added in v0.9.0

func (dr *PrometheusDataReceiver) ProtocolName() string

func (*PrometheusDataReceiver) Start added in v0.9.0

func (*PrometheusDataReceiver) Stop added in v0.9.0

func (dr *PrometheusDataReceiver) Stop() error

type PrometheusDataSender added in v0.9.0

type PrometheusDataSender struct {
	DataSenderBase
	consumer.MetricsConsumer
	// contains filtered or unexported fields
}

func NewPrometheusDataSender added in v0.9.0

func NewPrometheusDataSender(host string, port int) *PrometheusDataSender

func (*PrometheusDataSender) GenConfigYAMLStr added in v0.9.0

func (pds *PrometheusDataSender) GenConfigYAMLStr() string

func (*PrometheusDataSender) ProtocolName added in v0.9.0

func (pds *PrometheusDataSender) ProtocolName() string

func (*PrometheusDataSender) Start added in v0.9.0

func (pds *PrometheusDataSender) Start() error

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 {
	Name        string
	LogFilePath string
	CmdArgs     []string
	// 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 TraceAssertionFailure added in v0.10.0

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

func (TraceAssertionFailure) String added in v0.10.0

func (af TraceAssertionFailure) String() string

type TraceDataSender

type TraceDataSender interface {
	DataSender
	consumer.TracesConsumer
}

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 {
	DataSenderBase
	consumer.TracesConsumer
}

ZipkinDataSender implements TraceDataSender for Zipkin http exporterType.

func NewZipkinDataSender

func NewZipkinDataSender(host string, port int) *ZipkinDataSender

NewZipkinDataSender creates a new Zipkin exporterType 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