Skip to content

Wait for the transition log row in timeline-driven gen.sync tests - #172

Merged
C-Sinclair merged 1 commit into
mainfrom
test/gen-sync-await-log
Nov 16, 2026
Merged

C-Sinclair merged 1 commit into
mainfrom
test/gen-sync-await-log

Conversation

@C-Sinclair

Copy link
Copy Markdown
Contributor
  • Mix.Tasks.AshWorkflow.Gen.SyncTest gains await_log/4, which polls the transition log until it matches the expected value. It shares a deadline loop, await/3, with await_state/3.
  • The two tests that read the log after a live AshWorkflow.Scheduler.Precise.Timeline run now use it: "returns a failed sync to syncing with a fresh set of attempts" and "an update during a push resyncs once the push succeeds".
  • The cause is ordering on the ETS data layer. The timeline runs the sync action in its own process. AshWorkflow.Changes.RecordEvent appends the log row in an after_action hook, after the new state is already readable. With no transaction around the two writes, await_state/3 could return on :synced before the :synced row existed. CI hit this once: left [:failed, :syncing, :syncing], right [:failed, :synced, :syncing, :syncing].
sequenceDiagram
    participant T as Timeline process
    participant E as ETS
    participant X as Test process
    T->>E: write state :synced
    X->>E: await_state sees :synced
    X->>E: read log (row missing)
    T->>E: RecordEvent after_action appends :synced row
Loading

A Process.sleep(100) placed before the log append in RecordEvent reproduces the CI failure on main every time. The same test passes with this change. The other recipe generator tests drive the timeline with Timeline.run_due/1 in the test process, so their log reads are not affected.

On the ETS data layer, the precise timeline's sync action makes the new state visible before RecordEvent's after_action hook appends the log row. await_state/3 returned on the state alone, so the log read straight after it could miss the last row.

Add await_log/4, which polls the log until it matches, and share the deadline loop with await_state/3. Use it in the two gen.sync tests that read the log after a timeline run.
@C-Sinclair
C-Sinclair marked this pull request as ready for review November 16, 2026 12:20
@C-Sinclair
C-Sinclair merged commit a56f778 into main Nov 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant