Documentation
¶
Index ¶
- func Contains(substring string) containsMatcher
- func GreaterThan[T cmp.Ordered](value T) greaterThanMatcher[T]
- func HasLen[T any](length int) hasLenMatcher[T]
- func Is[T comparable](value T) isMatcher[T]
- func IsNull[T any]() isNullMatcher[T]
- func LessThan[T cmp.Ordered](value T) lessThanMatcher[T]
- func Matches(pattern string) patternMatcher
- func NodeLogPath(challengeKey, nodeName string) string
- func NodesWithLogs(challengeKey string) ([]string, error)
- func Not[T any](matcher Matcher[T]) notMatcher[T]
- func OneOf[T comparable](values ...T) oneOfMatcher[T]
- func RenderLogs(challengeKey string, nodeNames []string) error
- type Check
- func (c *Check) Body(matchers ...Matcher[string]) *Check
- func (c *Check) Consistently(timeout time.Duration) *Check
- func (c *Check) Eventually(timeout time.Duration) *Check
- func (c *Check) Header(name string, matchers ...Matcher[string]) *Check
- func (c *Check) Hint(help string) *Check
- func (c *Check) JSON(path string, matchers ...Matcher[string]) *Check
- func (c *Check) Run()
- func (c *Check) Status(matchers ...Matcher[int]) *Check
- type Do
- func (do *Do) AllNodes(names ...string) NodeSelector
- func (do *Do) AtLeastOneNode(names ...string) NodeSelector
- func (do *Do) Cancel()
- func (do *Do) Concurrently(n int, fn func(i int))
- func (do *Do) DELETE(sel NodeSelector, path string, args ...any) *Check
- func (do *Do) Done()
- func (do *Do) ExactlyOneNode(names ...string) NodeSelector
- func (do *Do) ExceptNodes(names ...string) NodeSelector
- func (do *Do) Fetch(name, path string) *FetchResponse
- func (do *Do) GET(sel NodeSelector, path string, args ...any) *Check
- func (do *Do) Heal()
- func (do *Do) Impair(sel NodeSelector, impairments ...Impairment)
- func (do *Do) Kill(name string)
- func (do *Do) MockNode(name, port string)
- func (do *Do) Names(sel NodeSelector) []string
- func (do *Do) Nodes() []string
- func (do *Do) PATCH(sel NodeSelector, path string, args ...any) *Check
- func (do *Do) POST(sel NodeSelector, path string, args ...any) *Check
- func (do *Do) PUT(sel NodeSelector, path string, args ...any) *Check
- func (do *Do) Partition(groups ...[]string)
- func (do *Do) Repair(sel ...NodeSelector)
- func (do *Do) Restart(name string, sig ...syscall.Signal)
- func (do *Do) Settle(d time.Duration)
- func (do *Do) Start(name string)
- func (do *Do) Stop(name string)
- type FetchResponse
- type H
- type Impairment
- type JSONFieldMatcher
- type Matcher
- type NodeSelector
- type Option
- func WithChallenge(key string) Option
- func WithCluster(n int) Option
- func WithClusterSettleDuration(d time.Duration) Option
- func WithConcurrencyLimit(n int) Option
- func WithNodeShutdownTimeout(d time.Duration) Option
- func WithNodeStartupTimeout(d time.Duration) Option
- func WithPollInterval(d time.Duration) Option
- func WithRequestTimeout(d time.Duration) Option
- type Suite
- type TestFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains(substring string) containsMatcher
Contains creates a matcher that checks if actual contains the substring.
func GreaterThan ¶ added in v0.4.4
GreaterThan creates a matcher that asserts actual > value.
func HasLen ¶
HasLen creates a matcher that validates the length of arrays, slices, maps, channels, or strings.
func Is ¶
func Is[T comparable](value T) isMatcher[T]
Is creates a matcher that validates exact equality.
func IsNull ¶
func IsNull[T any]() isNullMatcher[T]
IsNull creates a matcher that checks if a value is nil.
func Matches ¶
func Matches(pattern string) patternMatcher
Matches creates a matcher that checks if actual matches the regex pattern.
func NodeLogPath ¶ added in v0.4.14
NodeLogPath returns the path to the log file for the given challenge and node.
func NodesWithLogs ¶ added in v0.4.18
NodesWithLogs returns logical node names that have log files for the given challenge.
func OneOf ¶
func OneOf[T comparable](values ...T) oneOfMatcher[T]
OneOf creates a matcher that accepts any of the provided values.
func RenderLogs ¶ added in v0.4.18
RenderLogs reads log files for the given nodes and prints them interleaved by timestamp.
Types ¶
type Check ¶ added in v0.4.7
type Check struct {
// contains filtered or unexported fields
}
Check describes an HTTP request and the conditions its response must satisfy.
func (*Check) Body ¶ added in v0.4.7
Body adds expected HTTP response body matchers. All matchers must pass.
func (*Check) Consistently ¶ added in v0.4.7
Consistently configures the assertion to verify success for the entire duration.
func (*Check) Eventually ¶ added in v0.4.7
Eventually configures the assertion to retry until success or timeout.
func (*Check) Header ¶ added in v0.4.7
Header adds matchers for the named response header. All matchers must pass.
func (*Check) JSON ¶ added in v0.4.7
JSON adds expected matchers for a JSON field at the given gjson path. All matchers must pass.
type Do ¶
type Do struct {
// contains filtered or unexported fields
}
Do provides the test harness and acts as the test runner.
func (*Do) AllNodes ¶ added in v0.4.4
func (do *Do) AllNodes(names ...string) NodeSelector
AllNodes returns a selector that passes when every node satisfies the assertion. If names are provided, only those nodes are checked.
func (*Do) AtLeastOneNode ¶ added in v0.4.4
func (do *Do) AtLeastOneNode(names ...string) NodeSelector
AtLeastOneNode returns a selector that passes when at least one node satisfies the assertion. If names are provided, only those nodes are checked.
func (*Do) Concurrently ¶
Concurrently runs fn n times in parallel.
func (*Do) DELETE ¶ added in v0.4.0
func (do *Do) DELETE(sel NodeSelector, path string, args ...any) *Check
DELETE creates a Check for an HTTP DELETE request.
func (*Do) Done ¶
func (do *Do) Done()
Done cancels the test context and stops all nodes. Containers are left in place so they can be inspected after a failure; they will be cleaned up at the start of the next run.
func (*Do) ExactlyOneNode ¶ added in v0.4.4
func (do *Do) ExactlyOneNode(names ...string) NodeSelector
ExactlyOneNode returns a selector that passes when exactly one node satisfies the assertion. If names are provided, only those nodes are checked.
func (*Do) ExceptNodes ¶ added in v0.4.19
func (do *Do) ExceptNodes(names ...string) NodeSelector
ExceptNodes returns a selector targeting all alive nodes except those specified.
func (*Do) Fetch ¶ added in v0.4.4
func (do *Do) Fetch(name, path string) *FetchResponse
Fetch makes a GET request to the named node and returns the raw response. Returns nil if the request fails (e.g. node is down).
func (*Do) GET ¶ added in v0.4.0
func (do *Do) GET(sel NodeSelector, path string, args ...any) *Check
GET creates a Check for an HTTP GET request.
func (*Do) Heal ¶ added in v0.4.1
func (do *Do) Heal()
Heal flushes all iptables rules on every node, restoring full connectivity.
func (*Do) Impair ¶ added in v0.4.19
func (do *Do) Impair(sel NodeSelector, impairments ...Impairment)
Impair applies network impairments to outgoing traffic on the selected nodes.
func (*Do) Names ¶ added in v0.4.19
func (do *Do) Names(sel NodeSelector) []string
Names resolves a selector to the node names it targets.
func (*Do) PATCH ¶ added in v0.4.0
func (do *Do) PATCH(sel NodeSelector, path string, args ...any) *Check
PATCH creates a Check for an HTTP PATCH request.
func (*Do) POST ¶ added in v0.4.0
func (do *Do) POST(sel NodeSelector, path string, args ...any) *Check
POST creates a Check for an HTTP POST request.
func (*Do) PUT ¶ added in v0.4.0
func (do *Do) PUT(sel NodeSelector, path string, args ...any) *Check
PUT creates a Check for an HTTP PUT request.
func (*Do) Partition ¶ added in v0.4.1
Partition installs iptables DROP rules so nodes in different groups cannot reach each other. Rules are bidirectional.
func (*Do) Repair ¶ added in v0.4.19
func (do *Do) Repair(sel ...NodeSelector)
Repair removes tc netem impairments from the selected nodes. If no selector is given, all nodes are repaired.
func (*Do) Restart ¶
Restart restarts the node. Pass syscall.SIGKILL to crash immediately instead of graceful shutdown.
func (*Do) Settle ¶ added in v0.4.16
Settle pauses for the given duration to let the cluster settle.
type FetchResponse ¶ added in v0.4.4
FetchResponse is the result of a Fetch call.
func (*FetchResponse) JSON ¶ added in v0.4.4
func (r *FetchResponse) JSON(path string) string
JSON returns the string value at the given gjson path.
type Impairment ¶ added in v0.4.19
type Impairment struct {
// contains filtered or unexported fields
}
Impairment describes a network condition applied to a node's outgoing traffic via tc netem.
func Delay ¶ added in v0.4.19
func Delay(d time.Duration, jitter ...time.Duration) Impairment
Delay adds a fixed latency to outgoing packets. An optional jitter value adds random variation: delay ± jitter.
func Duplicate ¶ added in v0.4.19
func Duplicate(pct float64) Impairment
Duplicate sends a percentage of outgoing packets twice.
func Loss ¶ added in v0.4.19
func Loss(pct float64) Impairment
Loss randomly drops a percentage of outgoing packets.
func Reorder ¶ added in v0.4.19
func Reorder(pct float64) Impairment
Reorder delivers a percentage of packets out of order. Must be combined with Delay. Without it, all packets go out immediately and no reordering occurs.
type JSONFieldMatcher ¶ added in v0.4.7
type JSONFieldMatcher struct {
// contains filtered or unexported fields
}
JSONFieldMatcher pairs a gjson path with a matcher for that field.
func JSON ¶
func JSON(path string, matcher Matcher[string]) JSONFieldMatcher
JSON creates a matcher that extracts a JSON field at the given path and validates it.
func (JSONFieldMatcher) Check ¶ added in v0.4.7
func (m JSONFieldMatcher) Check(actual string) bool
func (JSONFieldMatcher) Expected ¶ added in v0.4.7
func (m JSONFieldMatcher) Expected() string
type Matcher ¶ added in v0.4.7
type Matcher[T any] interface { // Check returns true if actual satisfies this matcher's condition. Check(actual T) bool // Expected returns a human-readable description of what was expected. Expected() string }
Matcher is a composable predicate used in assertions to validate actual values against expected conditions.
type NodeSelector ¶ added in v0.4.4
type NodeSelector struct {
// contains filtered or unexported fields
}
NodeSelector targets one or more nodes for an HTTP assertion.
func Node ¶ added in v0.4.0
func Node(name string) NodeSelector
Node returns a selector targeting a specific named node.
type Option ¶ added in v0.4.0
type Option func(*config)
Option configures a Suite.
func WithChallenge ¶ added in v0.4.5
WithChallenge sets the challenge key used to namespace Docker resources.
func WithCluster ¶ added in v0.4.0
WithCluster declares N nodes named n1, n2, ... nN.
func WithClusterSettleDuration ¶ added in v0.4.16
WithClusterSettleDuration sets how long Partition and Heal wait after topology changes for in-flight RPCs to drain and timeouts to expire.
func WithConcurrencyLimit ¶ added in v0.5.3
WithConcurrencyLimit sets the maximum number of goroutines that Concurrently runs at once, and sizes the HTTP connection pool to match.
func WithNodeShutdownTimeout ¶ added in v0.4.0
WithNodeShutdownTimeout sets how long to wait for a node to exit before sending SIGKILL.
func WithNodeStartupTimeout ¶ added in v0.5.2
WithNodeStartupTimeout sets how long to wait for a node to accept connections after starting.
func WithPollInterval ¶ added in v0.4.0
WithPollInterval sets how often Eventually and Consistently poll.
func WithRequestTimeout ¶ added in v0.4.0
WithRequestTimeout sets the HTTP client timeout per request.
type Suite ¶
type Suite struct {
// contains filtered or unexported fields
}
Suite represents a test suite with setup and test functions.