Documentation
¶
Overview ¶
Package departmenttest is test support for products that register a runtime with Host: an exported conformance run that launches one real session through a department.LaunchTarget and checks the contract Host relies on.
It imports no harness package, so it can check any runtime; it is run in Host against github.com/looprig/host/harnessruntime, and a product runs it against its own target (Carbon's, the tests lanes' rigs) so a capability that compiles but is not wired fails a unit test rather than a failover.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunRuntimeConformance ¶
func RunRuntimeConformance(t *testing.T, target department.LaunchTarget, launch Launch, options ...Option)
RunRuntimeConformance launches one session through target via launch and checks, each as its own subtest:
- the target declares both recovery capabilities (department.Recovery), which host.Compose requires under the default durable profile;
- the launched session runs under the RigSessionID Host asked for;
- the runtime has the six required capabilities, holds a journal lease epoch, and offers both recovery capabilities — AttemptCloser and PersistenceFaults — for real (AttemptCloserAvailable and PersistenceFaultsAvailable report true where the runtime reports them);
- it offers department.LiveOptionsSubscriber;
- an input's Principal and Metadata reach the runtime's own applier through ApplyCommand;
- an unresolved PayloadRef is refused and never reaches the applier.
The session is released (nonterminally) when the test ends. The probe input is applied to a real runtime, so launch must supply one whose model answers.
Types ¶
type Applied ¶
type Applied struct {
Principal *sessionwire.Principal
Metadata sessionwire.MessageMetadata
}
Applied is what a runtime's own command applier received for one command, observed beneath the department seam.
type Launch ¶
type Launch func(ctx context.Context, target department.LaunchTarget, request department.CreateRequest) (department.Runtime, Recorder, error)
Launch launches one session through target for request, the way the product's Host would (normally target.Create), and returns the runtime with a Recorder over it. It may fill in request fields its rigs need — a tenant RigPerTenant knows, a workspace root — but must not change RigSessionID; honouring that is one of the checks.
type Option ¶
type Option func(*run)
Option adjusts a conformance run.
func WithInputEncoder ¶
func WithInputEncoder(encode func(sessionwire.InputRequest) ([]byte, error)) Option
WithInputEncoder replaces the default encoding of the probe input's body, json.Marshal of Core's sessionwire.InputRequest, for a product whose runtime reads another body shape (harnessruntime.WithBlockDecoder).
type Recorder ¶
type Recorder interface {
// Applied reports what the runtime applied for command, and whether it
// applied that command at all. The whole command is passed so a recorder
// can correlate on either identity: harness, for one, stamps the
// RuntimeCommandID as the cause of the turn an input starts. It is called
// after ApplyCommand returns; a recorder over an asynchronous effect may
// wait for it, bounded by its own deadline.
Applied(command department.RuntimeCommand) (Applied, bool)
}
Recorder reports what the launched runtime's own applier received. It is the product's probe below the seam Host hands commands across — for a harness runtime, a recording runtimecommand.Applier or a read of the session's journal — because a runtime that drops Principal or Metadata in translation looks identical from above.