backendtest

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package backendtest provides a shared conformance suite that every backend.Backend implementation must pass, proving the implementations are interchangeable (DESIGN.md §2: "backends are interchangeable behind backend.Backend").

Index

Constants

View Source
const Unknown = int64(-1)

Unknown is the free-bytes/free-inodes value that makes a Capacity report backend.ErrSpaceUnknown for that axis, modeling a backend without the capability.

Variables

This section is empty.

Functions

func AtomicConditionalPut added in v0.33.0

func AtomicConditionalPut(h http.Handler) http.Handler

AtomicConditionalPut wraps an S3-compatible test server's handler, serializing every request that carries an If-None-Match or If-Match precondition. Real S3 evaluates a conditional PUT atomically; the embeddable go-faster/fs server (as of v0.3.0) checks the precondition and performs the write as two separate steps, so two concurrent "If-None-Match: *" PUTs can both observe the key absent and both succeed — a TOCTOU race the conformance suite's single-winner CAS test rightly rejects. Serializing just the conditional requests restores real-S3 semantics for the tests without patching the fake. (Worth fixing upstream; this wrapper is then a no-op.)

func Run

func Run(t *testing.T, factory func(t *testing.T) backend.Backend)

Run executes the full conformance suite against a backend produced by factory — the object operations plus the conditional-write (CAS) [Backend.PutIfAbsent]. Each subtest gets a fresh, empty backend. Call it from each implementation's test package.

Types

type Capacity added in v0.40.0

type Capacity struct {
	backend.Backend
	// contains filtered or unexported fields
}

Capacity wraps a backend with a settable capacity report, so a test can put an engine on a full disk or an exhausted inode table without needing a real one. The two axes are set independently: a filesystem with terabytes free can still fail every create, and a test must be able to say so.

Like github.com/oteldb/storage/backend/faultbackend it forwards no other optional capability — each has a mandatory fallback, so a wrapped backend runs the same code, only slower.

func WithCapacity added in v0.40.0

func WithCapacity(b backend.Backend, freeBytes, freeInodes int64) *Capacity

WithCapacity wraps b reporting freeBytes bytes and freeInodes inodes available (Unknown for an axis the backend cannot report).

func (*Capacity) FreeInodes added in v0.40.0

func (c *Capacity) FreeInodes(context.Context) (int64, error)

FreeInodes implements backend.InodeReporter.

func (*Capacity) FreeSpace added in v0.40.0

func (c *Capacity) FreeSpace(context.Context) (int64, error)

FreeSpace implements backend.SpaceReporter.

func (*Capacity) SetFreeBytes added in v0.40.0

func (c *Capacity) SetFreeBytes(n int64)

SetFreeBytes changes the reported free bytes — the disk filling up, or being emptied.

func (*Capacity) SetFreeInodes added in v0.40.0

func (c *Capacity) SetFreeInodes(n int64)

SetFreeInodes changes the reported free inodes.

Jump to

Keyboard shortcuts

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