Parity PR 4b: no subscribers in tests; PRJ and QRY tests (#4) #16

Closed
mercurius wants to merge 0 commits from mercurius/4-pr4b-subscriber-tests into main
Member

Purpose (feature): no host_bookclub subscriber runs in the test env, so store tests stop planning parties and trying the mesh behind each other's backs (the latent flake). The read side gets E's tests: replay idempotence, the schema contract, store delivery, and QRY's boundary and id refusals. This is PR 4b of #4, the rest of gap table H.4, stacked on PR 4: the base is mercurius/4-pr4-emitters.

Refs #4

What changes (in commit order)

  1. b5fbe2a, the flake fix.
    • The policy and the emitters start unless the app env start_subscribers is false: the default is true (host_bookclub mix.exs), and config/runtime.exs sets false only when config_env() == :test.
    • The tests that need a subscriber start it themselves, as E's suites do. The PR 3 policy store test no longer stops and restarts the app's child.
    • Why not isolate store state per test: there is one named store per VM, and its Ra system stays bound to one directory.
  2. 92d3404, PRJ.
    • Clubs: reapplying the same event changes nothing; each row carries its version and event_id; PRJ names no mesh module.
    • Books, members and readings: delivered through a real store.
    • schema_contract_test: every query column is in the PRJ schema.
    • ProjectBookclub.TestEnv fixture, like E's project_bookclub_test_env, with reckon_db as a test-only dep.
  3. 9d3e807, QRY.
    • The boundary test: QRY names no framework, mesh, evoq or Phoenix.
    • get_bookclub, get_member and get_book refuse non-binary ids.
    • An archived club is found with its status.
  4. 26c5573, a test fix. The default-env test reads host_bookclub's compiled .app file, because the loaded spec already carries the test override.

Closes gap rows: §F PRJ clubs, PRJ books/members/readings, QRY get_bookclub, QRY get_member/get_book; H.4.

Prod and dev are unchanged

Two tests show it. One reads start_subscribers == true from the compiled .app. The other reads config/runtime.exs for dev with Config.Reader and finds no override. Prod differs from dev in runtime.exs only by requiring SECRET_KEY_BASE.

Checks (msi00, CI image, at this tip 26c5573)

  • deps, format, compile --warnings-as-errors, credo --strict, dialyzer: all rc 0
  • mix test: host 186, prj 20, qry 16, fac 11, web 7; 0 failures

Mutants killed:

  • INSERT OR REPLACE changed to INSERT in the clubs projection: "reapplying the same event changes nothing"
  • a query column renamed: "the query columns are all in the PRJ schema"
  • get_bookclub accepting lists: "a non-binary id is refused"
  • the runtime.exs test override removed: "no subscriber runs in the test env"

Left alone: the QRY tests still create their own tables, because QRY has no dependency on PRJ.

For the reviewer: Uranus's note on PR 15 (checked here)

On PR 15 each fact was published twice under test: the application's supervisor started the three emitters, and the emitter suite started its own. This PR closes that. config/runtime.exs:37-39 sets start_subscribers: false in the test env alone, and HostBookclub.Supervisor.children(false) (supervisor.ex:48) then starts no subscriber, so only the suite's emitters publish. The mutant "the runtime.exs test override removed" is killed by "no subscriber runs in the test env". Please check this.

The name of emit_member_registered_v1_to_mesh_test.exs is kept on purpose, even though the suite covers three emitters. The Erlang twin's suite has the same name and the same scope (mcl-bookclub emit_member_registered_v1_to_mesh_tests.erl:114-116), and the alignment ruling says Erlang's shape wins.

Purpose (feature): no host_bookclub subscriber runs in the test env, so store tests stop planning parties and trying the mesh behind each other's backs (the latent flake). The read side gets E's tests: replay idempotence, the schema contract, store delivery, and QRY's boundary and id refusals. This is PR 4b of #4, the rest of gap table H.4, stacked on PR 4: the base is mercurius/4-pr4-emitters. Refs #4 ## What changes (in commit order) 1. **b5fbe2a, the flake fix.** - The policy and the emitters start unless the app env `start_subscribers` is false: the default is true (host_bookclub `mix.exs`), and `config/runtime.exs` sets false only when `config_env() == :test`. - The tests that need a subscriber start it themselves, as E's suites do. The PR 3 policy store test no longer stops and restarts the app's child. - Why not isolate store state per test: there is one named store per VM, and its Ra system stays bound to one directory. 2. **92d3404, PRJ.** - Clubs: reapplying the same event changes nothing; each row carries its version and event_id; PRJ names no mesh module. - Books, members and readings: delivered through a real store. - `schema_contract_test`: every query column is in the PRJ schema. - `ProjectBookclub.TestEnv` fixture, like E's `project_bookclub_test_env`, with `reckon_db` as a test-only dep. 3. **9d3e807, QRY.** - The boundary test: QRY names no framework, mesh, evoq or Phoenix. - get_bookclub, get_member and get_book refuse non-binary ids. - An archived club is found with its status. 4. **26c5573, a test fix.** The default-env test reads host_bookclub's compiled `.app` file, because the loaded spec already carries the test override. Closes gap rows: §F PRJ clubs, PRJ books/members/readings, QRY get_bookclub, QRY get_member/get_book; H.4. ## Prod and dev are unchanged Two tests show it. One reads `start_subscribers == true` from the compiled `.app`. The other reads `config/runtime.exs` for dev with `Config.Reader` and finds no override. Prod differs from dev in runtime.exs only by requiring `SECRET_KEY_BASE`. ## Checks (msi00, CI image, at this tip 26c5573) - deps, format, compile `--warnings-as-errors`, credo `--strict`, dialyzer: all rc 0 - mix test: host 186, prj 20, qry 16, fac 11, web 7; 0 failures Mutants killed: - `INSERT OR REPLACE` changed to `INSERT` in the clubs projection: "reapplying the same event changes nothing" - a query column renamed: "the query columns are all in the PRJ schema" - get_bookclub accepting lists: "a non-binary id is refused" - the runtime.exs test override removed: "no subscriber runs in the test env" Left alone: the QRY tests still create their own tables, because QRY has no dependency on PRJ. ## For the reviewer: Uranus's note on PR 15 (checked here) On PR 15 each fact was published twice under test: the application's supervisor started the three emitters, and the emitter suite started its own. This PR closes that. `config/runtime.exs:37-39` sets `start_subscribers: false` in the test env alone, and `HostBookclub.Supervisor.children(false)` (`supervisor.ex:48`) then starts no subscriber, so only the suite's emitters publish. The mutant "the runtime.exs test override removed" is killed by "no subscriber runs in the test env". Please check this. The name of `emit_member_registered_v1_to_mesh_test.exs` is kept on purpose, even though the suite covers three emitters. The Erlang twin's suite has the same name and the same scope (`mcl-bookclub` `emit_member_registered_v1_to_mesh_tests.erl:114-116`), and the alignment ruling says Erlang's shape wins.
Store tests leave member registrations in the one shared store; the
live policy planned a party on every fifth, and the emitters now in
host_bookclub would try the mesh. host_bookclub's start_subscribers env
is true by default (mix.exs) and false only when config/runtime.exs is
read for test, as mcl-bookclub's suites never start the app's handlers
either. Tests that need a subscriber start it themselves, so the policy
store test no longer stops and restarts the live child. Dev and prod
are unchanged; the supervisor test reads both paths.
As mcl-bookclub's PRJ suites: clubs, books, members and readings are
delivered from a real store through its evoq subscription
(ProjectBookclub.TestEnv); the row carries the applied event_id and
version; reapplying a stored event changes nothing; every QRY SELECT
column is in BookclubReadModelStore.schema/0; no PRJ source names a
mesh module.
As mcl-bookclub's get_*_by_id suites: no QRY source names a framework,
the event store or a mesh module; get_bookclub/member/book_by_id refuse
a non-binary id; an archived club is found with its status.
Read host_bookclub's subscriber default from its .app file
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
c4 model / c4-model-1 (push) Successful in 5s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 6m36s
26c557328c
The loaded application spec already holds the test env's override, so
the default a release ships is read from the compiled .app file.
mercurius changed target branch from mercurius/4-pr4-emitters to main 2026-12-01 09:14:16 +00:00
Member

Landed by fast-forward: main is 26c557328c (from 3d1bd83a), PASS r=1, CI 6217, 6222. This repository does not allow the manually-merged style, so the PR is closed by hand.

Landed by fast-forward: main is 26c557328c48013a4cbc6fa27824d5b41fa344f1 (from 3d1bd83a), PASS r=1, CI 6217, 6222. This repository does not allow the manually-merged style, so the PR is closed by hand.
terra closed this pull request 2026-12-01 09:42:03 +00:00
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
c4 model / c4-model-1 (push) Successful in 5s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 6m36s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-bookclub-phoenix!16
No description provided.