Documentation
¶
Overview ¶
Package enginetest is the conformance suite the metric and record engines share: the part lifecycle, index-commit and repair invariants both must hold, written once against an Engine adapter. The adapters live in each engine's external test package, so this package imports neither engine.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyObjects ¶
CopyObjects copies every object under prefix from src to dst, which is what a repair fetch does to the objects of a part it pulls back. It fails t when prefix holds nothing.
Types ¶
type Answer ¶
type Answer func(w bucketindex.Want) (bucketindex.Entry, bucketindex.WantOutcome, error)
Answer is how a Fetcher answers one want.
type Config ¶
type Config struct {
Backend backend.Backend
Repair bucketindex.PartFetcher
WAL *wal.SegmentWriter
Obs *obs.Obs
// WriterID names the writer whose flush watermark the engine keeps in the bucket index.
WriterID string
// OrphanGrace and Now are the engine's orphan-sweep age guard and its clock.
OrphanGrace time.Duration
Now func() time.Time
// MergeCapBytes is the merge cap in the unit of [Part.Bytes]; 0 keeps the engine's derived cap.
MergeCapBytes int64
// Term is the writer's ownership term; nil is a writer with no cluster.
Term func() uint64
}
Config is what the suite varies when opening an engine; everything else is the adapter's.
type Engine ¶
type Engine interface {
Store
Loader
Introspector
Repairer
}
Engine is one engine adapted for the suite. Methods that share a name with the engine's own mean the same thing.
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher stands in for the cluster layer's part-sync pull: it records what repair asked for and answers with Answer, so the engine half of the seam runs without a peer, a transport or a syncer. A nil Answer reports every want absent.
func AnswerAlways ¶
func AnswerAlways(outcome bucketindex.WantOutcome, err error) *Fetcher
AnswerAlways returns a Fetcher giving every want the same outcome.
func (*Fetcher) Calls ¶
Calls reports how many batches repair issued: one per cycle, whatever the want count.
func (*Fetcher) FetchWants ¶
func (f *Fetcher) FetchWants(_ context.Context, wants []bucketindex.Want) []bucketindex.FetchResult
FetchWants implements bucketindex.PartFetcher.
type Introspector ¶
type Introspector interface {
// AttrNames returns every Attr key the engine can serve.
AttrNames(t *testing.T) []string
// StreamCount is the number of distinct stream identities the engine knows.
StreamCount() int
// HeadRows is the number of rows buffered in the head.
HeadRows() int
Parts() []Part
PartCount() int
PartPrefixes() []string
Stats() Stats
// MergeShape is the merge shape under a retention cutoff (≤ 0 disables it).
MergeShape(retainFrom int64) MergeShape
// LoadState is every field an index load replaces, comparable with assert.Equal.
LoadState() any
}
Introspector is what the engine reports about itself.
type Kind ¶
type Kind struct {
// Name names the subtest: "metrics" or "records".
Name string
// Prefix is the backend key prefix every engine Open returns writes under.
Prefix string
Open func(t *testing.T, cfg Config) Engine
// Identity is the identity the engine gives stream.
Identity func(stream string) signal.Series
// LegacyIdentityObject is the whole-set identity object older builds wrote at the prefix.
LegacyIdentityObject string
// Erodes reports whether an object key is one a partially lost part no longer has.
Erodes func(key string) bool
// IdentitySeed and IdentityRatio tune [Run]'s write-amplification check: the second flush of one
// new stream must write under 1/IdentityRatio of the first flush's IdentitySeed streams.
IdentitySeed, IdentityRatio int
}
Kind is one engine the suite runs against.
type Loader ¶
type Loader interface {
LoadParts(ctx context.Context) error
LoadPartsUnclaimed(ctx context.Context) error
LoadPartsReadOnly(ctx context.Context) error
RefreshReplica(ctx context.Context) error
ReloadFenced(ctx context.Context) error
Replay(ctx context.Context, dir string) error
WALState() (segments int, bytes int64, epoch uint64, ok bool)
}
Loader is how an engine recovers state from its backend and WAL.
type MergeShape ¶
MergeShape is the subset of the engine's merge shape the suite asserts on.
type Part ¶
type Part struct {
ID string
MinTime, MaxTime int64
// Bytes is the size the merge selector weighs the part at.
Bytes int64
}
Part is one live part as [Engine.Parts] reports it.
type Repairer ¶
type Repairer interface {
LosePart(prefix string, blocks bucketindex.Interval)
AdoptWants(ws []bucketindex.Want)
SetPartBlocks(prefix string, blocks bucketindex.Interval, level uint32)
WantPrefixes() []string
HasWants() bool
WantOverlaps(start, end int64) bool
Holes() []bucketindex.Entry
LostParts() uint64
RepairStats() bucketindex.RepairStats
}
Repairer is the repair-obligation surface, including the test-only LosePart and SetPartBlocks.
type Row ¶
type Row struct {
Stream string
Ts int64
Val int64
// Attr is an optional key and value: a series label for metrics, a record attribute for records.
Attr [2]string
}
Row is one sample or record. Val is a sample's value, or a record's body in decimal.
type Stats ¶
type Stats struct {
HeadAge time.Duration
WantedParts int
Holes int
LostParts uint64
IndexFenced bool
// TenureUnestablished is a clustered engine whose tenure's first commit has not landed.
TenureUnestablished bool
}
Stats is the subset of the engine's stats the suite asserts on.
type Store ¶
type Store interface {
// Append buffers rows in the head, failing t on error.
Append(t *testing.T, rows ...Row)
// Read returns every row stream holds, in the engine's fetch order, with Attr unset.
Read(ctx context.Context, stream string) ([]Row, error)
Flush(ctx context.Context) error
Merge(ctx context.Context, retainFrom int64) error
// BackgroundMerge runs automatic maintenance, or a forced automatic turn.
BackgroundMerge(ctx context.Context, retainFrom int64, force bool) (bool, error)
// ForceMerge merges every part into one, whatever the merge policy would pick.
ForceMerge(ctx context.Context) error
Reset(ctx context.Context) error
HeadBytes() int64
}
Store is the write, read and maintenance path.
Source Files
¶
- blockid.go
- corruptexit.go
- deferredsync.go
- enginetest.go
- fetcher.go
- flushfail.go
- forcedcap.go
- groupsuccessor.go
- headage.go
- heldpart.go
- helpers.go
- hole.go
- lifecycle.go
- loadfence.go
- lostpart.go
- mergecommit.go
- nestedrepair.go
- orphanpart.go
- partidentity.go
- publishorder.go
- repair.go
- repairfetch.go
- repairobs.go
- replica.go
- replicatrim.go
- retention.go
- retention_background.go
- splitlineage.go
- straddle.go
- tenure.go
- tenurefence.go
- walepoch.go
- wants.go
- widesplit.go