testbed

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 72 Imported by: 3

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"
	DefaultOTLPPort = 4317
)

TODO: Move these constants.

Variables

View Source
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/oteltestbedcol_{{.GOOS}}_{{.GOARCH}}",
}

GlobalConfig global config for testbed.

Functions

func Components added in v0.42.0

func Components() (
	otelcol.Factories,
	error,
)

Components returns the set of components for tests

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 GenerateNonPernamentErrorUntil added in v0.92.0

func GenerateNonPernamentErrorUntil(ch chan bool) error

func GetAvailablePort deprecated

func GetAvailablePort(t testing.TB) int

Deprecated: [v0.94.0] Use `testutil.GetAvailablePort(t testing.TB)` instead

func RandomNonPermanentError added in v0.88.0

func RandomNonPermanentError() error

randomNonPermanentError is a decision function that succeeds approximately half of the time and fails with a non-permanent error the rest of the time.

func RandomPermanentError added in v0.88.0

func RandomPermanentError() error

randomPermanentError is a decision function that succeeds approximately half of the time and fails with a permanent error the rest of the time.

func SaveResults

func SaveResults(resultsSummary TestResultsSummary)

func Start

func Start(resultsSummary TestResultsSummary) error

Types

type BaseOTLPDataReceiver

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

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

func (bor *BaseOTLPDataReceiver) GenConfigYAMLStr() string

func (*BaseOTLPDataReceiver) ProtocolName

func (bor *BaseOTLPDataReceiver) ProtocolName() string

func (*BaseOTLPDataReceiver) Start

func (*BaseOTLPDataReceiver) Stop

func (bor *BaseOTLPDataReceiver) Stop() error

func (*BaseOTLPDataReceiver) WithCompression

func (bor *BaseOTLPDataReceiver) WithCompression(compression string) *BaseOTLPDataReceiver

func (*BaseOTLPDataReceiver) WithQueue added in v0.88.0

func (bor *BaseOTLPDataReceiver) WithQueue(sendingQueue string) *BaseOTLPDataReceiver

func (*BaseOTLPDataReceiver) WithRetry added in v0.88.0

func (bor *BaseOTLPDataReceiver) WithRetry(retry string) *BaseOTLPDataReceiver

type ChildProcessOption added in v0.80.0

type ChildProcessOption func(*childProcessCollector)

func WithAgentExePath added in v0.80.0

func WithAgentExePath(exePath string) ChildProcessOption

WithAgentExePath sets the path of the Collector executable

func WithEnvVar added in v0.93.0

func WithEnvVar(k, v string) ChildProcessOption

WithEnvVar sets an additional environment variable for the process

type CorrectnessResults

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

func (r *CorrectnessResults) Add(_ string, result any)

func (*CorrectnessResults) Init

func (r *CorrectnessResults) Init(resultsDir string)

func (*CorrectnessResults) Save

func (r *CorrectnessResults) Save()

type CorrectnessTestResult

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

CorrectnessTestResult reports the results of a single correctness test.

type CorrectnessTestValidator

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

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

func NewCorrectTestValidator

func NewCorrectTestValidator(senderName string, receiverName string, provider DataProvider) *CorrectnessTestValidator

func (*CorrectnessTestValidator) RecordResults

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

func (*CorrectnessTestValidator) Validate

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

type DataProvider

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() (ptrace.Traces, bool)
	// GenerateMetrics returns an internal MetricData instance with an OTLP ResourceMetrics slice of test data.
	GenerateMetrics() (pmetric.Metrics, bool)
	// GenerateLogs returns the internal plog.Logs format
	GenerateLogs() (plog.Logs, bool)
}

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

func NewGoldenDataProvider

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

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: 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.

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 ProviderSender. Note the terminology: DataSender is something that sends data to Collector and the corresponding entity that receives the data in the Collector is a receiver.

type DataSenderBase

type DataSenderBase struct {
	Port int
	Host string
}

func (*DataSenderBase) Flush

func (dsb *DataSenderBase) Flush()

func (*DataSenderBase) GetEndpoint

func (dsb *DataSenderBase) GetEndpoint() net.Addr

type FileDataProvider

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

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

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

func (*FileDataProvider) GenerateLogs

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

func (*FileDataProvider) GenerateMetrics

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

func (*FileDataProvider) GenerateTraces

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

func (*FileDataProvider) SetLoadGeneratorCounters

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

type LoadGenerator

type LoadGenerator interface {
	Start(options LoadOptions)
	Stop()
	IsReady() bool
	DataItemsSent() uint64
	IncDataItemsSent()
	PermanentErrors() uint64
	GetStats() string
}

LoadGenerator is intended to be exercised by a TestCase to generate and send telemetry to an OtelcolRunner instance. The simplest ready implementation is the ProviderSender that unites a DataProvider with a DataSender.

func NewLoadGenerator

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

NewLoadGenerator creates a ProviderSender to send DataProvider-generated telemetry via a DataSender.

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

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

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

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 LogPresentResults added in v0.92.0

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

type LogPresentValidator added in v0.92.0

type LogPresentValidator struct {
	LogBody string
	Present bool
}

func (*LogPresentValidator) RecordResults added in v0.92.0

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

func (*LogPresentValidator) Validate added in v0.92.0

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

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 NewOTLPHTTPMetricDataSender

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.

type MockBackend

type MockBackend struct {
	ReceivedTraces  []ptrace.Traces
	ReceivedMetrics []pmetric.Metrics
	ReceivedLogs    []plog.Logs

	DroppedTraces  []ptrace.Traces
	DroppedMetrics []pmetric.Metrics
	DroppedLogs    []plog.Logs

	LogsToRetry []plog.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

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

func (*MockBackend) ConsumeMetric

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

func (*MockBackend) ConsumeTrace

func (mb *MockBackend) ConsumeTrace(td ptrace.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) Start

func (mb *MockBackend) Start() error

Start a backend.

func (*MockBackend) Stop

func (mb *MockBackend) Stop()

Stop the backend

func (*MockBackend) WithDecisionFunc added in v0.88.0

func (mb *MockBackend) WithDecisionFunc(decision decisionFunc)

type MockLogConsumer

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

func (*MockLogConsumer) Capabilities

func (lc *MockLogConsumer) Capabilities() consumer.Capabilities

func (*MockLogConsumer) ConsumeLogs

func (lc *MockLogConsumer) ConsumeLogs(_ context.Context, ld plog.Logs) error

type MockMetricConsumer

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

func (*MockMetricConsumer) Capabilities

func (mc *MockMetricConsumer) Capabilities() consumer.Capabilities

func (*MockMetricConsumer) ConsumeMetrics

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

func (*MockMetricConsumer) MockConsumeMetricData

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

type MockTraceConsumer

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

func (*MockTraceConsumer) Capabilities

func (tc *MockTraceConsumer) Capabilities() consumer.Capabilities

func (*MockTraceConsumer) ConsumeTraces

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

func (*MockTraceConsumer) MockConsumeTraceData

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

type OtelcolRunner

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

func NewChildProcessCollector(options ...ChildProcessOption) OtelcolRunner

NewChildProcessCollector creates a new OtelcolRunner as a child process on the same machine executing the test.

func NewInProcessCollector

func NewInProcessCollector(factories otelcol.Factories) OtelcolRunner

NewInProcessCollector creates a new inProcessCollector using the supplied component factories.

type PerfTestValidator

type PerfTestValidator struct{}

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

func (*PerfTestValidator) RecordResults

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

func (*PerfTestValidator) Validate

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

type PerformanceResults

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

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

func (*PerformanceResults) Add

func (r *PerformanceResults) Add(_ string, result any)

Add results for one test.

func (*PerformanceResults) Init

func (r *PerformanceResults) Init(resultsDir string)

func (*PerformanceResults) Save

func (r *PerformanceResults) Save()

Save the total results and close the file.

type PerformanceTestResult

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

PerformanceTestResult reports the results of a single performance test.

type ProviderSender added in v0.93.0

type ProviderSender struct {
	Provider DataProvider
	Sender   DataSender
	// contains filtered or unexported fields
}

ProviderSender is a simple load generator.

func (*ProviderSender) DataItemsSent added in v0.93.0

func (ps *ProviderSender) DataItemsSent() uint64

func (*ProviderSender) GetStats added in v0.93.0

func (ps *ProviderSender) GetStats() string

GetStats returns the stats as a printable string.

func (*ProviderSender) IncDataItemsSent added in v0.93.0

func (ps *ProviderSender) IncDataItemsSent()

IncDataItemsSent is used when a test bypasses the ProviderSender and sends data directly via its Sender. This is necessary so that the total number of sent items in the end is correct, because the reports are printed from ProviderSender'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 (*ProviderSender) IsReady added in v0.93.0

func (ps *ProviderSender) IsReady() bool

func (*ProviderSender) NonPermanentErrors added in v0.93.0

func (ps *ProviderSender) NonPermanentErrors() uint64

func (*ProviderSender) PermanentErrors added in v0.93.0

func (ps *ProviderSender) PermanentErrors() uint64

func (*ProviderSender) Start added in v0.93.0

func (ps *ProviderSender) Start(options LoadOptions)

Start the load.

func (*ProviderSender) Stop added in v0.93.0

func (ps *ProviderSender) Stop()

Stop the load.

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

	// The number of consecutive violations necessary to trigger a failure.
	// This is useful for tests which can tolerate transitory violations.
	MaxConsecutiveFailures uint32
}

ResourceSpec is a resource consumption specification.

type StartParams

type StartParams struct {
	Name        string
	LogFilePath string
	CmdArgs     []string
	// contains filtered or unexported fields
}

type TestCase

type TestCase struct {
	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 NewLoadGeneratorTestCase added in v0.93.0

func NewLoadGeneratorTestCase(t *testing.T, loadGenerator LoadGenerator, receiver DataReceiver, agentProc OtelcolRunner, validator TestCaseValidator, resultsSummary TestResultsSummary, opts ...TestCaseOption) *TestCase

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) AgentLogsContains added in v0.92.0

func (tc *TestCase) AgentLogsContains(text string) bool

Used to search for text in agent.log It can be used to verify if we've hit QueuedRetry sender or memory limiter

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) ComposeTestResultFileName added in v0.90.0

func (tc *TestCase) ComposeTestResultFileName(fileName string) string

func (*TestCase) EnableRecording

func (tc *TestCase) EnableRecording()

EnableRecording enables recording of all data received by MockBackend.

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 ProviderSender.

func (*TestCase) WaitFor

func (tc *TestCase) WaitFor(cond func() bool, errMsg any) 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 any) 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 func(t *TestCase)

TestCaseOption defines a TestCase option.

func WithDecisionFunc added in v0.88.0

func WithDecisionFunc(decision decisionFunc) TestCaseOption

WithDecision enables our mock backend to behave sporadically

func WithResourceLimits

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

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

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

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

type TraceAssertionFailure

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

func (TraceAssertionFailure) String

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 NewOTLPHTTPTraceDataSender

func NewOTLPHTTPTraceDataSender(host string, port int, compression configcompression.Type) 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.

Jump to

Keyboard shortcuts

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