Documentation
¶
Index ¶
- Constants
- func AddedJobID(t *testing.T, result Result) string
- func AssertPairOutcome(t *testing.T, r Result)
- func BuildRotari(path string) error
- func CommandEnv(vars []string, dir string) []string
- func GuardedCommands(project string) map[string][]string
- func JobProcesses(t *testing.T, root, job string) int
- func KeepOnFailure(t *testing.T, root string, transcript *Transcript)
- func KillProcessGroup(pid int) error
- func KillStrays(t *testing.T, root string)
- func KillSupervisors(t *testing.T, root string)
- func MemoryTempDir(t *testing.T) string
- func NonUTF8NamesAllowed(t interface{ ... }, dir string) bool
- func PairAdapter(command string) string
- func PairHasFlag(flags []PairFlag, name string) bool
- func PairIntersect(a, b []string) []string
- func PairMutationRevision(t *testing.T, e *Env) string
- func ProcessArgs(pid int) ([]string, bool, error)
- func ProcessEnvironment(pid int) ([]string, error)
- func Run(m *testing.M) int
- func TrackBuildInputs(t testing.TB)
- func WaitForInterrupted(t *testing.T, e *Env, project string)
- func WaitUntil(t *testing.T, timeout time.Duration, done func() (bool, string))
- type ActiveRun
- type CoordinatorProcess
- type Env
- func (e *Env) CheckState(project string) string
- func (e *Env) Command(args ...string) *exec.Cmd
- func (e *Env) CreateFinishedRun() FinishedRun
- func (e *Env) ExportFinishedRun(project string) string
- func (e *Env) FinishedJobRun(project string) (runID, attemptID string)
- func (e *Env) HTTPDo(method, url string, headers map[string]string, body string) HTTPResult
- func (e *Env) HTTPGet(url string) HTTPResult
- func (e *Env) HTTPPostJSON(url string, body any) HTTPResult
- func (e *Env) In(dir string) *Env
- func (e *Env) JobExitStatus(project, jobID string) string
- func (e *Env) MustRotari(args ...string) Result
- func (e *Env) OrphanRun(project, script string) string
- func (e *Env) Rotari(args ...string) Result
- func (e *Env) RotariRun(args ...string) Result
- func (e *Env) Setenv(name, value string)
- func (e *Env) StartRun(project string, count int, async bool, runArgs ...string) ActiveRun
- func (e *Env) StartTableView(path string, args ...string) string
- func (e *Env) StartWeb(args ...string) string
- func (e *Env) WithVar(name, value string) *Env
- func (e *Env) Without(name string) *Env
- type FinishedRun
- type FlagPair
- type HTTPResult
- type PairCommand
- type PairFixture
- type PairFlag
- type PairMutationFixture
- type PairMutationResult
- type PairSavedFile
- type PairSavedTree
- type Process
- type Result
- type Transcript
Constants ¶
const FailedDirName = "rotari-conformance-failed"
FailedDirName is the directory under os.TempDir where a failed test's evidence is kept.
Variables ¶
This section is empty.
Functions ¶
func AssertPairOutcome ¶
func BuildRotari ¶
BuildRotari builds cmd/rotari at path for a conformance test binary. Commands that run the binary must call TrackBuildInputs.
func CommandEnv ¶ added in v0.1.30
CommandEnv is vars with PWD set to dir, as a shell sets it to the directory as the user named it. Without it, os.Getwd returns the resolved path, which differs where the temporary directory is under a symbolic link, as /var is on macOS.
func GuardedCommands ¶
GuardedCommands are the project commands that a running or interrupted project rejects. Queue edits are not among them: the queue holds only the next run's jobs.
func KeepOnFailure ¶ added in v0.1.30
func KeepOnFailure(t *testing.T, root string, transcript *Transcript)
KeepOnFailure keeps the evidence of a failed test: when t has failed, its state directory root is moved to a new directory under os.TempDir()/FailedDirName, with the transcript beside it as commands.log, and the place is logged. A passing test keeps nothing. Register it before the cleanups that stop the test's servers and processes, so that it runs after them.
func KillProcessGroup ¶
func KillStrays ¶
func KillSupervisors ¶
KillSupervisors kills the supervisor processes of runs under root, as a crash would, and leaves their jobs running. It returns once they are gone, so a caller that then stops the jobs cannot let a supervisor record their results.
func MemoryTempDir ¶ added in v0.1.20
MemoryTempDir returns a directory on /dev/shm when it is writable, removed when the test ends, and t.TempDir otherwise. jj syncs its operation log to disk on every snapshot, which takes seconds on a host busy with synchronous writes, so jj repositories made by tests live in memory.
func NonUTF8NamesAllowed ¶ added in v0.1.30
func NonUTF8NamesAllowed(t interface {
Helper()
Logf(string, ...any)
Fatal(...any)
}, dir string) bool
NonUTF8NamesAllowed reports whether the file system under dir holds a name that is not UTF-8. macOS (APFS) refuses one with EILSEQ; there a test checks everything else and leaves such names out.
func PairAdapter ¶
One execution classification shared by the inventory and runners. Missing adapters are deferred explicitly rather than counted as passing tests.
func PairHasFlag ¶
func PairIntersect ¶
func ProcessArgs ¶ added in v0.1.30
ProcessArgs returns pid's arguments, or false when it is not running.
func ProcessEnvironment ¶ added in v0.1.30
ProcessEnvironment returns pid's environment as NAME=VALUE entries: from /proc on Linux and from ps -E elsewhere, where entries follow the arguments split at spaces. It fails when pid is gone or not this user's.
func TrackBuildInputs ¶
TrackBuildInputs makes a cached test result depend on rotari's sources.
BuildRotari runs `go build` in a subprocess, which Go's test cache does not observe, so a cached conformance result would survive a change to rotari. The cache does record files the test process stats while tests run (not in TestMain), so every command that runs the built binary calls this: it stats each file under the module's cmd and internal directories, plus go.mod and go.sum, once per test binary.
Types ¶
type CoordinatorProcess ¶
type CoordinatorProcess struct {
Host string `json:"host"`
PID int `json:"pid"`
PIDNamespace string `json:"pid_namespace"`
ProcessStart string `json:"process_start"`
}
func CurrentCoordinator ¶
func CurrentCoordinator(t *testing.T) CoordinatorProcess
func ProcessIdentity ¶
func ProcessIdentity(t *testing.T, pid int) CoordinatorProcess
type Env ¶
type Env struct {
T *testing.T
Root string
Base string
Master string
// contains filtered or unexported fields
}
func (*Env) CheckState ¶
func (*Env) Command ¶
Command returns an unstarted rotari command in e's environment, for a test that talks to the process itself, such as over its stdin.
func (*Env) CreateFinishedRun ¶
func (e *Env) CreateFinishedRun() FinishedRun
func (*Env) ExportFinishedRun ¶
func (*Env) FinishedJobRun ¶
func (*Env) HTTPDo ¶
HTTPDo sends one request with headers; a "Host" header sets the request's Host. body, when not empty, is sent as JSON.
func (*Env) HTTPGet ¶
func (e *Env) HTTPGet(url string) HTTPResult
func (*Env) HTTPPostJSON ¶
func (e *Env) HTTPPostJSON(url string, body any) HTTPResult
func (*Env) JobExitStatus ¶
func (*Env) MustRotari ¶
func (*Env) RotariRun ¶ added in v0.1.20
RotariRun runs a run or retry that must start a run, whatever its jobs do. A refusal to start also exits 1, like a run whose jobs failed, so it fails the test with the command's output unless a new run directory appeared in e's basedir or one the arguments name.
func (*Env) StartTableView ¶
StartTableView starts rotari tableview on path and returns its URL.
type FinishedRun ¶
type FlagPair ¶
type FlagPair struct{ A, B PairFlag }
func CommandFlagPairs ¶
func CommandFlagPairs(c PairCommand) []FlagPair
type HTTPResult ¶
type PairCommand ¶
func ReadPairSchema ¶
func ReadPairSchema(t *testing.T, e *Env) []PairCommand
type PairFixture ¶
func NewPairFixture ¶
func NewPairFixture(t *testing.T) PairFixture
type PairMutationFixture ¶
type PairMutationFixture struct {
PairFixture
Initial PairSavedTree
// Current is the tree as last observed after an invocation; Restore
// diffs against it.
Current *PairSavedTree
Revision string
SecondRun string
Manifest string
}
func NewPairMutationFixture ¶
func NewPairMutationFixture(t *testing.T) PairMutationFixture
type PairMutationResult ¶
type PairSavedFile ¶
type PairSavedTree ¶
type PairSavedTree []PairSavedFile
A byte-for-byte initial tree, including directory mtimes used by latest-run lookup. All paths are relative to the harness-owned temporary root. No active supervisor/job is allowed while this snapshot is captured or restored.
func SavePairTree ¶
func SavePairTree(t *testing.T, root string) PairSavedTree
func (PairSavedTree) Observation ¶
func (tree PairSavedTree) Observation(t *testing.T) map[string]string
Only the project's newly written meta.updated_at is nondeterministic. All other content (IDs, queue definitions, results, registry, modes) stays exact.
func (PairSavedTree) Raw ¶
func (tree PairSavedTree) Raw() map[string]string
func (PairSavedTree) Restore ¶
func (tree PairSavedTree) Restore(t *testing.T, root string, current PairSavedTree)
Restore returns root to tree, given current, the snapshot taken after the last invocation. It rewrites only entries that differ, which matters on network filesystems where rewriting the whole tree per invocation dominated the runtime. Every entry's path, type, mode, and modification time is then checked against tree; contents are exact because unchanged entries had equal contents in current and changed ones are rewritten from tree.
type Process ¶ added in v0.1.30
type Process struct {
PID, PPID, PGID int
// Args are the command-line arguments. On Linux they are exact; elsewhere
// they come from ps and are split at spaces, so an argument holding a space
// reads as several. Tests match paths without spaces and whole words.
Args []string
}
Process is one entry of the process table, as tests look at it from outside.
func MustProcesses ¶ added in v0.1.30
MustProcesses is Processes, failing the test on an error rather than letting a caller find nothing and pass.
func Processes ¶ added in v0.1.30
Processes lists the processes this user can see: from /proc on Linux, and from ps elsewhere. A process that has exited but is not yet reaped has no arguments.
func (Process) CommandLine ¶ added in v0.1.30
CommandLine joins the arguments with spaces, for substring matches.
type Result ¶
func PairInvoke ¶
Adapters own isolation and restoration for mutating commands. Finished runs ensure --follow exits; the deadline is a failure bound, never an expected result. It is 20 s: 5 s was exceeded by cancel --wait on a loaded macOS runner under the race detector, and 20 s still stops short of the 30-second grace period a cancel waits when its job does not end, so that fault still shows.
type Transcript ¶ added in v0.1.30
type Transcript struct {
// contains filtered or unexported fields
}
Transcript records the rotari commands a test runs: when each started, in which directory, and, for commands run to completion, their exit code and full output. It is written out only when the test fails.
func (*Transcript) Finished ¶ added in v0.1.30
func (transcript *Transcript) Finished(args []string, code int, stdout, stderr string, elapsed time.Duration)
Finished records a command that ran to completion.
func (*Transcript) Started ¶ added in v0.1.30
func (transcript *Transcript) Started(dir string, args []string)
Started records a command that is about to start.