Documentation
¶
Overview ¶
Package enginetest holds the differential checks that hold an engine of the shared C implementation against the pure-Go engine, which is the oracle: the same documents, requests, schemas and endpoints are judged by both, and the answers must agree. An engine is whatever runs the C engine's services (the cgo binding in pkg/ext-go/cgoengine, and any other build of the same C), so each engine's tests call these checks with their own Engine and nothing else changes.
Index ¶
- Constants
- func CaseFoldingMatchesGoForEveryRune(t *testing.T, e Engine)
- func Causes(err error) string
- func ContractMutationDifferential(t *testing.T, e Engine)
- func DrainErrorCausesMatchGo(t *testing.T, e Engine)
- func DrainObserverEventsMatchGo(t *testing.T, e Engine)
- func EndpointAddressDifferential(t *testing.T, e Engine)
- func EndpointDefaultClock(t *testing.T, e Engine)
- func EndpointErrorsCarryNoValue(t *testing.T, e Engine)
- func EndpointFixture(t *testing.T, e Engine)
- func EndpointMutationDifferential(t *testing.T, e Engine)
- func EndpointTimeDifferential(t *testing.T, e Engine)
- func EndpointTimeSpellingsAreStricterInTheEngine(t *testing.T, e Engine)
- func FrameValidationDifferential(t *testing.T, e Engine)
- func FramesDescriptorDifferential(t *testing.T, e Engine)
- func FramesMatchDifferential(t *testing.T, e Engine)
- func FramesRequestDifferential(t *testing.T, e Engine)
- func InstanceErrorCausesMatchGo(t *testing.T, e Engine)
- func InstanceObserverEventsMatchGo(t *testing.T, e Engine)
- func MaybeServeGuest()
- func MultiFieldMutationDifferential(t *testing.T, e Engine)
- func OpenErrorCausesMatchGo(t *testing.T, e Engine)
- func OpenObserverEventsMatchGo(t *testing.T, e Engine)
- func PairwiseMutationDifferential(t *testing.T, e Engine)
- func ProcessObserverEventsMatchGo(t *testing.T, e Engine)
- func RetryHintBoundMatchesGo(t *testing.T, e Engine)
- func Run(t *testing.T, e Engine)
- func SchemaGeneratedDifferential(t *testing.T, e Engine)
- func SchemaMatrixDifferential(t *testing.T, e Engine)
- func SessionErrorCausesMatchGo(t *testing.T, e Engine)
- func SessionObserverEventsMatchGo(t *testing.T, e Engine)
- func ZeroTimeInAnyZoneMatchesGo(t *testing.T, e Engine)
- type Check
- type Engine
- type EventLog
- type Instances
- type Launch
- type Lease
- type Session
Constants ¶
const GuestEnv = "ENGINETEST_GUEST"
GuestEnv names the mode in which a test binary serves as a plugin instead of running its tests. The process checks start the binary they run in as the child, with this variable set; an engine's TestMain calls MaybeServeGuest first.
Variables ¶
This section is empty.
Functions ¶
func CaseFoldingMatchesGoForEveryRune ¶
CaseFoldingMatchesGoForEveryRune compares how the engine and Go decide that two artifact paths differ only in case, for every character whose lowercase differs from itself and for those next to them that do not fold. The engine pins the Unicode simple lowercase mapping of one version (lib/plugin/src/unicode_lower.h), where Go follows its toolchain: this test is what makes a toolchain that moves ahead of the table visible, and is skipped, with the reason, until the table is regenerated for it (pkg/ext-go/cgoengine/tools/README.md).
func Causes ¶
Causes lists the classes an error can belong to. Two implementations agree when an error is in exactly the same classes, whatever its text.
func DrainErrorCausesMatchGo ¶
DrainErrorCausesMatchGo compares calls and closes while a call is in flight. Every probe waits for the event it depends on, so nothing here races a timer: drain with no deadline, then a close that times out.
func DrainObserverEventsMatchGo ¶
DrainObserverEventsMatchGo reports a call refused while the session drains, and the call that was in flight when the drain began.
func EndpointAddressDifferential ¶
The loopback test rests on net.SplitHostPort and net.ParseIP; the engine carries its own copies of their rules, so address text of every shape is compared.
func EndpointDefaultClock ¶
A policy with no clock uses the wall clock, as the Go package does.
func EndpointErrorsCarryNoValue ¶
An endpoint is a credential: no outcome carries a part of one.
func EndpointFixture ¶
Both implementations reproduce every outcome the fixture states.
func EndpointMutationDifferential ¶
One-field mutations of an endpoint and of a policy are judged the same.
func EndpointTimeDifferential ¶
Expiry is compared to the nanosecond, in any zone, at both edges of the allowed lifetime.
func EndpointTimeSpellingsAreStricterInTheEngine ¶
Go parses a time with a lenient fallback when its fast path refuses a string (strict RFC 3339 checking is switched off in its source), so it accepts a few spellings that are not RFC 3339: an offset of 24 hours or 60 minutes, a comma before the fraction, year 0000. The engine accepts RFC 3339 and nothing else, which is the safe side of the difference: a host built on the engine refuses an endpoint a Go host would admit, never the other way round. The engine's side is pinned; Go's is only reported, since it may tighten.
func FramesMatchDifferential ¶
func InstanceErrorCausesMatchGo ¶
InstanceErrorCausesMatchGo runs the same sequence of operations through both managers and compares the class of every error.
func InstanceObserverEventsMatchGo ¶
InstanceObserverEventsMatchGo runs the scenarios through both managers and requires the same events, in the same order: configured, retired and disposed, with the key and revision.
func MaybeServeGuest ¶
func MaybeServeGuest()
MaybeServeGuest runs the plugin the environment asks for and exits, when GuestEnv is set. Call it at the start of TestMain.
func MultiFieldMutationDifferential ¶
MultiFieldMutationDifferential changes three and four independent positions of a valid descriptor, request, response, progress frame, reverse request and package manifest at once and requires the C engine and the Go code to agree on whether the result is valid. The descriptor and request documents also carry the members that progress events and reverse calls added: an operation's progress flag, the reverse list, a request's rate and parent. EXT_PAIR_SCALE multiplies every sample size.
func OpenErrorCausesMatchGo ¶
OpenErrorCausesMatchGo compares failures while admitting a plugin.
func OpenObserverEventsMatchGo ¶
OpenObserverEventsMatchGo does the same for the ways admitting a plugin can fail: the verify, connect and handshake events, and their codes.
func PairwiseMutationDifferential ¶
PairwiseMutationDifferential changes two independent positions of a valid descriptor, request, response and package manifest at once and requires the C engine and the Go code to agree on whether the result is valid.
func ProcessObserverEventsMatchGo ¶
ProcessObserverEventsMatchGo opens a child process through the pure-Go session (process.Start as the connect step) and through the engine, which owns the child, and requires the same events and the same error classes for every way admitting it can fail, and for a call that finds the child gone.
func RetryHintBoundMatchesGo ¶
A retry hint is whole milliseconds from zero to one year: the C engine used to accept anything an int64 holds.
func Run ¶
Run runs every check as a subtest. An engine that keeps the names of the checks as tests of its own (so that a failure names the check in its CI log) calls them one by one instead.
func SchemaGeneratedDifferential ¶
SchemaGeneratedDifferential compares the C engine and the Go schema package on seeded random schemas that combine several keywords and nest, and on values built to sit on and across the bounds they declare. EXT_PAIR_SCALE multiplies the sample.
func SessionErrorCausesMatchGo ¶
SessionErrorCausesMatchGo drives identical backends through the C-backed session and the pure-Go session and requires the same error classes and the same final state for every call.
func SessionObserverEventsMatchGo ¶
SessionObserverEventsMatchGo drives the scenarios of TestSessionErrorCausesMatchGo through the C-backed and the pure-Go session with an observer, and requires the same events in the same order: the stage, the identity, the contract and operation (blank when they are not valid names), the request id and the code.
func ZeroTimeInAnyZoneMatchesGo ¶
Go's zero time is no time at all, in whatever zone it is written.
Types ¶
type Engine ¶
type Engine struct {
// Name says which engine failed, in messages.
Name string
// Call runs one of the engine's pure services (descriptor.validate, schema.validate,
// endpoint.check, ...) on bounded JSON. No plugin is executed.
Call func(operation string, input json.RawMessage) (json.RawMessage, error)
// Fixtures is the directory of the shared fixtures, lib/plugin/testdata.
Fixtures string
// NewInstances opens the engine's instance manager over string values. Optional: the checks
// that compare instance managers are skipped without it.
NewInstances func(instance.Options[string]) (Instances, error)
// Open admits a plugin through the engine, as plugin.Open does through the oracle. Optional:
// the checks that compare sessions are skipped without it.
Open func(ctx context.Context, d plugin.Descriptor, o plugin.Options) (Session, error)
// OpenProcess is Open with a child process the engine itself starts (launch.Executable is the
// test binary, which serves as the plugin: see MaybeServeGuest). Optional: the process check is
// skipped without it.
OpenProcess func(ctx context.Context, d plugin.Descriptor, launch Launch, o plugin.Options) (Session, error)
}
Engine is an implementation of the shared engine under test.
type EventLog ¶
type EventLog struct {
// contains filtered or unexported fields
}
EventLog keeps the observer events of one session: everything but the duration.
type Instances ¶
type Instances interface {
Configure(ctx context.Context, key, revision string, config json.RawMessage) error
Remove(key string) error
Close(ctx context.Context) error
// Acquire leases the instance stored under key and returns its value.
Acquire(key string) (string, Lease, error)
}
Instances is the part of an instance manager that the checks use: the same calls on the oracle (instance.Manager) and on the engine under test.
type Lease ¶
type Lease interface{ Release() error }
Lease is held until Release; Release reports the error of disposing of a retired instance.
type Session ¶
type Session interface {
Call(context.Context, plugin.ContractRef, string, json.RawMessage) (json.RawMessage, error)
State() plugin.State
Close(context.Context) error
Abort() error
}
Session is the part of a session that the checks use, the same on the oracle (plugin.Session) and on the engine under test.