fabric/store/conformance

Checks a store backend against the contract of fabric/store/backend, and a leased backend kept in memory for tests. A backend author runs every check of checks in a test.

Types

One property of the leased backend contract (see fabric/store/backend, Leases): run checks it and describes the first difference found.

pub type Check {
  Check(name: String, run: fn() -> Result(Nil, String))
}

Constructors

  • Check(name: String, run: fn() -> Result(Nil, String))

A leased backend kept in memory by one process, shared by every store given backend in this VM, and a clock that tests can move forward.

pub type LeasedMemory {
  LeasedMemory(
    backend: backend.LeasedBackend,
    advance: fn(Int) -> Nil,
  )
}

Constructors

  • LeasedMemory(
      backend: backend.LeasedBackend,
      advance: fn(Int) -> Nil,
    )

    Arguments

    advance

    Moves the backend’s clock forward by this many milliseconds.

Values

pub fn checks(new: fn() -> backend.LeasedBackend) -> List(Check)

The checks a leased backend must pass, each against a backend made by new: compare-and-set, the lease conditions of each backend.Lease, renewal of live leases only and without a new revision, and claim_expired with disjoint results for concurrent claimers, also while a Hold races it. claim_expired claims any expired lease in the backend’s storage, so each call of new must return a backend over storage of its own that starts empty (a fresh table, schema, or process), and the checks must run one at a time. An expired lease is made with a ttl of 0, so no clock control is needed. Run each check in a test and fail it on Error.

pub fn leased_memory() -> LeasedMemory

A leased backend in memory (see fabric/store/backend, Leases), for tests: it stands for a database that several nodes share, each node a leased store of its own node id over backend; not for runs that must outlive the VM. Its process stops when the process that called this exits. Its clock is UTC system time, moved forward by advance.

✨ Search Document