harness

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeployApp

func DeployApp(t *testing.T, m *Miren, opts AppOptions) string

DeployApp deploys a testdata application, registers cleanup, and waits for it to become ready. It returns the app name.

func GetSandboxID

func GetSandboxID(t *testing.T, m *Miren, appName string) string

GetSandboxID returns the ID of a running sandbox for the given app by parsing the JSON output of `sandbox list --format json`.

func HTTPGet added in v0.6.0

func HTTPGet(m *Miren, hostname, path string) (statusCode int, body string, err error)

HTTPGet makes an HTTP GET request from inside the dev container via curl. The host header is set to the given hostname so ingress routing works, while the actual request goes to localhost:443 over HTTPS (with -k to skip certificate verification). Port 80 redirects to HTTPS, so we connect directly to avoid redirect resolution issues.

func Poll

func Poll(t *testing.T, description string, timeout, interval time.Duration, condition func() (done bool, msg string))

Poll repeatedly calls condition until it returns true or the timeout expires. On timeout, it fails the test with the last message from the condition.

func UniqueAppName

func UniqueAppName(t *testing.T, base string) string

UniqueAppName generates a short app name unique to this test and process. The format is bb-<base>-<hash> where hash is 6 hex chars derived from the test name plus a process-unique run ID to avoid collisions across concurrent runs.

func WaitForAppReady

func WaitForAppReady(t *testing.T, m *Miren, name string, timeout time.Duration)

WaitForAppReady polls `app list --json` until the named app reports healthy.

Types

type AppOptions

type AppOptions struct {
	// Name overrides the generated app name. If empty, one is derived from the
	// test name and Testdata value.
	Name string

	// Testdata is the directory name under testdata/ to deploy (e.g. "go-server").
	Testdata string

	// Env is a list of KEY=VALUE pairs to pass via -e flags.
	Env []string

	// ReadyTimeout is how long to wait for the app to become healthy after deploy.
	// Defaults to 2 minutes.
	ReadyTimeout time.Duration
}

AppOptions configures a test app deployment.

type Cluster

type Cluster struct {
	Mode        Mode
	RepoRoot    string
	TestdataDir string
	MirenBin    string // only used in local mode
}

Cluster holds targeting information for a test run.

func NewCluster

func NewCluster(t *testing.T) *Cluster

NewCluster reads environment variables and returns a configured Cluster. It fails the test if required configuration is missing.

type Miren

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

Miren wraps CLI execution against a target cluster.

func NewMiren

func NewMiren(t *testing.T, cluster *Cluster) *Miren

NewMiren creates a CLI runner bound to the given cluster.

func (*Miren) ContainerPath

func (m *Miren) ContainerPath(hostPath string) string

ContainerPath translates a host-side path to a container-internal path. In dev mode, the repo is mounted at /src inside the iso container.

func (*Miren) MustRun

func (m *Miren) MustRun(args ...string) *Result

MustRun executes a miren CLI command and fails the test on non-zero exit.

func (*Miren) Run

func (m *Miren) Run(args ...string) *Result

Run executes a miren CLI command and returns the result. In dev mode the command is dispatched through hack/dev-exec.

func (*Miren) RunCmd added in v0.6.0

func (m *Miren) RunCmd(args ...string) *Result

RunCmd executes an arbitrary command (not miren CLI) in the dev container. In local mode it runs the command directly on the host.

type Mode

type Mode string

Mode determines how the harness reaches the miren cluster.

const (
	// ModeDev routes commands through hack/dev-exec inside the iso container.
	ModeDev Mode = "dev"

	// ModeLocal calls the miren binary directly on the host.
	ModeLocal Mode = "local"
)

type Result

type Result struct {
	ExitCode int
	Stdout   string
	Stderr   string
}

Result captures the output of a CLI invocation.

func (*Result) OutputContains

func (r *Result) OutputContains(s string) bool

OutputContains checks whether stdout or stderr contains the given substring.

func (*Result) RequireContains

func (r *Result) RequireContains(t *testing.T, substr string)

RequireContains fails the test if neither stdout nor stderr contains substr.

func (*Result) RequireExitCode

func (r *Result) RequireExitCode(t *testing.T, code int)

RequireExitCode fails the test if the exit code doesn't match.

func (*Result) RequireSuccess

func (r *Result) RequireSuccess(t *testing.T)

RequireSuccess fails the test if the command did not exit with code 0.

func (*Result) Success

func (r *Result) Success() bool

Success returns true if the command exited with code 0.

Jump to

Keyboard shortcuts

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