No description
  • Erlang 52.3%
  • Shell 47.7%
Find a file
2026-11-24 01:12:54 +01:00
.github/workflows ci: every Erlang block in the README and guides compiles, and the release waits on it 2026-10-21 16:14:02 +02:00
scripts mcl-testkit: an mcl-* service's real mesh path over an in-memory mesh 2026-09-24 01:55:50 +02:00
src 1.0.0: wire 1.0, on macula 15.6 / mcl_om 1.0 2026-10-17 03:24:55 +02:00
test mcl-testkit: an mcl-* service's real mesh path over an in-memory mesh 2026-09-24 01:55:50 +02:00
.gitignore mcl-testkit: an mcl-* service's real mesh path over an in-memory mesh 2026-09-24 01:55:50 +02:00
CHANGELOG.md docs: the changelog entry says macula 16, as its own Changed bullets do 2026-10-22 02:34:26 +02:00
CODE_OF_CONDUCT.md mcl-testkit: an mcl-* service's real mesh path over an in-memory mesh 2026-09-24 01:55:50 +02:00
CONTRIBUTING.md mcl-testkit: an mcl-* service's real mesh path over an in-memory mesh 2026-09-24 01:55:50 +02:00
LICENSE mcl-testkit: an mcl-* service's real mesh path over an in-memory mesh 2026-09-24 01:55:50 +02:00
README.md README: add the Buy Me a Coffee badge 2026-11-23 22:20:48 +00:00
rebar.config docs: the changelog entry says macula 16, as its own Changed bullets do 2026-10-22 02:34:26 +02:00
SECURITY.md SECURITY.md: response times, attachment and identity rules, drills (macula-io/macula#174) 2026-10-31 02:59:45 +01:00

mcl-testkit

Buy Me a Coffee

A test harness for mcl-* services. It runs a service's real mesh path (mcl_om:macula_client/0, mcl_om:realm/0, macula:publish/subscribe) over an in-memory macula mesh, with no station, no QUIC and no certificate.

It composes macula_testkit's loopback pools into the mcl_om identity. with_mesh/1 stands up a two-pool cluster and stubs the identity (with meck), so the service resolves the SERVICE pool and a test realm. The harness keeps the second, TEST pool: it publishes facts "from another node" and asserts on what the service publishes back.

echo_round_trip_test() ->
    mcl_testkit:with_mesh(fun(Mesh) ->
        {ok, _} = mcl_testkit:boot_service(my_service),
        ok = mcl_testkit:subscribe(Mesh, <<"out">>),
        ok = mcl_testkit:publish(Mesh, <<"in">>, #{n => 1}),
        #{echoed := _} = mcl_testkit:await(<<"out">>, fun(P) -> maps:is_key(echoed, P) end)
    end).

Install

As a test dependency:

{profiles, [{test, [{deps, [{mcl_testkit, "~> 1.0"}]}]}]}.

The 1.0 line is the wire 1.0 line: it builds on the macula-16 mcl_om and on the macula_testkit that answers wire 1.0's pool calls. It is a major and not a 0.2 because every service floats mcl_om at ~> 0.x with no lockfile, so no ~> 0.x resolves to it: a service moves onto the new wire when it asks to, by name.

API

Function What it does
with_mesh(Fun), with_mesh(#{realm => R}, Fun) Runs Fun(Mesh) on a fresh in-memory mesh, then removes the stub and stops the cluster. The realm defaults to 32 zero bytes.
boot_service(Mod), boot_service(Mod, #{apps => [...]}) Starts mcl_om, boots Mod through mcl_om:boot/1, then starts the listed sibling applications.
publish(Mesh, Topic, Fact) Publishes from the TEST pool, as another node would.
subscribe(Mesh, Topic) Subscribes the calling process through the TEST pool.
await(Topic, Match), await(Topic, Match, Ms) Waits for a fact on Topic that Match accepts. Raises {await_timeout, Topic} after 2 s by default. Events for other topics stay in the mailbox.
service_pool/1, test_pool/1, realm/1 Read the mesh.

Pub/sub only, like macula_testkit: RPC and advertise are not simulated.

Licence

Apache-2.0. See LICENSE.