ClientUtils.RunLink.Session (client_utils v0.5.0)

View Source

A run's side of its link to the harness, registered on the run's node.

Each event gets the next seq and is held until the harness acknowledges it ({:run_ack, run_id, seq} acknowledges everything up to seq). While connected, it is sent as {:run_event, run_id, session, seq, event} (the session's pid, as spex shards share a run id and each counts from 1) to the harness's listener. When the listener goes, the run carries on: about once a second it looks for a listening harness (the one it was started by, or another on the same host under the same name prefix, since a restarted harness has a new node name), and on finding one sends {:run_rejoin, run_id, node(), session} and replays what was not acknowledged, in order.

A harness answers a rejoin with {:run_adopted, run_id} before anything is replayed, or {:run_refused, run_id} when it does not serve this run (two harnesses on one host), and the session tries the next one.

{:run_cancel, run_id} halts the run. finish/2, from the run's exit, reports its exit status as the last event and waits until a harness has acknowledged every event. The run waits for a harness, but not forever: one that no harness has adopted for an hour (:orphan_ms) halts itself with status 75. Nothing it can reach will ever take it, and its harness's own ceiling (half that) has long passed.

The harness's cookie (:cookie) is set for each harness the run tries, so the run's node can be on any other cookie (ClientUtils.RunLink).

Summary

Functions

Returns a specification to start this module under a supervisor.

Report the run's exit status and wait until a harness has every event.

Start the session, unlinked: a test crashing must not take the link with it.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

finish(session, status)

Report the run's exit status and wait until a harness has every event.

report(session, event)

run_id(session)

start(opts)

Start the session, unlinked: a test crashing must not take the link with it.