Documentation
¶
Index ¶
- func DeployApp(t *testing.T, m *Miren, opts AppOptions) string
- func GetSandboxID(t *testing.T, m *Miren, appName string) string
- func HTTPGet(m *Miren, hostname, path string) (statusCode int, body string, err error)
- func HTTPGetViaPOP(m *Miren, popListenPort, hostname, path string) (statusCode int, body string, err error)
- func Poll(t *testing.T, description string, timeout, interval time.Duration, ...)
- func UniqueAppName(t *testing.T, base string) string
- func WaitForAddonReady(t *testing.T, m *Miren, appName, addonName string, timeout time.Duration)
- func WaitForAddonRemoved(t *testing.T, m *Miren, appName, addonName string, timeout time.Duration)
- func WaitForAppReady(t *testing.T, m *Miren, name string, timeout time.Duration)
- func WaitForEnvVar(t *testing.T, m *Miren, appName, key string, timeout time.Duration)
- func WaitForEnvVarRemoved(t *testing.T, m *Miren, appName, key string, timeout time.Duration)
- type AppOptions
- type BackgroundProcess
- type CloudEnv
- type Cluster
- type Miren
- func (m *Miren) ContainerPath(hostPath string) string
- func (m *Miren) MustRun(args ...string) *Result
- func (m *Miren) PeerExec(peer string, args ...string) *Result
- func (m *Miren) Run(args ...string) *Result
- func (m *Miren) RunCmd(args ...string) *Result
- func (m *Miren) RunCmdAsRoot(args ...string) *Result
- func (m *Miren) RunCmdBackground(t *testing.T, env map[string]string, args ...string) *BackgroundProcess
- func (m *Miren) SetEnv(key, value string)
- type Mode
- type Result
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 ¶
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
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 HTTPGetViaPOP ¶ added in v0.7.0
func HTTPGetViaPOP(m *Miren, popListenPort, hostname, path string) (statusCode int, body string, err error)
HTTPGetViaPOP makes an HTTPS GET request through a POP's TLS listener. It uses curl --resolve to route the hostname to 127.0.0.1 on the given port.
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 ¶
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 WaitForAddonReady ¶ added in v0.7.0
WaitForAddonReady polls `addon list` until the named addon appears for the app.
func WaitForAddonRemoved ¶ added in v0.7.0
WaitForAddonRemoved polls `addon list` until the named addon no longer appears for the app.
func WaitForAppReady ¶
WaitForAppReady polls `app list --json` until the named app reports healthy.
func WaitForEnvVar ¶ added in v0.7.0
WaitForEnvVar polls `env list` until the given key appears in the app's environment.
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 BackgroundProcess ¶ added in v0.7.0
type BackgroundProcess struct {
PID string
LogFile string
// contains filtered or unexported fields
}
BackgroundProcess represents a process running in the dev container.
func (*BackgroundProcess) Logs ¶ added in v0.7.0
func (p *BackgroundProcess) Logs() string
Logs returns the contents of the background process log file.
func (*BackgroundProcess) Stop ¶ added in v0.7.0
func (p *BackgroundProcess) Stop()
Stop sends SIGTERM to the background process (runs as root since background processes are started as root).
type CloudEnv ¶ added in v0.7.0
type CloudEnv struct {
CloudURL string // e.g. http://localhost:18080
PopListenPort string
PopH3Port string
ClusterID string
OrgID string
CertXID string
PopXID string
// contains filtered or unexported fields
}
CloudEnv manages a cloud+POP test environment for global router blackbox tests.
func NewCloudEnv ¶ added in v0.7.0
NewCloudEnv builds a full cloud+POP environment for testing the global router. It builds cloud/POP binaries, starts cloud, registers a POP and cluster, starts POP, and restarts the miren server with --labs globalrouter. The environment is torn down via t.Cleanup.
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 ¶
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 (*Miren) ContainerPath ¶
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) PeerExec ¶ added in v0.7.0
PeerExec runs a command on a specific iso peer container. This is only meaningful in ModePeers and is used for verification tasks like querying runner-side state or hitting internal HTTP endpoints.
func (*Miren) Run ¶
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
RunCmd executes an arbitrary command (not miren CLI) in the dev container. In local mode it runs the command directly on the host.
func (*Miren) RunCmdAsRoot ¶ added in v0.7.0
RunCmdAsRoot executes a command in the dev container as root.
func (*Miren) RunCmdBackground ¶ added in v0.7.0
func (m *Miren) RunCmdBackground(t *testing.T, env map[string]string, args ...string) *BackgroundProcess
RunCmdBackground starts a command in the dev container as a background process using nohup. Output is captured to a log file. The process is killed via t.Cleanup. Must be called in dev mode.
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" // ModePeers routes commands through iso peers exec into the coordinator // container. Used for testing distributed runner topologies. ModePeers Mode = "peers" )
type Result ¶
Result captures the output of a CLI invocation.
func (*Result) OutputContains ¶
OutputContains checks whether stdout or stderr contains the given substring.
func (*Result) RequireContains ¶
RequireContains fails the test if neither stdout nor stderr contains substr.
func (*Result) RequireExitCode ¶
RequireExitCode fails the test if the exit code doesn't match.
func (*Result) RequireSuccess ¶
RequireSuccess fails the test if the command did not exit with code 0.