leaseconformance

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package leaseconformance provides a shared conformance test suite for the port.SessionLease interface. Adapters (the in-memory reference, the single-host flock lease, the gRPC driver client over bufconn, the k8s lease) call Run with a factory that constructs a fresh lease plus an advance callback that drives the lease's notion of time past its TTL, and the suite exercises only the port.SessionLease interface through the port's value types.

Importing "testing" in a non-_test.go file is intentional here: this is a test-helper package whose sole purpose is to be imported by adapter tests, the conventional Go pattern for shared conformance suites (cf. the sibling eventlogconformance/storeconformance packages).

The suite pins the CONTRACT, not the implementation: how the lease stores its records (a map, a record file, a coordination.k8s.io Lease object) is adapter-internal and deliberately NOT asserted here. It is the SAME suite the reference memlease and the gRPC driver client (over bufconn) both pass — the dual-path contract-unification: the Go port is the contract, the wire is one adapter.

TIME: the suite never sleeps. It expresses "the lease lapsed" by calling the factory-supplied advance(d) callback, which pushes the lease's injected clock (or, for a real-clock adapter, the real TTL window) forward by d. A fake-clock adapter advances instantly; a real-clock adapter may implement advance as a short real sleep over a small TTL.

Index

Constants

View Source
const TTL = 30 * time.Second

TTL is the lease lifetime the factory MUST construct its lease with, so the suite's advance(TTL+ε) calls reliably cross the expiry boundary.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, newLease func(t *testing.T) (port.SessionLease, func(time.Duration)))

Run executes the shared SessionLease conformance table against the lease produced by newLease. newLease returns a fresh, isolated lease constructed with TTL, plus an advance callback that moves THAT lease's clock forward by the given duration. Both must be wired to the same time source.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL