Documentation
¶
Overview ¶
Package load is the engine behind the Berth API-level load driver (test/load). It drives the lease API through pkg/client under a set of named scenarios, records client-observed latency, and produces a summary suitable for CI assertions. It holds no flag parsing or process wiring — that lives in the thin test/load entrypoint — so the scenarios stay unit-testable against an in-process server.
Index ¶
Constants ¶
const ( OpAcquire = "acquire" OpRenew = "renew" OpRelease = "release" )
Operation labels group recorded latencies by the API call that produced them. They are the keys in a Summary.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Namespace is the lease namespace all generated leases live under.
Namespace string
// Tenant, when non-empty, scopes every generated holder under "<tenant>/" so
// the API server's holder authorization accepts them. Set it to the key id
// (tenant) the driver authenticates as; leave it empty for unauthenticated
// (auth-mode=none) or in-process runs, where holder authorization is bypassed.
Tenant string
// Backend is an informational tag recorded in the summary (e.g. "k8s",
// "sql"); it does not change driver behavior.
Backend string
Scenario Scenario
// Leases is the number of distinct leases driven.
Leases int
// Pairs is the number of region pairs; used only to label leases by region
// for reporting. Must divide into Leases conceptually but is not enforced.
Pairs int
TTL time.Duration
Heartbeat time.Duration
// Duration bounds the sustained scenarios (steady, churn). Ignored by the
// one-shot scenarios (coldstart, failover).
Duration time.Duration
// Concurrency bounds in-flight requests during burst phases (initial
// acquire, failover reclaim). The sustained scenarios run one goroutine per
// lease regardless, since the point is to keep every lease active.
Concurrency int
// ChurnFraction is the per-heartbeat probability that a held lease is
// released and re-acquired by a fresh holder. Only used by ScenarioChurn.
ChurnFraction float64
}
Config is the fully-resolved driver configuration. The thin entrypoint builds it from flags; Config.Validate enforces invariants.
type LeaseClient ¶
type LeaseClient interface {
Acquire(ctx context.Context, namespace, name, holder string, ttl time.Duration) (client.AcquireResult, error)
Renew(ctx context.Context, namespace, name, holder string, fencingToken int32, ttl time.Duration) (client.AcquireResult, error)
Release(ctx context.Context, namespace, name, holder string, fencingToken int32) error
}
LeaseClient is the subset of client.Client the scenarios use. It is an interface so tests can substitute a fake and the scenarios can run against an in-process server.
type OpResult ¶
type OpResult struct {
Count int `json:"count"`
Errors int `json:"errors"`
Min time.Duration `json:"-"`
Max time.Duration `json:"-"`
Mean time.Duration `json:"-"`
P50 time.Duration `json:"-"`
P95 time.Duration `json:"-"`
P99 time.Duration `json:"-"`
P999 time.Duration `json:"-"`
MinMS float64 `json:"minMs"`
MaxMS float64 `json:"maxMs"`
MeanMS float64 `json:"meanMs"`
P50MS float64 `json:"p50Ms"`
P95MS float64 `json:"p95Ms"`
P99MS float64 `json:"p99Ms"`
P999MS float64 `json:"p999Ms"`
}
OpResult is the latency distribution for a single operation.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder accumulates per-operation latency samples across all worker goroutines. It is safe for concurrent use. An optional hook is invoked on every observation so the entrypoint can mirror samples into Prometheus without coupling this package to a metrics library.
func NewRecorder ¶
NewRecorder returns an empty Recorder. hook may be nil.
type Scenario ¶
type Scenario string
Scenario names the load shape to run. The shapes mirror the sizing model in docs/operations/scalability.md.
const ( // ScenarioSteady holds N leases and renews them at heartbeat cadence while // a standby contends for each — the steady-state holder + denied-acquire // load. ScenarioSteady Scenario = "steady" // ScenarioColdStart fires all acquires near-simultaneously, modeling every // holder racing for its lease inside the first heartbeat window. ScenarioColdStart Scenario = "coldstart" // ScenarioFailover lets the failover half of the leases expire while the // survivor half keeps renewing, and times the standby acquire-after-expiry // that reclaims the expired half against that concurrent renew load. ScenarioFailover Scenario = "failover" // ScenarioChurn renews steadily while a fraction of holders release and a // fresh holder re-acquires each heartbeat. ScenarioChurn Scenario = "churn" )
type Summary ¶
type Summary struct {
Scenario string `json:"scenario"`
Backend string `json:"backend,omitempty"`
Leases int `json:"leases"`
Pairs int `json:"pairs"`
TTLMS float64 `json:"ttlMs"`
ElapsedMS float64 `json:"elapsedMs"`
Ops map[string]OpResult `json:"ops"`
}
Summary is the full result of a run, keyed by operation label.