Skip to content

test: supervise the shared Integration.TestRepo in setup_all - #164

Merged
ocean merged 1 commit into
devfrom
fix-flaky-integration-testrepo
Dec 2, 2026
Merged

ocean merged 1 commit into
devfrom
fix-flaky-integration-testrepo

Conversation

@ocean

@ocean ocean commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Fixes the flaky {:error, {:already_started, pid}} seen in CI on #159, which invalidated all 19 tests in InExpressionComprehensiveTest.

in_expression_comprehensive_test, returning_clause_test, ecto_sqlite3_returning_debug_test and ecto_sqlite3_crud_compat_test all started EctoLibSql.Integration.TestRepo with start_link in setup_all and never stopped it. The repo only died when its linked setup_all process exited, asynchronously, so the next module could still find the name registered. They now use start_supervised!, which ExUnit stops before the next module runs.

Verified with a throwaway probe of 20 modules sharing the repo: with start_link the repo was still registered at the start of 19 of them and one hit already_started; with start_supervised! none did. The four modules pass across 15 seeds, the full suite passes (871 tests), and on_exit cleanup still removes the database files.

https://claude.ai/code/session_01LR8MxKNHZfhfopXM58LKwG

Summary by CodeRabbit

  • Tests
    • Improved test setup by having the test framework supervise shared repository processes and stop them between test modules.

Four modules started EctoLibSql.Integration.TestRepo with start_link in
setup_all and never stopped it. The repo died only when its linked
setup_all process exited, asynchronously, so the next module could find
the name still registered and fail with :already_started, invalidating
every test in it. start_supervised! stops the repo before the next
module runs.

Closes kata rsn2.

Claude-Session: https://claude.ai/code/session_01LR8MxKNHZfhfopXM58LKwG
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Four test modules now start the shared TestRepo with start_supervised! in setup_all instead of calling start_link directly.

Changes

Test repository setup

Layer / File(s) Summary
Supervised TestRepo startup
test/ecto_sqlite3_crud_compat_test.exs, test/ecto_sqlite3_returning_debug_test.exs, test/in_expression_comprehensive_test.exs, test/returning_clause_test.exs
Each setup callback starts TestRepo with start_supervised!. The CRUD compatibility test also adds a comment about the supervised lifecycle.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Merge Risk: Minimal · up to ea7ed

This only changes how tests start the shared repo so that it shuts down between modules. It does not affect production behavior, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "test: supervise the shared Integration.TestRepo in setup_all" matches the main change. Four test modules now start the shared TestRepo with start_supervised! in setup_all instead of start_l…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "test: supervise the shared Integration.TestRepo in setup_all" matches the main change. Four test modules now start the shared TestRepo with start_supervised! in setup_all instead of start_link, so ExUnit stops the repo before the next module starts it. The title is specific and concise, and it names the affected repo and hook.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the test repo's start,
start_supervised! plays its part.
Four setups now follow the same way,
The shared repo stops at day's end,
And hops to the next test again.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b09b6a2 and ea7ed23.

Files selected for processing: 4

  • test/ecto_sqlite3_crud_compat_test.exs
  • test/ecto_sqlite3_returning_debug_test.exs
  • test/in_expression_comprehensive_test.exs
  • test/returning_clause_test.exs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@ocean

ocean commented Dec 2, 2026

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ocean
ocean merged commit a8238d9 into dev Dec 2, 2026
13 checks passed
@ocean
ocean deleted the fix-flaky-integration-testrepo branch December 4, 2026 04:46
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