Documentation
¶
Overview ¶
Package equivalence runs the same workload through two storage backends and asserts they produce equivalent results across every reader method.
The harness drives the canonical GrantRecord path through both the v3 Pebble engine and a reference implementation (a deterministic in-memory map). For each case we Put N grants, then for each reader method (GetGrantRecord, IterateGrants, IterateGrantsByEntitlement, IterateGrantsByPrincipal) we compare the returned set against the reference.
The runner is intentionally pluggable: additional engines can register as References when their adapters expose this contract.
Index ¶
- Variables
- func Compare(ctx context.Context, refA, refB Reference, w Workload) error
- func Equal(a, b *Result) error
- type MemoryRef
- func (m *MemoryRef) DeleteGrantRecord(_ context.Context, externalID string) error
- func (m *MemoryRef) GetGrantRecord(_ context.Context, externalID string) (*v3.GrantRecord, error)
- func (m *MemoryRef) IterateGrants(_ context.Context, yield func(*v3.GrantRecord) bool) error
- func (m *MemoryRef) IterateGrantsByEntitlement(_ context.Context, entitlementID string, yield func(*v3.GrantRecord) bool) error
- func (m *MemoryRef) IterateGrantsByPrincipal(_ context.Context, principalRT, principalID string, ...) error
- func (m *MemoryRef) PutGrantRecord(_ context.Context, r *v3.GrantRecord) error
- func (m *MemoryRef) SetCurrentSync(ctx context.Context, syncID string) error
- type Op
- type OpKind
- type Reference
- type Result
- type Workload
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("equivalence: reference doesn't implement this method")
ErrNotImplemented is returned by reference adapters that don't support a method.
Functions ¶
Types ¶
type MemoryRef ¶
type MemoryRef struct {
// contains filtered or unexported fields
}
MemoryRef is a deterministic in-memory implementation of Reference, used as the source-of-truth in equivalence tests. Backed by a nested map keyed by (sync_id, external_id). All operations are linearizable under MemoryRef.mu.
Iteration order is by external_id (lexicographic) for stable ordering across runs.
func NewMemoryRef ¶
func NewMemoryRef() *MemoryRef
NewMemoryRef returns an empty in-memory reference.
func (*MemoryRef) DeleteGrantRecord ¶
func (*MemoryRef) GetGrantRecord ¶
func (*MemoryRef) IterateGrants ¶ added in v0.15.0
func (*MemoryRef) IterateGrantsByEntitlement ¶
func (*MemoryRef) IterateGrantsByPrincipal ¶
func (*MemoryRef) PutGrantRecord ¶
type Op ¶
type Op struct {
Kind OpKind
Record *v3.GrantRecord // nil for OpDelete
DeleteExternalID string
}
Op is one operation in a workload.
type Reference ¶
type Reference interface {
PutGrantRecord(ctx context.Context, r *v3.GrantRecord) error
GetGrantRecord(ctx context.Context, externalID string) (*v3.GrantRecord, error)
IterateGrants(ctx context.Context, yield func(*v3.GrantRecord) bool) error
IterateGrantsByEntitlement(ctx context.Context, entitlementID string, yield func(*v3.GrantRecord) bool) error
IterateGrantsByPrincipal(ctx context.Context, principalRT, principalID string, yield func(*v3.GrantRecord) bool) error
}
Reference is the minimal store contract the equivalence runner drives. Both the Pebble engine and the in-memory reference satisfy it; future SQLite + translation shims can be wired in by adding a new adapter.
type Result ¶
type Result struct {
BySyncCount int
ByEntitlementCount map[string]int
ByPrincipalCount map[string]int
GetSpotChecks map[string]bool // externalID -> present
}
Result is the per-Reference output collected at the end of a workload, in a form that's directly comparable across implementations.