fake

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fake is a dumb, instant, pure-Go implementation of the backend interfaces used to exercise the cross-process coordination layer (client ↔ helper ↔ holder) on a CI runner that cannot boot a real VM. It is linked only by internal/holder's backend selector under the fleetbox_fake build tag, so it can never enter a normal `go build ./...` artifact (ADR-0018/0020).

Since ADR-0020 the fake lives BEHIND the helper: a helper built -tags fleetbox_fake uses fake.New(), and the test drives the real client↔helper protocol against it. The fake runs in the helper's address space, so a test in the client process cannot read in-process globals. Instead, when FLEETBOX_FAKE_RECORD names a file, the fake appends one JSON line per backend call (reserve/create/stop/close) to it; the test reads that file afterwards to assert what the helper's backend actually received (the orchestrator's disk/seed/fixture/MAC/IP threading). Everything else a test needs is observable over the protocol (status: state/IP) and on disk (member dirs, config.json).

The fake proves coordination, not that a VM boots: Start/Stop are no-ops, WaitForIP returns an unroutable TEST-NET-3 address, and nothing dials the guest. Its Subnet is empty (mimicking macOS DHCP), so the Linux static-IP allocation path is NOT exercised here — that stays covered by real cloud-hypervisor in vm-linux.yml. Real boot, SSH, and IP discovery stay covered by the VM-boot suites.

Index

Constants

View Source
const (
	// EnvFailCreate names the member whose Create the fake should fail. The spawned
	// fake helper (a separate address space from the test) reads it from the
	// environment to inject a boot failure for the orchestrator's rollback paths.
	EnvFailCreate = "FLEETBOX_FAKE_FAIL_CREATE"

	// EnvFakeRecord names a file the fake appends one JSON record per backend call
	// to. It is the cross-process observation channel: the test sets it, drives the
	// protocol, then reads the file to assert the args the helper's backend saw.
	EnvFakeRecord = "FLEETBOX_FAKE_RECORD"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct{}

Backend is the fake backend. It holds no state of its own; observable effects land in the FLEETBOX_FAKE_RECORD file and over the protocol.

func New

func New() *Backend

New creates a fake backend.

func (*Backend) Create

func (b *Backend) Create(cfg backend.Config, _ backend.Network) (backend.VM, error)

Create records the config it received and returns a fake VM, unless this member's Create has been armed to fail via EnvFailCreate, in which case it records the attempt and returns an error so the orchestrator's create-failure cleanup path runs. The returned VM is assigned a deterministic, unroutable TEST-NET-3 IP.

func (*Backend) CreateNetwork

func (b *Backend) CreateNetwork() (backend.Network, error)

CreateNetwork returns a fake network. Its Subnet is empty, mirroring the DHCP/vz path so no static IP is allocated.

func (*Backend) NestedVirtSupported

func (b *Backend) NestedVirtSupported() bool

NestedVirtSupported always reports true: the fake never boots a guest, so the capability gate must not skip the coordination tests.

func (*Backend) Reconcile

func (b *Backend) Reconcile() error

Reconcile is a no-op: the fake owns no host resources.

func (*Backend) SupportsClustering

func (b *Backend) SupportsClustering() bool

SupportsClustering always reports true so the multi-member coordination paths (StartN/StartCluster, Cluster.Add) are reachable.

Jump to

Keyboard shortcuts

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