Repository navigation
feat(core): Durable.Testing helpers + fix for string step errors - #18
Merged
Merged
Conversation
…n running
A step returning {:error, "declined"} handed the raw string to the
failed/compensated write. The error column is a map, so the write was
rejected: without compensations the run stayed :running until stale-lock
recovery; with them, the executor crashed. handle_step_failure/4 now
normalizes and sanitizes the error, as the parallel-child path already did.
run_workflow/3 and drain/2 run a workflow inline in the test process, including parallel branches and child workflows, until nothing is left to do. Sleeps end immediately and retry backoff is skipped. assert_status, assert_step, assert_waiting_for_input and assert_waiting_for_event give failure messages that show the run's current step and error. Adds guides/testing.md to HexDocs, the README and the site.
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.
Summary
Adds
Durable.Testing, which runs workflows inline in ExUnit and gives assertions for the result (roadmap milestone M03). Writing its tests turned up an engine bug, which is fixed in its own commit.Durable.Testingrun_workflow/3anddrain/2run the workflow in the test process, including parallel branches and child workflows, until nothing is left to do.Backoff.pause/1checks a process flag, so both step retries and compensation retries skip it.allow/3.drain/2raises if queue processing is on, because queue workers would race the test for the same runs.assert_status/3,assert_step/4,assert_waiting_for_input/3,assert_waiting_for_event/3andsteps/2. Failed assertions print the run's current step and error.assert_stepfinds steps insideparallelandbranchblocks by their plain name.importinto your ownDataCase, not theDurable.TestCasetemplate the M03 plan described. Users already have a template that sets up the sandbox, and ExUnit only lets a test module use one.guides/testing.md, linked from HexDocs, the README and the site.Fix: string step errors left runs stuck in
:runningA step returning
{:error, "card declined"}passed the raw string to the write that marks the run failed or compensated. Theerrorcolumn is a map, so the write was rejected:cas_updatereturned{:error, changeset}without raising, somark_failed's fallback never ran. The run stayed:runninguntil stale-lock recovery.Ecto.ChangeError.handle_step_failure/4now converts the error to a map and makes it safe to store as JSON, the same way the parallel-child path already did. All failure paths go through this one function. The guides show steps returning{:error, "..."}, so this affects production, not just tests.Roadmap
agents/ROADMAP.mdand the milestone docs are updated to match what has shipped since March (1.0, the dashboard and CLI, and now testing).Known gaps
drain/2doesn't trigger wait timeouts, because the timeout worker only runs with the queue on. This is in the guide and listed as a roadmap follow-up.Test plan
mix testindurable/: 488 passed. The newtest/durable/testing_test.exscovers parallel blocks, sleeps, input waits, retries without backoff, child workflows, compensations, string errors and failure messages.mix compile --warnings-as-errors,mix credo --strict,mix formatmix docs: no new warningsdurable_dashboardtest suite (not run locally)