harness

package
v0.57.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ChromiumGPUEnv = "E2E_CHROMIUM_GPU"

ChromiumGPUEnv selects the Chromium GPU launch policy for local e2e runs.

Variables

This section is empty.

Functions

func ChromiumLaunchOptions added in v0.57.2

func ChromiumLaunchOptions(headless bool, gpu bool) playwright.BrowserTypeLaunchOptions

ChromiumLaunchOptions returns the Playwright launch options for one Chromium launch mode. gpu selects the full-Chromium hardware-GPU launch; otherwise the options are byte-identical to the legacy software launch.

func LaunchChromium added in v0.57.2

func LaunchChromium[B any](
	ctx context.Context,
	p *ChromiumLaunchPolicy,
	launch func(gpu bool) (B, error),
) (B, error)

LaunchChromium performs one Chromium launch under the sticky policy. launch receives true when the GPU options must be used. The first launch resolves the sticky GPU choice: prefer-GPU probes the GPU launch once and falls back to the legacy launch on error; legacy never attempts GPU; required never falls back. Concurrent callers serialize only while the choice is unresolved; relaunches reuse it without retrying. Cancellation aborts a launch that has not started yet.

func Resolve

func Resolve[A any](ctx context.Context, le *logrus.Entry, opts ResolveOptions, shape Shape[A]) (A, error)

Resolve returns a valid artifact, coalescing builds across processes.

Types

type BuildLock

type BuildLock struct {
	// contains filtered or unexported fields
}

BuildLock owns one held cross-process build lock.

func AcquireBuildLock

func AcquireBuildLock(ctx context.Context, le *logrus.Entry, lockDir, name string) (*BuildLock, error)

AcquireBuildLock acquires a named cross-process build lock. Context cancellation is checked before and after the kernel wait, but cannot promptly interrupt a caller parked in that wait.

func (*BuildLock) Release

func (l *BuildLock) Release()

Release unlocks and closes the build lock without unlinking its shared path.

type ChromiumGPUPreference added in v0.57.2

type ChromiumGPUPreference int

ChromiumGPUPreference is the three-state Chromium GPU launch policy parsed from E2E_CHROMIUM_GPU.

const (
	// ChromiumGPUPreferGPU is the unset default. Launch with hardware GPU
	// enabled; on a launch error, retry the legacy software launch once.
	ChromiumGPUPreferGPU ChromiumGPUPreference = iota
	// ChromiumGPULegacy is an explicit opt-out (false/0/no/off). Launch
	// legacy software Chromium only.
	ChromiumGPULegacy
	// ChromiumGPURequired is an explicit opt-in (true/1/yes/on). The GPU
	// launch is required and never falls back.
	ChromiumGPURequired
)

func ParseChromiumGPUPreference added in v0.57.2

func ParseChromiumGPUPreference(raw string) (ChromiumGPUPreference, error)

ParseChromiumGPUPreference parses a raw E2E_CHROMIUM_GPU value.

func ResolveChromiumGPUPreference added in v0.57.2

func ResolveChromiumGPUPreference() (ChromiumGPUPreference, error)

ResolveChromiumGPUPreference resolves the launch policy from the process environment. Harnesses call this once per boot.

func (ChromiumGPUPreference) String added in v0.57.2

func (p ChromiumGPUPreference) String() string

String returns the stable log name of the preference.

type ChromiumLaunchPolicy added in v0.57.2

type ChromiumLaunchPolicy struct {
	// contains filtered or unexported fields
}

ChromiumLaunchPolicy carries the resolved E2E_CHROMIUM_GPU preference and the sticky launch choice for one harness boot. The zero value is invalid; use NewChromiumLaunchPolicy.

func NewChromiumLaunchPolicy added in v0.57.2

func NewChromiumLaunchPolicy(le *logrus.Entry) (*ChromiumLaunchPolicy, error)

NewChromiumLaunchPolicy resolves the policy from the environment once per harness boot and logs the chosen preference.

type Generation

type Generation[A any] struct {
	Token    string
	Artifact A
}

Generation pairs a store-owned immutable publication token with its artifact.

type ResolveOptions

type ResolveOptions struct {
	LockDir      string
	LockName     string
	RequireFresh bool
}

ResolveOptions configures the shared artifact resolution policy.

type Shape

type Shape[A any] interface {
	// ContentKey returns the immutable content key to resolve.
	ContentKey(context.Context) (string, error)
	// Lookup returns every validated publication for the content key in
	// preference order. The first publication is the preferred result.
	Lookup(context.Context, string) ([]Generation[A], error)
	// Build produces and publishes one generation for the content key.
	Build(context.Context, string) (Generation[A], error)
}

Shape supplies content identity, validated publication lookup, and artifact building.

Jump to

Keyboard shortcuts

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