Documentation
¶
Overview ¶
Package conformance checks a connector against Echo's wire protocol. It has three parts:
- Schema validates captures and decisions against wire/schema.json, the protocol as a JSON Schema generated from package wire.
- testdata/*.json holds the shared vectors: capture and decision pairs, including what a connector must do when Echo is unreachable, answers 5xx or times out (fail closed). Connector suites in other languages read them too.
- Main runs a strict stand-in Echo (`rhythm echo conformance`) that a connector's end-to-end test points at. It validates every capture it gets, refuses the bad ones, answers the rest like Echo and prints a pass or fail table when it stops.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Scenarios = []Scenario{ {"email", "an email reported before it is sent", func(c wire.Capture) bool { return c.Kind == "email" && c.Phase == "" }}, {"email-after", "a real send's outcome reported after (observe)", func(c wire.Capture) bool { return c.Kind == "email" && c.Phase == wire.After }}, {"http-before", "an HTTP request reported before it is sent", func(c wire.Capture) bool { return c.Kind == "http" && c.Phase == wire.Before }}, {"http-after", "an allowed request's response reported after", func(c wire.Capture) bool { return c.Kind == "http" && c.Phase == wire.After }}, {"run", "a capture tied to a run", func(c wire.Capture) bool { return c.Run != "" }}, {"site", "a capture that names its site", func(c wire.Capture) bool { return c.Source.Site != "" }}, {"attachments", "an email that lists its attachments", func(c wire.Capture) bool { return c.Email != nil && len(c.Email.Attachments) > 0 }}, {"wire-1", "a capture in wire 1", func(c wire.Capture) bool { return c.Version == 1 }}, {"wire-2", "a capture in wire 2", func(c wire.Capture) bool { return c.Version == 2 }}, }
Scenarios are what the stand-in recognizes in captures, for Expect and the report, in report order.
var Usage = `rhythm echo conformance: a strict stand-in Echo for a connector's end-to-end test Usage: rhythm echo conformance [flags] Runs a strict stand-in Echo for a connector's end-to-end test. Point the connector at it (RHYTHM_ECHO_URL), run the test, then stop it (Ctrl-C or SIGTERM): it prints a pass or fail table and exits 1 on any fail. Every capture is checked against Echo's wire schema; a bad one is answered 400 with what is wrong. GET /v1/conformance returns the report so far as JSON. Flags: --listen <addr> API address (default 127.0.0.1:8025) --smtp <addr> also run Echo's SMTP sink there (default off) --mode <m> seal (default) or observe --token <t> require this X-Echo-Token --allow <hosts> hosts reachable when sealed, comma separated --wire <n> speak this wire version, to check a connector falls back (default ` + strconv.Itoa(wire.Version) + `) --expect <list> scenarios the run must include, comma separated: email, email-after, http-before, http-after, run, site, attachments, wire-1, wire-2 --json print the report as JSON instead of a table Exit codes: 0 every check passed, 1 a check failed, 2 usage error, 3 couldn't listen. ` + flagtext.Footer
Usage is the help for `rhythm echo conformance`.
Functions ¶
Types ¶
type Options ¶
type Options struct {
Mode string // seal (default) or observe
Token string // required in X-Echo-Token when set
Allow []string // hosts reachable when sealed
// Wire is the wire version the stand-in speaks: 0 for this Echo's
// (wire.Version), or an older one to check that a connector falls back.
// Speaking 1 it says so in /v1/health and refuses newer captures the way
// an Echo of that version does.
Wire int
// Expect lists the scenarios the run must include (see Scenarios); the
// report fails each one no capture showed.
Expect []string
}
Options configure the stand-in.
type Problem ¶
type Problem struct {
Problems []string `json:"problems"` // each way it broke the schema
Capture json.RawMessage `json:"capture"` // as the connector sent it
}
Problem is a capture the stand-in refused, with why.
type Report ¶
type Report struct {
OK bool `json:"ok"` // no row failed
Captures int `json:"captures"` // how many arrived, valid or not
Rows []Row `json:"rows"`
Problems []Problem `json:"problems,omitempty"`
}
Report is what the stand-in saw: one row per check, then the refused captures.
type Row ¶
type Row struct {
Check string `json:"check"`
Result string `json:"result"`
Detail string `json:"detail"`
}
Row is one line of the report. Result is pass, fail or info.
type Scenario ¶
type Scenario struct {
Name string // the ID Options.Expect lists and the report names
About string // what it is, for the report
Match func(wire.Capture) bool // whether a capture is one
}
Scenario is one kind of capture the stand-in recognizes.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema validates documents against a JSON Schema in the subset conformance/gen writes: type, properties, required, additionalProperties, items, enum, minimum, maximum, $ref to $defs and x-since (the wire version that added a field).
func WireSchema ¶
WireSchema is the schema for the wire protocol this Echo speaks.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
conformance
command
Command conformance runs Echo's strict stand-in on its own, for the connectors' end-to-end tests until `rhythm echo conformance` exists:
|
Command conformance runs Echo's strict stand-in on its own, for the connectors' end-to-end tests until `rhythm echo conformance` exists: |
|
Command gen writes wire/schema.json, Echo's wire protocol as a JSON Schema, from the Go types in package wire.
|
Command gen writes wire/schema.json, Echo's wire protocol as a JSON Schema, from the Go types in package wire. |