Documentation
¶
Index ¶
- func BuildArgs(flags map[string]string) []string
- func EmptyFlags() map[string]string
- func EqualsAmongTwo(sums ...float64) bool
- func EqualsSingle(expected float64) func(float64) bool
- func GreaterAmongTwo(sums ...float64) bool
- func LessAmongTwo(sums ...float64) bool
- func MergeFlags(inputs ...map[string]string) map[string]string
- func MergeFlagsWithoutRemovingEmpty(inputs ...map[string]string) map[string]string
- func StartAndWaitReady(runnables ...Runnable) error
- func SumValues(values []float64) float64
- type CmdReadinessProbe
- type Command
- type CompositeInstrumentedRunnable
- func (s *CompositeInstrumentedRunnable) Instances() []*InstrumentedRunnable
- func (s *CompositeInstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
- func (s *CompositeInstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
- func (s *CompositeInstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
- type DockerEnvironment
- type Environment
- type EnvironmentOption
- type ErrRunnable
- func (ErrRunnable) Dir() string
- func (ErrRunnable) Endpoint(string) string
- func (r ErrRunnable) Exec(Command) (string, string, error)
- func (r ErrRunnable) Init(StartOptions) Runnable
- func (ErrRunnable) InternalDir() string
- func (ErrRunnable) InternalEndpoint(string) string
- func (ErrRunnable) IsRunning() bool
- func (r ErrRunnable) Kill() error
- func (r ErrRunnable) Name() string
- func (r ErrRunnable) Start() error
- func (r ErrRunnable) Stop() error
- func (r ErrRunnable) WaitReady() error
- type FutureInstrumentedRunnable
- type FutureRunnable
- type HTTPReadinessProbe
- type InstrumentedRunnable
- func (r *InstrumentedRunnable) Metrics() (_ string, err error)
- func (r *InstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
- func (r *InstrumentedRunnable) WaitRemovedMetric(metricName string, opts ...MetricsOption) error
- func (r *InstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
- func (r *InstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
- type LinePrefixLogger
- type Linkable
- type Logger
- type MetricValueExpectation
- type MetricsOption
- type ReadinessProbe
- type Runnable
- type SimpleLogger
- type StartOptions
- type TCPReadinessProbe
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmptyFlags ¶
func EqualsAmongTwo ¶
EqualsAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is equal to the second. NOTE: Be careful on scrapes in between of process that changes two metrics. Those are usually not atomic.
func EqualsSingle ¶
func GreaterAmongTwo ¶
GreaterAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is greater than second. NOTE: Be careful on scrapes in between of process that changes two metrics. Those are usually not atomic.
func LessAmongTwo ¶
LessAmongTwo is an isExpected function for WaitSumMetrics that returns true if first sum is smaller than second. NOTE: Be careful on scrapes in between of process that changes two metrics. Those are usually not atomic.
func StartAndWaitReady ¶
Types ¶
type CmdReadinessProbe ¶
type CmdReadinessProbe struct {
// contains filtered or unexported fields
}
CmdReadinessProbe checks readiness by `Exec`ing a command (within container) which returns 0 to consider status being ready.
func NewCmdReadinessProbe ¶
func NewCmdReadinessProbe(cmd Command) *CmdReadinessProbe
func (*CmdReadinessProbe) Ready ¶
func (p *CmdReadinessProbe) Ready(runnable Runnable) error
type CompositeInstrumentedRunnable ¶
type CompositeInstrumentedRunnable struct {
// contains filtered or unexported fields
}
CompositeInstrumentedRunnable abstract an higher-level service composed by more than one InstrumentedRunnable.
func NewCompositeInstrumentedRunnable ¶
func NewCompositeInstrumentedRunnable(runnables ...*InstrumentedRunnable) *CompositeInstrumentedRunnable
func (*CompositeInstrumentedRunnable) Instances ¶
func (s *CompositeInstrumentedRunnable) Instances() []*InstrumentedRunnable
func (*CompositeInstrumentedRunnable) SumMetrics ¶
func (s *CompositeInstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
SumMetrics returns the sum of the values of each given metric names.
func (*CompositeInstrumentedRunnable) WaitSumMetrics ¶
func (s *CompositeInstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
WaitSumMetrics waits for at least one instance of each given metric names to be present and their sums, returning true when passed to given expected(...).
func (*CompositeInstrumentedRunnable) WaitSumMetricsWithOptions ¶
func (s *CompositeInstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
type DockerEnvironment ¶
type DockerEnvironment struct {
// contains filtered or unexported fields
}
DockerEnvironment defines single node docker engine that allows to run Services.
func NewDockerEnvironment ¶
func NewDockerEnvironment(name string, opts ...EnvironmentOption) (*DockerEnvironment, error)
NewDockerEnvironment creates new, isolated docker environment.
func (*DockerEnvironment) Close ¶
func (e *DockerEnvironment) Close()
func (*DockerEnvironment) FutureRunnable ¶
func (e *DockerEnvironment) FutureRunnable(name string, ports map[string]int) FutureRunnable
func (*DockerEnvironment) Runnable ¶
func (e *DockerEnvironment) Runnable(name string, ports map[string]int, opts StartOptions) Runnable
func (*DockerEnvironment) SharedDir ¶
func (e *DockerEnvironment) SharedDir() string
type Environment ¶
type Environment interface {
// Runnable returns instance of runnable which can be started and stopped within this environment.
Runnable(name string, Ports map[string]int, opts StartOptions) Runnable
// FutureRunnable returns instance of runnable which can be started and stopped within this environment.
FutureRunnable(name string, Ports map[string]int) FutureRunnable
// Close shutdowns isolated environment and cleans it's resources.
Close()
}
Environment defines how to run Runnable in isolated area e.g via docker in isolated docker network.
type EnvironmentOption ¶
type EnvironmentOption func(*environmentOptions)
EnvironmentOption defined the signature of a function used to manipulate options.
func WithLogger ¶
func WithLogger(logger Logger) EnvironmentOption
WithLogger tells environment to use custom logger to default one (stdout).
func WithVerbose ¶
func WithVerbose() EnvironmentOption
WithVerbose tells environment to be verbose i.e print all commands it executes.
type ErrRunnable ¶
type ErrRunnable struct {
// contains filtered or unexported fields
}
func NewErrRunnable ¶
func NewErrRunnable(name string, err error) ErrRunnable
func (ErrRunnable) Dir ¶
func (ErrRunnable) Dir() string
func (ErrRunnable) Endpoint ¶
func (ErrRunnable) Endpoint(string) string
func (ErrRunnable) Init ¶
func (r ErrRunnable) Init(StartOptions) Runnable
func (ErrRunnable) InternalDir ¶
func (ErrRunnable) InternalDir() string
func (ErrRunnable) InternalEndpoint ¶
func (ErrRunnable) InternalEndpoint(string) string
func (ErrRunnable) IsRunning ¶
func (ErrRunnable) IsRunning() bool
func (ErrRunnable) Kill ¶
func (r ErrRunnable) Kill() error
func (ErrRunnable) Name ¶
func (r ErrRunnable) Name() string
func (ErrRunnable) Start ¶
func (r ErrRunnable) Start() error
func (ErrRunnable) Stop ¶
func (r ErrRunnable) Stop() error
func (ErrRunnable) WaitReady ¶
func (r ErrRunnable) WaitReady() error
type FutureInstrumentedRunnable ¶
type FutureInstrumentedRunnable struct {
FutureRunnable
// contains filtered or unexported fields
}
func NewFutureInstrumentedRunnable ¶
func NewFutureInstrumentedRunnable( env Environment, name string, ports map[string]int, metricPortName string, ) *FutureInstrumentedRunnable
func (*FutureInstrumentedRunnable) Init ¶
func (r *FutureInstrumentedRunnable) Init(opts StartOptions) *InstrumentedRunnable
type FutureRunnable ¶
type FutureRunnable interface {
Linkable
// Init transforms future into runnable.
Init(opts StartOptions) Runnable
}
type HTTPReadinessProbe ¶
type HTTPReadinessProbe struct {
// contains filtered or unexported fields
}
HTTPReadinessProbe checks readiness by making HTTP call and checking for expected HTTP status code.
func NewHTTPReadinessProbe ¶
func NewHTTPReadinessProbe(portName string, path string, expectedStatusRangeStart, expectedStatusRangeEnd int, expectedContent ...string) *HTTPReadinessProbe
func (*HTTPReadinessProbe) Ready ¶
func (p *HTTPReadinessProbe) Ready(runnable Runnable) (err error)
type InstrumentedRunnable ¶
type InstrumentedRunnable struct {
Runnable
// contains filtered or unexported fields
}
InstrumentedRunnable represents opinionated microservice with one port marked as HTTP port with metric endpoint.
func NewInstrumentedRunnable ¶
func NewInstrumentedRunnable(env Environment, name string, ports map[string]int, metricPortName string, opts StartOptions) *InstrumentedRunnable
func (*InstrumentedRunnable) Metrics ¶
func (r *InstrumentedRunnable) Metrics() (_ string, err error)
func (*InstrumentedRunnable) SumMetrics ¶
func (r *InstrumentedRunnable) SumMetrics(metricNames []string, opts ...MetricsOption) ([]float64, error)
SumMetrics returns the sum of the values of each given metric names.
func (*InstrumentedRunnable) WaitRemovedMetric ¶
func (r *InstrumentedRunnable) WaitRemovedMetric(metricName string, opts ...MetricsOption) error
WaitRemovedMetric waits until a metric disappear from the list of metrics exported by the service.
func (*InstrumentedRunnable) WaitSumMetrics ¶
func (r *InstrumentedRunnable) WaitSumMetrics(expected MetricValueExpectation, metricNames ...string) error
WaitSumMetrics waits for at least one instance of each given metric names to be present and their sums, returning true when passed to given expected(...).
func (*InstrumentedRunnable) WaitSumMetricsWithOptions ¶
func (r *InstrumentedRunnable) WaitSumMetricsWithOptions(expected MetricValueExpectation, metricNames []string, opts ...MetricsOption) error
type LinePrefixLogger ¶
type LinePrefixLogger struct {
// contains filtered or unexported fields
}
type Linkable ¶
type Linkable interface {
// Name returns unique name for the Runnable instance.
Name() string
// Dir returns host working directory path for this runnable.
Dir() string
// InternalDir returns local, environment working directory path for this runnable.
InternalDir() string
// InternalEndpoint returns internal runnable endpoint (host:port) for given internal port.
// Internal means that it will be accessible only from runnable context.
InternalEndpoint(portName string) string
}
Linkable is the entity that one can use to link runnable to other runnables before started.
type Logger ¶
type Logger interface {
Log(keyvals ...interface{}) error
}
Logger is the fundamental interface for all log operations. Log creates a log event from keyvals, a variadic sequence of alternating keys and values. Implementations must be safe for concurrent use by multiple goroutines. In particular, any implementation of Logger that appends to keyvals or modifies or retains any of its elements must make a copy first. This is 1:1 copy of "github.com/go-kit/kit/log" interface.
type MetricValueExpectation ¶
func Equals ¶
func Equals(value float64) MetricValueExpectation
Equals is an MetricValueExpectation function for WaitSumMetrics that returns true if given single sum is equals to given value.
func Greater ¶
func Greater(value float64) MetricValueExpectation
Greater is an isExpected function for WaitSumMetrics that returns true if given single sum is greater than given value.
func GreaterOrEqual ¶
func GreaterOrEqual(value float64) MetricValueExpectation
GreaterOrEqual is an isExpected function for WaitSumMetrics that returns true if given single sum is greater or equal than given value.
func Less ¶
func Less(value float64) MetricValueExpectation
Less is an isExpected function for WaitSumMetrics that returns true if given single sum is less than given value.
type MetricsOption ¶
type MetricsOption func(*metricsOptions)
MetricsOption defined the signature of a function used to manipulate options.
func SkipMissingMetrics ¶
func SkipMissingMetrics() MetricsOption
SkipMissingMetrics is an option to skip/ignore whenever an expected metric is missing.
func WaitMissingMetrics ¶
func WaitMissingMetrics() MetricsOption
WaitMissingMetrics is an option to wait whenever an expected metric is missing. If this option is not enabled, will return error on missing metrics.
func WithLabelMatchers ¶
func WithLabelMatchers(matchers ...*matchers.Matcher) MetricsOption
WithLabelMatchers is an option to filter only matching series.
func WithMetricCount ¶
func WithMetricCount() MetricsOption
WithMetricCount is an option to get the histogram/summary count as metric value.
type ReadinessProbe ¶
type Runnable ¶
type Runnable interface {
Linkable
// IsRunning returns if runnable was started.
IsRunning() bool
// Start tells Runnable to start.
Start() error
// WaitReady waits until the Runnable is ready. It should return error if runnable is stopped in mean time or
// it was stopped before.
WaitReady() error
// Kill tells Runnable to get killed immediately.
// It should be ok to Stop and Kill more than once, with next invokes being noop.
Kill() error
// Stop tells Runnable to get gracefully stopped.
// It should be ok to Stop and Kill more than once, with next invokes being noop.
Stop() error
// Exec runs the provided command inside the same process context (e.g in the docker container).
// It returns the stdout, stderr, and error response from attempting to run the command.
Exec(command Command) (string, string, error)
// Endpoint returns external runnable endpoint (host:port) for given port name.
// External means that it will be accessible only from host, but not from docker containers.
//
// If your service is not running, this method returns incorrect `stopped` endpoint.
Endpoint(portName string) string
}
Runnable is the entity that environment returns to manage single instance.
type SimpleLogger ¶
type SimpleLogger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger(w io.Writer) *SimpleLogger
func (*SimpleLogger) Log ¶
func (l *SimpleLogger) Log(keyvals ...interface{}) error
type StartOptions ¶
type TCPReadinessProbe ¶
type TCPReadinessProbe struct {
// contains filtered or unexported fields
}
TCPReadinessProbe checks readiness by ensure a TCP connection can be established.
func NewTCPReadinessProbe ¶
func NewTCPReadinessProbe(portName string) *TCPReadinessProbe
func (*TCPReadinessProbe) Ready ¶
func (p *TCPReadinessProbe) Ready(runnable Runnable) (err error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package e2edb is a reference, instrumented runnables that are running various popular databases one could run in their tests or benchmarks.
|
Package e2edb is a reference, instrumented runnables that are running various popular databases one could run in their tests or benchmarks. |
|
examples
|
|
|
thanos
module
|
|
|
internal
|
|