Documentation
¶
Overview ¶
Package conformance provides the test suite every coordination.Backend implementation must pass.
Call Run from a test of the implementation's package:
func TestBackend(t *testing.T) {
conformance.Run(t, func(t *testing.T) (coordination.Backend, func(time.Duration)) {
clock := newManualClock()
return newBackend(clock), clock.Advance
})
}
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run verifies the lease contract of the backends produced by factory, one subtest per property: immediate contention returns coordination.ErrNotAcquired; a waiting acquisition honours cancellation; renewal extends the deadline from the current time; release and expiry close Done; a released lease cannot be renewed after another owner acquires the key (coordination.ErrLeaseLost); and fencing tokens strictly increase across release and expiry. Each subtest waits at most one second of real time for asynchronous effects.
Example ¶
Backend authors call Run from a test in their package, returning a fresh backend and a hook that advances its clock.
_ = func(t *testing.T) {
conformance.Run(t, func(t *testing.T) (coordination.Backend, func(time.Duration)) {
clock := newFakeClock(time.Unix(0, 0))
return memory.NewBackend(clock), clock.Advance
})
}