Documentation
¶
Overview ¶
Package harness runs the built bitc binary in throwaway homes (spec 11).
Index ¶
- Constants
- Variables
- func BuildReference() (dir string, err error)
- func BuildSSHFake() (dir string, err error)
- func ExitCode(err error, ps *os.ProcessState) int
- func MergeEnv(base, extra []string) []string
- func Q(s string) string
- func ReadEnvFile(t *testing.T, path string) map[string]string
- func WithRemoteFlag(body string) string
- type APICall
- type FakeAPI
- type H
- func (h *H) Atoi(s string) int
- func (h *H) Hold(env []string, runArgs ...string) *Holder
- func (h *H) HostConfig(body string)
- func (h *H) Origin(name string) string
- func (h *H) Plugin(typ string) (path, sum string)
- func (h *H) PluginFrom(typ, src string) (path, sum string)
- func (h *H) Repo(name string, files map[string]string) string
- func (h *H) Run(args ...string) Result
- func (h *H) RunWith(env []string, args ...string) Result
- func (h *H) Seam(line string)
- func (h *H) SetSeam(key, value string)
- func (h *H) Start(args ...string) *Proc
- func (h *H) StartFakeAPI(bin string) *FakeAPI
- func (h *H) StartWith(env []string, args ...string) *Proc
- func (h *H) Track(pid int)
- func (h *H) Until(cond func() bool, d time.Duration)
- func (h *H) Write(path, body string, mode os.FileMode)
- type Holder
- type Proc
- type Result
Constants ¶
const HoldScript = `env > "$1.env"; : > "$1"; while [ ! -e "$2" ]; do sleep 0.05; done`
HoldScript is the held command: dump env to $1.env, touch $1, wait for $2.
Variables ¶
var Bin string
Bin is the bitc binary under test, set by the conformance TestMain.
var RefPlugin, RefFakeAPI string
RefPlugin and RefFakeAPI are the built reference plugin and fake API (BuildReference).
var SSHFakeGate string
SSHFakeGate is the fake ssh host gate (internal/provider/ssh/sshfake/gate) the conformance TestMain built; a host file names it with `[test] ssh_gate` and `ssh_exec = "local"`.
var StubPlugin string
StubPlugin is the stub provider plugin (internal/provider/plugin/stubplugin) the conformance TestMain built; Plugin installs it for a test.
Functions ¶
func BuildReference ¶
BuildReference builds the reference plugin and its fake API into a new temp dir, reproducibly (-trimpath, CGO off), and sets RefPlugin and RefFakeAPI. The caller removes dir.
func BuildSSHFake ¶
BuildSSHFake builds the fake gate into a new temp dir (the caller removes it).
func ExitCode ¶
func ExitCode(err error, ps *os.ProcessState) int
ExitCode is the shell-style code of a finished process (128+N for signal N).
func ReadEnvFile ¶
ReadEnvFile parses `env` output.
func WithRemoteFlag ¶ added in v0.1.1
WithRemoteFlag adds experimental_remote = true to the [host] table of a host-file body that mentions providers (a [providers.<type>] table or a pool's providers list) and lacks the key: after an existing [host] header, else as a [host] table at the end.
Types ¶
type APICall ¶
type APICall struct {
Seq int `json:"seq"`
Method string `json:"method"`
Path string `json:"path"`
Query string `json:"query"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
Attach bool `json:"attach"`
}
APICall is one call the fake API recorded (the /__bitc/calls contract, design A.10.2).
type FakeAPI ¶
type FakeAPI struct {
URL string
// contains filtered or unexported fields
}
FakeAPI is a running fake API process (a plugin author's loopback fake of their API) and the client of its /__bitc/ control contract.
func (*FakeAPI) Behave ¶
Behave is POST /__bitc/behave: the behaviour the fake shows to instances created from now on.
func (*FakeAPI) Calls ¶
Calls is GET /__bitc/calls: every API call in order, the attach call marked.
func (*FakeAPI) Seed ¶
Seed lists an instance with no process (optional part of the contract); it returns its id.
type H ¶
type H struct {
T *testing.T
Root string
State string
Config string
Cwd string
Env []string
// contains filtered or unexported fields
}
H is one test's sandbox: HOME, state dir and host config under a temp dir.
func (*H) Hold ¶
Hold runs `bitc run <runArgs...> -- sh -c HoldScript` and waits until the command runs. runArgs are run flags followed by the pool.
func (*H) HostConfig ¶
HostConfig writes the host file: "version = 1", body, then [test] with accounting_dir under Root and every seam added with Seam; a body naming sprites gets [test] allow_sprites (the sprites refusal's test-only bypass, honoured only for loopback endpoints). A body that configures a remote provider gets [host] experimental_remote = true (WithRemoteFlag); EX1 writes its host files whole instead.
func (*H) Plugin ¶
Plugin copies the stub plugin to Root/plugins/bitc-provider-<typ> (a private directory, 0700, so the pin checks of providers delta A.2 pass) and returns its path and sha256.
func (*H) PluginFrom ¶
PluginFrom installs the plugin binary src as Root/plugins/bitc-provider-<typ> (0755, in a 0700 directory) and returns its path and sha256: the path + sha256 pin a real host writes.
func (*H) SetSeam ¶
SetSeam sets one [test] key, replacing an earlier line for it, and rewrites the host file.
func (*H) StartFakeAPI ¶
StartFakeAPI starts the fake API binary on a loopback port, with this bitc as every instance's agent, and stops it with the test. The binary prints "listening <url>" once it serves.