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
- Variables
- func DoTestMain(m *testing.M, resultsSummary TestResultsSummary)
- func GetAvailablePort(t *testing.T) int
- func SaveResults(resultsSummary TestResultsSummary)
- func Start(resultsSummary TestResultsSummary) error
- type BaseOTLPDataReceiver
- func (bor *BaseOTLPDataReceiver) GenConfigYAMLStr() string
- func (bor *BaseOTLPDataReceiver) ProtocolName() string
- func (bor *BaseOTLPDataReceiver) Start(tc consumer.Traces, mc consumer.Metrics, lc consumer.Logs) error
- func (bor *BaseOTLPDataReceiver) Stop() error
- func (bor *BaseOTLPDataReceiver) WithCompression(compression string) *BaseOTLPDataReceiver
- type CorrectnessResults
- type CorrectnessTestResult
- type CorrectnessTestValidator
- type DataProvider
- type DataReceiver
- type DataReceiverBase
- func (mb *DataReceiverBase) GetExporters() map[config.DataType]map[config.ComponentID]component.Exporter
- func (mb *DataReceiverBase) GetExtensions() map[config.ComponentID]component.Extension
- func (mb *DataReceiverBase) GetFactory(_ component.Kind, _ config.Type) component.Factory
- func (mb *DataReceiverBase) ReportFatalError(err error)
- type DataSender
- type DataSenderBase
- func (dsb *DataSenderBase) Flush()
- func (dsb *DataSenderBase) GetEndpoint() net.Addr
- func (dsb *DataSenderBase) GetExporters() map[config.DataType]map[config.ComponentID]component.Exporter
- func (dsb *DataSenderBase) GetExtensions() map[config.ComponentID]component.Extension
- func (dsb *DataSenderBase) GetFactory(_ component.Kind, _ config.Type) component.Factory
- func (dsb *DataSenderBase) ReportFatalError(err error)
- type FileDataProvider
- type LoadGenerator
- type LoadOptions
- type LogDataSender
- type MetricDataSender
- type MockBackend
- func (mb *MockBackend) ClearReceivedItems()
- func (mb *MockBackend) ConsumeLogs(ld pdata.Logs)
- func (mb *MockBackend) ConsumeMetric(md pdata.Metrics)
- func (mb *MockBackend) ConsumeTrace(td pdata.Traces)
- func (mb *MockBackend) DataItemsReceived() uint64
- func (mb *MockBackend) EnableRecording()
- func (mb *MockBackend) GetStats() string
- func (mb *MockBackend) Start() error
- func (mb *MockBackend) Stop()
- type MockLogConsumer
- type MockMetricConsumer
- type MockTraceConsumer
- type OtelcolRunner
- type PerfTestValidator
- type PerformanceResults
- type PerformanceTestResult
- type ResourceConsumption
- type ResourceSpec
- type StartParams
- type TestCase
- func (tc *TestCase) AgentMemoryInfo() (uint32, uint32, error)
- func (tc *TestCase) EnableRecording()
- func (tc *TestCase) Sleep(d time.Duration)
- func (tc *TestCase) StartAgent(args ...string)
- func (tc *TestCase) StartBackend()
- func (tc *TestCase) StartLoad(options LoadOptions)
- func (tc *TestCase) Stop()
- func (tc *TestCase) StopAgent()
- func (tc *TestCase) StopBackend()
- func (tc *TestCase) StopLoad()
- func (tc *TestCase) ValidateData()
- func (tc *TestCase) WaitFor(cond func() bool, errMsg ...interface{}) bool
- func (tc *TestCase) WaitForN(cond func() bool, duration time.Duration, errMsg ...interface{}) bool
- type TestCaseOption
- type TestCaseValidator
- type TestResultsSummary
- type TraceAssertionFailure
- type TraceDataSender
- func NewJaegerGRPCDataSender(host string, port int) TraceDataSender
- func NewOCTraceDataSender(host string, port int) TraceDataSender
- func NewOTLPHTTPTraceDataSender(host string, port int) TraceDataSender
- func NewOTLPTraceDataSender(host string, port int) TraceDataSender
- func NewZipkinDataSender(host string, port int) TraceDataSender
Constants ¶
const DefaultHost = "127.0.0.1"
const DefaultJaegerPort = 14250
const DefaultOCPort = 56565
const DefaultOTLPPort = 4317
Variables ¶
var GlobalConfig = struct { // DefaultAgentExeRelativeFile 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 childProcessCollector // that is passed to the TestCase. DefaultAgentExeRelativeFile string }{ DefaultAgentExeRelativeFile: "../../bin/otelcol_{{.GOOS}}_{{.GOARCH}}", }
GlobalConfig global config for testbed.
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 GetAvailablePort ¶
func SaveResults ¶
func SaveResults(resultsSummary TestResultsSummary)
func Start ¶
func Start(resultsSummary TestResultsSummary) error
Types ¶
type BaseOTLPDataReceiver ¶ added in v0.21.0
type BaseOTLPDataReceiver struct { DataReceiverBase // contains filtered or unexported fields }
BaseOTLPDataReceiver implements the OTLP format receiver.
func NewOTLPDataReceiver ¶
func NewOTLPDataReceiver(port int) *BaseOTLPDataReceiver
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) *BaseOTLPDataReceiver
NewOTLPHTTPDataReceiver creates a new OTLP/HTTP DataReceiver that will listen on the specified port after Start is called.
func (*BaseOTLPDataReceiver) GenConfigYAMLStr ¶ added in v0.21.0
func (bor *BaseOTLPDataReceiver) GenConfigYAMLStr() string
func (*BaseOTLPDataReceiver) ProtocolName ¶ added in v0.21.0
func (bor *BaseOTLPDataReceiver) ProtocolName() string
func (*BaseOTLPDataReceiver) Stop ¶ added in v0.21.0
func (bor *BaseOTLPDataReceiver) Stop() error
func (*BaseOTLPDataReceiver) WithCompression ¶ added in v0.21.0
func (bor *BaseOTLPDataReceiver) WithCompression(compression string) *BaseOTLPDataReceiver
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(senderName string, receiverName string, 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(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) // 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.
func NewGoldenDataProvider ¶ added in v0.5.0
func NewGoldenDataProvider(tracePairsFile string, spanPairsFile string, metricPairsFile string) DataProvider
NewGoldenDataProvider creates a new instance of goldenDataProvider which generates test data based on the pairwise combinations specified in the tracePairsFile and spanPairsFile input variables.
func NewPerfTestDataProvider ¶ added in v0.5.0
func NewPerfTestDataProvider(options LoadOptions) DataProvider
NewPerfTestDataProvider creates an instance of perfTestDataProvider which generates test data based on the sizes specified in the supplied LoadOptions.
type DataReceiver ¶
type DataReceiver interface { Start(tc consumer.Traces, mc consumer.Metrics, lc consumer.Logs) error Stop() error // GenConfigYAMLStr generates a config string to place in exporter part of collector config // so that it can send data to this receiver. GenConfigYAMLStr() string // ProtocolName returns 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 NewJaegerDataReceiver ¶
func NewJaegerDataReceiver(port int) DataReceiver
NewJaegerDataReceiver creates a new Jaeger DataReceiver that will listen on the specified port after Start is called.
func NewOCDataReceiver ¶
func NewOCDataReceiver(port int) DataReceiver
NewOCDataReceiver creates a new ocDataReceiver that will listen on the specified port after Start is called.
func NewPrometheusDataReceiver ¶ added in v0.9.0
func NewPrometheusDataReceiver(port int) DataReceiver
func NewZipkinDataReceiver ¶
func NewZipkinDataReceiver(port int) DataReceiver
NewZipkinDataReceiver creates a new Zipkin 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 (mb *DataReceiverBase) GetExporters() map[config.DataType]map[config.ComponentID]component.Exporter
func (*DataReceiverBase) GetExtensions ¶
func (mb *DataReceiverBase) GetExtensions() map[config.ComponentID]component.Extension
func (*DataReceiverBase) GetFactory ¶
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 // Flush sends any accumulated data. Flush() // GetEndpoint returns the address to which this sender will send data. GetEndpoint() net.Addr // GenConfigYAMLStr generates a config string to place in receiver part of collector config // so that it can receive data from this sender. GenConfigYAMLStr() string // ProtocolName returns exporter 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
func (*DataSenderBase) Flush ¶ added in v0.13.0
func (dsb *DataSenderBase) Flush()
func (*DataSenderBase) GetEndpoint ¶ added in v0.13.0
func (dsb *DataSenderBase) GetEndpoint() net.Addr
func (*DataSenderBase) GetExporters ¶ added in v0.13.0
func (dsb *DataSenderBase) GetExporters() map[config.DataType]map[config.ComponentID]component.Exporter
func (*DataSenderBase) GetExtensions ¶ added in v0.13.0
func (dsb *DataSenderBase) GetExtensions() map[config.ComponentID]component.Extension
func (*DataSenderBase) GetFactory ¶ added in v0.13.0
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 config.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) SetLoadGeneratorCounters ¶ added in v0.20.0
func (dp *FileDataProvider) SetLoadGeneratorCounters(dataItemsGenerated *atomic.Uint64)
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.
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.Logs }
LogDataSender defines the interface that allows sending log data. It adds ability to send a batch of Logs to the DataSender interface.
func NewOTLPHTTPLogsDataSender ¶ added in v0.14.0
func NewOTLPHTTPLogsDataSender(host string, port int) LogDataSender
NewOTLPHTTPLogsDataSender creates a new OTLP/HTTP logs exporter sender that will send to the specified port after Start is called.
func NewOTLPLogsDataSender ¶ added in v0.13.0
func NewOTLPLogsDataSender(host string, port int) LogDataSender
NewOTLPLogsDataSender creates a new OTLP logs exporter sender that will send to the specified port after Start is called.
type MetricDataSender ¶
type MetricDataSender interface { DataSender consumer.Metrics }
MetricDataSender defines the interface that allows sending metric data. It adds ability to send a batch of Metrics to the DataSender interface.
func NewOCMetricDataSender ¶
func NewOCMetricDataSender(host string, port int) MetricDataSender
NewOCMetricDataSender creates a new OpenCensus metric exporter sender that will send to the specified port after Start is called.
func NewOTLPHTTPMetricDataSender ¶ added in v0.14.0
func NewOTLPHTTPMetricDataSender(host string, port int) MetricDataSender
NewOTLPHTTPMetricDataSender creates a new OTLP/HTTP metrics exporter sender that will send to the specified port after Start is called.
func NewOTLPMetricDataSender ¶
func NewOTLPMetricDataSender(host string, port int) MetricDataSender
NewOTLPMetricDataSender creates a new OTLP metric exporter sender that will send to the specified port after Start is called.
func NewPrometheusDataSender ¶ added in v0.9.0
func NewPrometheusDataSender(host string, port int) MetricDataSender
NewPrometheusDataSender creates a new Prometheus sender that will expose data on the specified port after Start is called.
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
type MockLogConsumer ¶ added in v0.9.0
type MockLogConsumer struct {
// contains filtered or unexported fields
}
func (*MockLogConsumer) Capabilities ¶ added in v0.27.0
func (lc *MockLogConsumer) Capabilities() consumer.Capabilities
func (*MockLogConsumer) ConsumeLogs ¶ added in v0.9.0
type MockMetricConsumer ¶
type MockMetricConsumer struct {
// contains filtered or unexported fields
}
func (*MockMetricConsumer) Capabilities ¶ added in v0.27.0
func (mc *MockMetricConsumer) Capabilities() consumer.Capabilities
func (*MockMetricConsumer) ConsumeMetrics ¶
func (*MockMetricConsumer) MockConsumeMetricData ¶ added in v0.9.0
func (mc *MockMetricConsumer) MockConsumeMetricData(metricsCount int) error
type MockTraceConsumer ¶
type MockTraceConsumer struct {
// contains filtered or unexported fields
}
func (*MockTraceConsumer) Capabilities ¶ added in v0.27.0
func (tc *MockTraceConsumer) Capabilities() consumer.Capabilities
func (*MockTraceConsumer) ConsumeTraces ¶
func (*MockTraceConsumer) MockConsumeTraceData ¶ added in v0.9.0
func (tc *MockTraceConsumer) MockConsumeTraceData(spanCount int) 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) // Start 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 // Stop 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.
func NewChildProcessCollector ¶ added in v0.30.0
func NewChildProcessCollector() OtelcolRunner
NewChildProcessCollector crewtes a new OtelcolRunner as a child process on the same machine executing the test.
func NewInProcessCollector ¶ added in v0.5.0
func NewInProcessCollector(factories component.Factories) OtelcolRunner
NewInProcessCollector crewtes a new inProcessCollector using the supplied component factories.
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 ResourceConsumption ¶
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 TestCase ¶
type TestCase struct { Sender DataSender LoadGenerator *LoadGenerator MockBackend *MockBackend // 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 ¶
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) StartAgent ¶
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) 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) WaitForN ¶
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 func(t *TestCase)
TestCaseOption defines a TestCase option.
func WithResourceLimits ¶ added in v0.29.0
func WithResourceLimits(resourceSpec ResourceSpec) TestCaseOption
WithResourceLimits 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 WithSkipResults ¶
func WithSkipResults() TestCaseOption
WithSkipResults disables writing out results file for a TestCase.
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 { // Init creates 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.Traces }
TraceDataSender defines the interface that allows sending trace data. It adds ability to send a batch of Spans to the DataSender interface.
func NewJaegerGRPCDataSender ¶
func NewJaegerGRPCDataSender(host string, port int) TraceDataSender
NewJaegerGRPCDataSender creates a new Jaeger exporter sender that will send to the specified port after Start is called.
func NewOCTraceDataSender ¶
func NewOCTraceDataSender(host string, port int) TraceDataSender
NewOCTraceDataSender creates a new ocTracesDataSender that will send to the specified port after Start is called.
func NewOTLPHTTPTraceDataSender ¶ added in v0.14.0
func NewOTLPHTTPTraceDataSender(host string, port int) TraceDataSender
NewOTLPHTTPTraceDataSender creates a new TraceDataSender for OTLP/HTTP traces exporter.
func NewOTLPTraceDataSender ¶
func NewOTLPTraceDataSender(host string, port int) TraceDataSender
NewOTLPTraceDataSender creates a new TraceDataSender for OTLP traces exporter.
func NewZipkinDataSender ¶
func NewZipkinDataSender(host string, port int) TraceDataSender
NewZipkinDataSender creates a new Zipkin exporter sender that will send to the specified port after Start is called.