bench

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 55 Imported by: 0

Documentation

Overview

Package bench runs reference-server test scenarios in simulated and live workspaces.

A workspace keeps local identities and configuration across runs. Start can embed the server runtime or launch dmserver processes, using the same server configuration in either case. Up supervises those processes in the foreground; other commands attach through an authenticated loopback control endpoint.

Simulated workspaces provide local service fixtures. Live scenarios require the operator's credentials and device enrollment. Doctor reports missing prerequisites without enrolling a device or changing its trust settings.

See the reference bench guide: https://github.com/deploymenttheory/go-apple-dm/blob/main/docs/operations/reference-bench.md

Index

Constants

This section is empty.

Variables

View Source
var ErrBlocked = errors.New("scenario prerequisites unavailable")

Functions

func EnrollmentPreflight

func EnrollmentPreflight(w *Workspace, identity string) map[string]any

EnrollmentPreflight checks local prerequisites without installing profiles or changing trust. Service discovery and device delivery have separate scenarios.

func ExportTrust

func ExportTrust(w *Workspace, destination string) error

ExportTrust bootstraps private HTTPS trust before the Mac can fetch an HTTPS profile.

func HTTP

func HTTP(
	ctx context.Context,
	c *http.Client,
	base, token, method, path string,
	body io.Reader,
) ([]byte, int, error)

HTTP performs a bounded admin request. Errors contain status, never bodies or tokens.

func Init

func Init(dir, mode, storage, topology, listen string) error

func Markdown

func Markdown() string

Markdown is generated directly from executable metadata.

func Profile

func Profile(ctx context.Context, e *Environment, device, destination string) error

Profile requests the actual configured enrollment service and writes a new file.

func ProfileWithIdentity

func ProfileWithIdentity(
	ctx context.Context,
	e *Environment,
	device, identity, destination string,
) error

ProfileWithIdentity exports the configured profile with the rights needed for inventory and controlled profile replacement. Empty identity uses server defaults.

func Replace

func Replace(ctx context.Context, e *Environment, device, identity string) (map[string]any, error)

Replace starts an authorized update; the existing push route wakes the device.

func Up

func Up(ctx context.Context, w *Workspace, binary string, out io.Writer) error

Up supervises processes in the foreground. A separate dmctl bench down uses the authenticated loopback control endpoint, never a possibly recycled PID.

func WriteReports

func WriteReports(dir string, results []Result) error

WriteReports writes private JSON evidence and a JUnit projection. Non-passes never become successes merely because the selected execution mode lacks a device.

Types

type Environment

type Environment struct {
	// InstallingUserID is the local user's GeneratedUID, supplied by the operator
	// for live enrollment acceptance. It is not inferred from an arbitrary child.
	InstallingUserID string
	DEP              *deptest.Server
	ABM              *axmtest.Server
	Provider         *webauthtest.Provider
	Authority        *testpki.CA
	Instance
	Client    *http.Client
	Token     string
	APNS      *pushtest.Server
	Workspace *Workspace
	// contains filtered or unexported fields
}

Environment owns fixture services and the ordinary server runtime(s).

func Attach

func Attach(w *Workspace) (*Environment, error)

func AttachURL

func AttachURL(w *Workspace, address string) (*Environment, error)

AttachURL connects to an existing live server using the workspace's trust and admin credential. It does not start a supervisor, replace state or migrate SQL.

func Start

func Start(ctx context.Context, w *Workspace, binary string, out io.Writer) (*Environment, error)

Start uses the same configuration and runtime in both adapters. A nonempty binary launches dmserver; an empty binary embeds runtime.Serve for E2E tests.

func (*Environment) Close

func (e *Environment) Close()

Close stops all runtimes before releasing fixture services.

func (*Environment) Control

func (e *Environment) Control(
	ctx context.Context,
	method, path string,
	body io.Reader,
) ([]byte, error)

type Instance

type Instance struct {
	Binary       string `json:"Binary"`
	URL          string `json:"URL"`
	DDMURL       string `json:"DDMURL"`
	ControlURL   string `json:"ControlURL"`
	ControlToken string `json:"ControlToken"`
	Mode         string `json:"Mode"`
	Topology     string `json:"Topology"`
}

Instance describes the running workspace. The control credential stays private.

type Result

type Result struct {
	ID       string        `json:"ID"`
	Name     string        `json:"Name"`
	Mode     string        `json:"Mode"`
	Adapter  string        `json:"Adapter"`
	Revision string        `json:"Revision"`
	Status   string        `json:"Status"`
	Detail   string        `json:"Detail"`
	Started  time.Time     `json:"Started"`
	Duration time.Duration `json:"Duration"`
}

Result distinguishes unavailable prerequisites from an assertion failure.

func Run

func Run(ctx context.Context, e *Environment, s Scenario, adapter, revision, device string) Result

type Scenario

type Scenario struct {
	Settings      map[string]string                                 `json:"Settings,omitempty"`
	Topology      string                                            `json:"Topology,omitempty"`
	ID            string                                            `json:"ID"`
	Name          string                                            `json:"Name"`
	Family        string                                            `json:"Family"`
	Regression    string                                            `json:"Regression"`
	Modes         []string                                          `json:"Modes"`
	Prerequisites []string                                          `json:"Prerequisites"`
	Run           func(context.Context, *Environment, string) error `json:"-"`
}

Scenario is the maintained inventory; implementations never depend on testing.T. Regression names retain the original detailed assertions during migration.

func Catalogue

func Catalogue() []Scenario

Catalogue returns a fresh inventory in stable ID order.

func Select

func Select(selector string) ([]Scenario, error)

func SelectMode

func SelectMode(mode, selector string) ([]Scenario, error)

SelectMode makes all select the applicable scenarios; explicit IDs still report unsupported modes rather than being silently ignored.

type Workspace

type Workspace struct {
	Settings  map[string]string `json:"Settings,omitempty"`
	Version   int               `json:"Version"`
	Mode      string            `json:"Mode"`
	Storage   string            `json:"Storage"`
	Topology  string            `json:"Topology"`
	Listen    string            `json:"Listen"`
	DSN       string            `json:"DSN,omitempty"`
	Directory string            `json:"-"`
}

Workspace contains non-secret settings. Existing local identities stay in mdm/.

func Load

func Load(dir string) (*Workspace, error)

func (*Workspace) Doctor

func (w *Workspace) Doctor() map[string]any

Doctor checks prerequisites without enrolling a device or altering trust.

Jump to

Keyboard shortcuts

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