ulo-rpc-conformance
The conformance suite every ulo-rpc link runs. A link is the transport under ulo-rpc's client
and server: TCP, UDP, a broker, or one written outside the ulo repository. One macro stamps the
suite's scenarios as #[test]s against the link: requests and replies, events, the four call
shapes, cancellation, deadlines, drain, recovery from a dropped connection, two instances on one
pattern and admission under load. A link whose tests/conformance.rs passes keeps the same
promises as the links ulo ships, each of which runs the suite in CI.
Install
The suite is a dev-dependency of the link crate. The example below runs it against ulo-rpc-tcp,
which stands in for your link:
[]
= "=0.1.0-alpha.3"
= { = "=0.1.0-alpha.3", = ["tokio"] }
= "=0.1.0-alpha.3"
Each crate is pinned with =, since a caret on a pre-release also takes a later alpha, which may
break this one. tokio brings OnTokio, the runtime half of a link built on tokio; a link on smol
enables smol and names OnSmol instead.
First run
tests/conformance.rs:
use ;
use BoundAddr;
use Relay;
use ;
use Tcp;
/// One scenario's environment: a server on a port of its own, the client reaching it through a
/// relay that `disrupt` cuts.
conformance_suite!;
cargo test --test conformance runs every scenario as a test of its own, named after the scenario,
and reports the three declared above as ignored with their reasons.
Your link takes Tcp's place. start answers an environment no other scenario shares: a fresh
broker or namespace, or nothing where the server binds port 0. link answers the server's link,
client_link the client's once the servers are bound, and disrupt severs the client's
connection. A link run against a broker in a container starts it in start, through
relay::unshadowed when the container's port is published on the host, and fails a start that
does not come up through startup_failed!. The suite depends on no container library; the link's
own dev-dependencies bring one.
community-link
is a complete link written as a crate outside the workspace would write it, against ulo-rpc's
public link API alone, with its tests/conformance.rs run in CI.
What a link declares
A link's Capabilities hold every ability unless the link declares one absent with
without_<ability>(reason). A link that declares nothing is held to every scenario, and fails the
ones it cannot keep. A declared absence changes what the scenarios assert: a scenario whose ability
is absent asserts the refusal the declaration names, or, where it cannot run without the ability,
is skipped with one line naming the scenario, the ability and the reason on standard error.
not_applicable { scenario: "reason" } is for a scenario no capability describes, such as the
held-cancel scenarios above on a link that holds no cancel. The test is stamped
#[ignore = "<reason>"], a name that is no scenario fails to compile, and
cargo test -- --ignored runs it, where it fails. A link that does hold a cancel until the
server's opened declares the same three not applicable too: they read the link's client table
through a probe outside the suite's public API, which the links ulo ships attach.
Scenarios
The scenarios are the functions of the cases
modules, each documented with what it asserts.
Will it work for me
- Rust 1.88 or later.
- Runtimes: the suite names none.
tokioandsmolbring the two harnesses; another runtime implementsHarness. - Parallelism: the scenarios run in parallel under libtest.
Broker::PARALLELbounds how many hold an environment at once, and a host short of memory setsULO_CONFORMANCE_PARALLELto a positive integer; the smaller of the two applies. - Startup failures are written to a file before the test panics: under
$ULO_CONFORMANCE_FAILURESwhen it is set, otherwise underconformance-failuresin the target directory the test binary was built into. - Stability: the scenarios,
Broker,Harnessandconformance_suite!are the contract a link is held to. While the version is a pre-release, everyulocrate releases at one version and a pre-release may change any of them. From0.1.0on, a release that adds or tightens a scenario or changes the contract is a minor release,0.1to0.2, since a link that passed the earlier suite can fail it.
Where to go next
- The API docs on docs.rs, or
cargo doc --open. - The suites of the links
uloships:ulo-rpc-tcpandulo-rpc-udp, run on every build, and the brokers' behind each crate'sintegrationfeature, a container per scenario: NATS, Redis, MQTT, RabbitMQ and Kafka.
License
MIT.