Documentation
¶
Overview ¶
Package sessiontesting holds runner-independent session test fixtures and storage decorators shared by every backend's conformance and benchmarks.
Index ¶
- func RunConformance(t *testing.T, cases []ConformanceCase)
- type CommitDiscarded
- type ConformanceCase
- type GatingStorage
- func (storage *GatingStorage) Arm()
- func (storage *GatingStorage) Commit(ctx context.Context, writes []session.Write) (session.CommitResult, error)
- func (storage *GatingStorage) Discard()
- func (storage *GatingStorage) Next(count int) error
- func (storage *GatingStorage) Pending() int
- func (storage *GatingStorage) WaitPending(count int) error
- type InstrumentedStorage
- type StorageDecorator
- type StorageFixture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunConformance ¶
func RunConformance(t *testing.T, cases []ConformanceCase)
RunConformance registers every case as a subtest grouped by Group.
Types ¶
type CommitDiscarded ¶
type CommitDiscarded struct{ Message string }
CommitDiscarded rejects every commit after simulated storage loss.
func (*CommitDiscarded) Error ¶
func (err *CommitDiscarded) Error() string
type ConformanceCase ¶
ConformanceCase is a runner-independent conformance case; register each with t.Run(testCase.Group+"/"+testCase.Name, testCase.Run).
type GatingStorage ¶
type GatingStorage struct {
StorageDecorator
// contains filtered or unexported fields
}
GatingStorage is a test-only decorator that deterministically parks admitted commits once armed.
func NewGatingStorage ¶
func NewGatingStorage(delegate session.Storage) *GatingStorage
NewGatingStorage wraps delegate; setup commits bypass gating until Arm.
func (*GatingStorage) Commit ¶
func (storage *GatingStorage) Commit(ctx context.Context, writes []session.Write) (session.CommitResult, error)
Commit parks an armed commit until Next releases it, then delegates.
func (*GatingStorage) Discard ¶
func (storage *GatingStorage) Discard()
Discard drops parked commits and permanently rejects every later commit.
func (*GatingStorage) Next ¶
func (storage *GatingStorage) Next(count int) error
Next releases count commits in FIFO order, returning after each lands.
func (*GatingStorage) Pending ¶
func (storage *GatingStorage) Pending() int
Pending reports the number of parked commits.
func (*GatingStorage) WaitPending ¶
func (storage *GatingStorage) WaitPending(count int) error
WaitPending blocks until at least count commits are parked.
type InstrumentedStorage ¶
type InstrumentedStorage struct {
StorageDecorator
// contains filtered or unexported fields
}
InstrumentedStorage is a test-only transparent Storage decorator that records commit admission before delegating.
func NewInstrumentedStorage ¶
func NewInstrumentedStorage(delegate session.Storage) *InstrumentedStorage
NewInstrumentedStorage wraps delegate.
func (*InstrumentedStorage) ClearCommitAttempts ¶
func (storage *InstrumentedStorage) ClearCommitAttempts()
ClearCommitAttempts forgets recorded transactions without touching the delegate.
func (*InstrumentedStorage) Commit ¶
func (storage *InstrumentedStorage) Commit(ctx context.Context, writes []session.Write) (session.CommitResult, error)
Commit records the transaction, then delegates.
func (*InstrumentedStorage) GetCommitAttempts ¶
func (storage *InstrumentedStorage) GetCommitAttempts() [][]session.Write
GetCommitAttempts returns the recorded transactions in admission order.
type StorageDecorator ¶
StorageDecorator is a test-only forwarding base for decorators that alter one part of Storage behavior; embedded methods forward to the delegate.
func NewStorageDecorator ¶
func NewStorageDecorator(delegate session.Storage) StorageDecorator
NewStorageDecorator wraps delegate.
type StorageFixture ¶
StorageFixture is a fresh backend storage instance owned by one test or benchmark case.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package benchmark holds the deterministic session workloads shared by every backend's storage and repository benchmarks.
|
Package benchmark holds the deterministic session workloads shared by every backend's storage and repository benchmarks. |
|
Package conformance holds the runner-independent Storage and SessionRepo conformance suites every session backend must pass.
|
Package conformance holds the runner-independent Storage and SessionRepo conformance suites every session backend must pass. |