Repository navigation
Conversation
Belay already journals the result of every step, so a failed job carries
everything needed to run its code again on the exact values it saw. That was
reachable only as Belay.Replay.dry_run/2, against a configured instance.
mix belay.replay 4821 --url $DATABASE_URL
Answers one of four ways: completed, diverged at <step>, blocked, or raised.
Divergence is the useful one — it names the point where today's code departs
from what production ran, which is also how you find out whether in-flight
jobs survive a worker change before deploying it.
mix belay.replay 4821 --url $DATABASE_URL \
--out test/regressions/job_4821_test.exs
writes a self-contained ExUnit file: worker, input, journal. No database, no
instance. Fix the bug, keep the file, and the production data that broke you
is in CI forever.
Belay.Replay.from_journal/4 is the storage-free entry point behind it; it
stands up an ephemeral in-memory instance for the call and tears it down
after, so fixtures run anywhere mix test runs.
Fixtures embed values copied from the database. The task docs, the guide, and
the generated file header all say so.
New guides/debugging.md, linked from the README and registered in docs.
201 tests on Memory, 219 on PostgreSQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #6 — review that one first; this diff is the replay work alone.
Belay already journals the result of every step, so a failed job carries everything needed to run its code again on the exact values it saw. Until now that was reachable only as
Belay.Replay.dry_run/2, against a configured instance.Replaying
Nothing executes. Steps, sleeps and spawns replay from the recording,
emit/2anddebit/3are inert, the database is only read — so replaying a job that is still running is safe.Four answers: completed, diverged at
<step>, blocked, raised. Divergence is the useful one: it names the point where today's code departs from what production ran, which is also how you find out whether in-flight jobs will survive a worker change before deploying it.Fixtures
$ mix belay.replay 4821 --url $DATABASE_URL --out test/regressions/job_4821_test.exsWrites a self-contained ExUnit file — worker, input, journal. No database, no instance. Fix the bug, keep the file, and the production data that broke you is in CI forever.
Belay.Replay.from_journal/4is the storage-free entry point behind it: it stands up an ephemeral in-memory instance for the call and tears it down after, so fixtures run anywheremix testruns.Verified end to end, not just unit tested
I ran a real job into the Postgres test database, replayed it, generated a fixture, and ran
mix teston the result — with the memory adapter, no database present. It passed. The generated file is in the guide.Privacy
Fixtures embed step values copied out of the database. The task moduledoc, the guide, and the generated file's own header all say so. I considered a
--redactflag and left it out: redacting the values breaks the replay, so it would be a flag that produces a file which cannot do the one thing it exists for. Documenting it honestly seemed better than a half-feature.Also
New
guides/debugging.md, linked from the README and registered inmix.exsextras. It is the differentiating feature, so it is in the guide list rather than buried in the API docs.201 tests on Memory, 219 on PostgreSQL, both green; format, warnings-as-errors and docs clean. No version bump.