// Package tests contains the per-stage executors the agent runs on the // host under test. Each stage implements Runner, is called with a // Context that carries the client + forwarder + run params, and returns // an Outcome that the caller POSTs to /result. package tests import ( "context" "encoding/json" "time" ) // Outcome is what a stage returns; it maps directly to the /result body. // - Passed=true and len(Skipped)>0 counts as a pass but surfaces in the // tile summary so operators can see "GPU: skipped (no VGA device)". // - Message is only used on failure; the UI displays it in the log. // - Extras is merged into the posted summary so stages can add // their own shape (e.g. Storage returns per-disk probe results). type Outcome struct { Passed bool Message string Summary string // short human-readable one-liner Extras map[string]any // merged into posted summary JSON } // MarshalSummary builds the summary JSON body POSTed to /result. // Stages accumulate fields via Extras; this helper adds "summary" (the // human-readable line) and serializes. func (o Outcome) MarshalSummary() (json.RawMessage, error) { body := map[string]any{} for k, v := range o.Extras { body[k] = v } if o.Summary != "" { body["summary"] = o.Summary } return json.Marshal(body) } // Deps bundles what stages need without pulling in the whole agent. // Logger methods print to stdout + forward to the orchestrator; Sensor // drops numeric samples; OverrideFlags carries operator-set bypasses. type Deps struct { Info func(string) Warn func(string) Error func(string) Sensor func(ctx context.Context, samples []Sample) error OverrideWipe bool NonDestructive bool // skip wipe-probe + writes in Storage ExpectedDisks []ExpectedDisk // serials + sizes from host.expected_spec StageTimeout time.Duration } // Sample mirrors the server's SensorSample but lives in the tests // package so probe code doesn't import internal/api. type Sample struct { Kind string Key string Value float64 Unit string } // ExpectedDisk is the subset of internal/spec.DiskSpec that Storage // needs: a device allowlist keyed on serial. type ExpectedDisk struct { Serial string SizeGB int }