Documentation
¶
Index ¶
- Constants
- func ContextWithTimeout(tc TestContext, duration time.Duration) context.Context
- func DefaultContext(tc TestContext) context.Context
- func DefaultNotifyContext(duration time.Duration, cleanup func(func())) context.Context
- func GetMetricValue(metrics NodeMetrics, name string, labels prometheus.Labels) (float64, bool)
- func LoggerForFormat(prefix string, rawLogFormat string) (logging.Logger, error)
- func NewDefaultLogger(prefix string) logging.Logger
- func Outf(format string, args ...interface{})
- func WithDefaultContext(tc TestContext) common.Option
- type ErrorfHandler
- type NodeMetrics
- type NodesMetrics
- type PanicHandler
- type PrometheusServer
- type SimpleNodeMetrics
- type SimpleNodesMetrics
- type SimpleTestContext
- func (tc *SimpleTestContext) By(msg string, callback ...func())
- func (tc *SimpleTestContext) ContextWithTimeout(duration time.Duration) context.Context
- func (tc *SimpleTestContext) DefaultContext() context.Context
- func (tc *SimpleTestContext) DeferCleanup(cleanup func())
- func (tc *SimpleTestContext) Errorf(format string, args ...any)
- func (tc *SimpleTestContext) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msg string)
- func (*SimpleTestContext) FailNow()
- func (tc *SimpleTestContext) GetDefaultContextParent() context.Context
- func (tc *SimpleTestContext) Log() logging.Logger
- func (tc *SimpleTestContext) Recover()
- func (tc *SimpleTestContext) RecoverAndExit()
- func (tc *SimpleTestContext) RecoverAndRethrow()
- func (tc *SimpleTestContext) SetDefaultContextParent(parent context.Context)
- func (tc *SimpleTestContext) WithDefaultContext() common.Option
- type TestContext
Constants ¶
const DefaultTimeout = 2 * time.Minute
A long default timeout used to timeout failed operations but unlikely to induce flaking due to unexpected resource contention.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTimeout ¶
func ContextWithTimeout(tc TestContext, duration time.Duration) context.Context
Helper simplifying use of a timed context by canceling the context with the test context.
func DefaultContext ¶
func DefaultContext(tc TestContext) context.Context
Helper simplifying use of a timed context configured with the default timeout.
func DefaultNotifyContext ¶
DefaultNotifyContext returns a context that is marked done when signals indicating process termination are received. If a non-zero duration is provided, the parent to the notify context will be a context with a timeout for that duration.
func GetMetricValue ¶
func GetMetricValue(metrics NodeMetrics, name string, labels prometheus.Labels) (float64, bool)
GetMetricValue returns the value of the specified metric which has the required labels.
If multiple metrics match the provided labels, the first metric found is returned.
Only Counter and Gauge metrics are supported.
func LoggerForFormat ¶
TODO(marun) Does/should the logging package have a function like this?
func NewDefaultLogger ¶
func Outf ¶ added in v1.1.11
func Outf(format string, args ...interface{})
Outputs to stdout.
Examples:
- Out("{{green}}{{bold}}hi there %q{{/}}", "aa")
- Out("{{magenta}}{{bold}}hi therea{{/}} {{cyan}}{{underline}}b{{/}}")
See https://github.com/onsi/ginkgo/blob/v2.0.0/formatter/formatter.go#L52-L73 for an exhaustive list of color options.
func WithDefaultContext ¶ added in v0.15.6
func WithDefaultContext(tc TestContext) common.Option
Helper simplifying use via an option of a timed context configured with the default timeout.
Types ¶
type ErrorfHandler ¶ added in v1.11.14
type NodeMetrics ¶
type NodeMetrics map[string]*dto.MetricFamily
"metric name" -> "metric value"
func GetNodeMetrics ¶
func GetNodeMetrics(ctx context.Context, nodeURI string) (NodeMetrics, error)
GetNodeMetrics retrieves the specified metrics the provided node URI.
type NodesMetrics ¶
type NodesMetrics map[string]NodeMetrics
URI -> "metric name" -> "metric value"
func GetNodesMetrics ¶
func GetNodesMetrics(ctx context.Context, nodeURIs []string) (NodesMetrics, error)
GetNodesMetrics retrieves the specified metrics for the provided node URIs.
type PanicHandler ¶ added in v1.11.14
type PanicHandler func(any)
type PrometheusServer ¶
type PrometheusServer struct {
// contains filtered or unexported fields
}
PrometheusServer is a HTTP server that serves Prometheus metrics from the provided gahterer. Listens on localhost with a dynamic port and serves metrics at /ext/metric.
func NewPrometheusServer ¶
func NewPrometheusServer(gatherer prometheus.Gatherer) (*PrometheusServer, error)
NewPrometheusServer creates and starts a Prometheus server with the provided gatherer listening on 127.0.0.1:0 and serving /ext/metric.
func (*PrometheusServer) Address ¶
func (s *PrometheusServer) Address() string
Address returns the address the server is listening on. If the server has not started, the address will be empty.
func (*PrometheusServer) Stop ¶
func (s *PrometheusServer) Stop() error
Stop gracefully shuts down the Prometheus server. Waits for the server to shut down and returns any error that occurred during shutdown.
type SimpleNodeMetrics ¶ added in v1.1.11
"metric name" -> "metric value"
func GetMetricsValue ¶ added in v1.1.11
func GetMetricsValue(url string, metrics ...string) (SimpleNodeMetrics, error)
func GetSimpleNodeMetrics ¶ added in v1.1.11
func GetSimpleNodeMetrics(nodeURI string, metricNames ...string) (SimpleNodeMetrics, error)
GetSimpleNodeMetrics retrieves the specified metrics the provided node URI.
type SimpleNodesMetrics ¶ added in v1.1.11
type SimpleNodesMetrics map[string]SimpleNodeMetrics
URI -> "metric name" -> "metric value"
func GetSimpleNodesMetrics ¶ added in v1.1.11
func GetSimpleNodesMetrics(nodeURIs []string, metricNames ...string) (SimpleNodesMetrics, error)
GetSimpleNodesMetrics retrieves the specified metrics for the provided node URIs.
type SimpleTestContext ¶
type SimpleTestContext struct {
// contains filtered or unexported fields
}
func NewTestContext ¶
func NewTestContext(log logging.Logger) *SimpleTestContext
func NewTestContextWithArgs ¶ added in v1.11.14
func NewTestContextWithArgs( ctx context.Context, log logging.Logger, errorfHandler ErrorfHandler, panicHandler PanicHandler, ) *SimpleTestContext
func (*SimpleTestContext) By ¶
func (tc *SimpleTestContext) By(msg string, callback ...func())
func (*SimpleTestContext) ContextWithTimeout ¶
func (tc *SimpleTestContext) ContextWithTimeout(duration time.Duration) context.Context
Helper simplifying use of a timed context by canceling the context on ginkgo teardown.
func (*SimpleTestContext) DefaultContext ¶
func (tc *SimpleTestContext) DefaultContext() context.Context
Helper simplifying use of a timed context configured with the default timeout.
func (*SimpleTestContext) DeferCleanup ¶
func (tc *SimpleTestContext) DeferCleanup(cleanup func())
func (*SimpleTestContext) Errorf ¶
func (tc *SimpleTestContext) Errorf(format string, args ...any)
func (*SimpleTestContext) Eventually ¶
func (*SimpleTestContext) FailNow ¶
func (*SimpleTestContext) FailNow()
func (*SimpleTestContext) GetDefaultContextParent ¶ added in v1.11.14
func (tc *SimpleTestContext) GetDefaultContextParent() context.Context
func (*SimpleTestContext) Log ¶
func (tc *SimpleTestContext) Log() logging.Logger
func (*SimpleTestContext) Recover ¶ added in v1.11.14
func (tc *SimpleTestContext) Recover()
Recover is intended to be deferred in a function executing a test whose assertions may result in panics. Such a panic is intended to be recovered to allow cleanup functions to be called before execution continues.
func (*SimpleTestContext) RecoverAndExit ¶ added in v1.11.14
func (tc *SimpleTestContext) RecoverAndExit()
RecoverAndExit is intended to be deferred by the caller to ensure cleanup functions are called before exit or re-panic (in the event of an unexpected panic or a panic during cleanup).
func (*SimpleTestContext) RecoverAndRethrow ¶ added in v1.11.14
func (tc *SimpleTestContext) RecoverAndRethrow()
RecoverAndRethrow is intended to be deferred in a function executing a test whose assertions may result in panics. Such a panic is intended to be recovered to allow cleanup functions to be called before the panic is rethrown.
func (*SimpleTestContext) SetDefaultContextParent ¶ added in v1.11.14
func (tc *SimpleTestContext) SetDefaultContextParent(parent context.Context)
func (*SimpleTestContext) WithDefaultContext ¶ added in v0.15.6
func (tc *SimpleTestContext) WithDefaultContext() common.Option
Helper simplifying use via an option of a timed context configured with the default timeout.
type TestContext ¶
type TestContext interface {
// Ensures the context can be used to instantiate a require instance
require.TestingT
// Ensures compatibility with ginkgo.By
By(text string, callback ...func())
// Provides a simple alternative to ginkgo.DeferCleanup
DeferCleanup(cleanup func())
// Returns a logger that can be used to log test output
Log() logging.Logger
// Context helpers requiring cleanup with DeferCleanup
ContextWithTimeout(duration time.Duration) context.Context
DefaultContext() context.Context
WithDefaultContext() common.Option
// The parent context to use as the parent of default contexts
GetDefaultContextParent() context.Context
// Ensures compatibility with require.Eventually
Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msg string)
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
avalanchego
command
|
|
|
avalanchego/gencomposeconfig
command
|
|
|
luxd/gencomposeconfig
command
|
|
|
xsvm/gencomposeconfig
command
|
|
|
c
AUTOMATICALLY GENERATED.
|
AUTOMATICALLY GENERATED. |
|
bootstrapmonitor/cmd
command
|
|
|
tmpnet/cmd
command
|
|
|
tmpnet/tmpnetctl
command
|
|
|
main
command
|