Run the conformance suite¶
The adapter's acceptance test is the core's conformance suite, run unchanged and once for each wire format. Run it from a checkout of messaging-nats:
No server needs installing: the tests start an embedded one. The suites are TestCoreConformance and
TestJetStreamConformance, each with a subtest for binary, structured, masstransit and
nservicebus.
The project's task runner has just test (with coverage), just test-race and just ci.
What each backend runs¶
| Backend | Suite | Extras |
|---|---|---|
Core |
conformance.Run |
conformance.WithForeign, for the unreadable-message row |
JetStream |
conformance.RunDurable |
conformance.WithKillable and conformance.WithForeign |
Run refuses a backend that declares SurvivesRestart, so JetStream can only run under RunDurable.
See the backend contract.
The fixtures¶
- Core. One embedded server for each test, from
natstest.StartServer, because two rows open more than one backend and expect them to share a broker. - JetStream. A fixture that owns the store directory.
Openbuilds a server over it and creates the operator's stream,CONFORMANCE, carryinga.>andb.>.Restartstops the server and starts a new one on the same directory. It also implementsconformance.Binder, with a stream that does not exist, for the binding row. - Foreign producer. Both suites send the three kinds of unreadable message (
Unclaimed,Ambiguous,Malformed) by publishing straight to the server, past the bus's writer. Every suite here reads both CloudEvents formats. - Killable.
Killtakes the link away the way an operator does, by deleting the consumer the source is attached to. It waits for the source's pull to reach the server first, to avoid the 30-second late notice.
Run it for your own wiring¶
To run the suite against your own configuration of the adapter, for example with a different Format
and Reads, call conformance.Run from a test and supply the backend:
conformance.Run(t, func(t *testing.T) messaging.Backend {
return nats.Core(nats.Settings{
Options: []client.Option{client.InProcess(serverFor(t))},
Format: cloudevents.Structured(),
})
}, conformance.WithForeign(yourForeign))
serverFor is a helper that starts an embedded server; see conformance_test.go in the adapter for the
one it uses.
For the contract the rows enforce, see the backend contract.