Documentation
¶
Overview ¶
Package conformance checks a built plugin against Stampede's plugin contract. Plugin authors run it from a test, pointing it at the plugin executable and at a few step calls that should work against a test server they start:
func TestConformance(t *testing.T) {
addr := startFakeServer(t)
bin := conformance.Build(t, ".", "echo")
conformance.Run(t, bin, conformance.Options{
Cases: []conformance.Case{
{Step: "say", Config: map[string]any{"text": "hi", "addr": addr}},
},
})
}
The suite starts the plugin the way Stampede does (a child process speaking gRPC through hashicorp/go-plugin) and checks that:
- it describes itself validly: name, version, unique step names, and a config schema for every step that compiles and accepts the cases;
- sessions follow the lifecycle: open, execute, close, close again, and a closed or unknown session fails cleanly;
- bad input fails cleanly, as a failed step with a short error class rather than an RPC error or a crash: unknown steps, configs that are not objects, configs with unknown or missing settings;
- it honours timeouts: a call with a tiny timeout comes back promptly;
- it is safe under concurrency: many virtual users with their own sessions run the cases at once;
- it never dies: the process is still running at the end.
Index ¶
Constants ¶
View Source
const MaxClassLen = 64
MaxClassLen is the longest error class the suite accepts.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Case ¶
type Case struct {
Step string
// Config is the step's config, marshalled to JSON.
Config any
// WantClass, when set, means the call must fail with this error class.
WantClass string
}
Case is one step call.
type Options ¶
type Options struct {
// Cases are step calls to make. Those without WantClass must succeed
// against the environment the test set up; at least one is required.
Cases []Case
// VUs is how many virtual users run the cases at once (default 50).
VUs int
// Iterations is how often each user runs them (default 3).
Iterations int
// Timeout bounds each call (default 10s).
Timeout time.Duration
// SkipBadInput lists steps the suite must not call with bad configs,
// for a step whose schema accepts any object and that does something
// drastic with it. Every other step is called with configs that are
// not objects or have unknown settings, and must fail cleanly.
SkipBadInput []string
}
Options configures the suite.
Click to show internal directories.
Click to hide internal directories.