Skip to content

test(eventstore): silence expected disconnect chatter - #102

Merged
yordis merged 1 commit into
mainfrom
yordis/test-silence-postgrex-disconnect-info
Apr 29, 2026
Merged

test(eventstore): silence expected disconnect chatter#102
yordis merged 1 commit into
mainfrom
yordis/test-silence-postgrex-disconnect-info

Conversation

@yordis

@yordis yordis commented Apr 29, 2026

Copy link
Copy Markdown
Member
  • keep adapter-backed test runs from drowning in expected connection teardown noise
  • scope the logger suppression to the DBConnection path that emits informational disconnect messages while preserving warnings and errors
  • make the full adapter-inclusive suite easier to trust by leaving only unexpected failures visible

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented Apr 29, 2026

Copy link
Copy Markdown

PR Summary

Cursor Bugbot is generating a summary for commit 69be472. Configure here.

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Walkthrough

A new test helper module is introduced to suppress module-level logging for DBConnection.Connection during test execution. Five existing test files are updated to import this helper and invoke it during test setup, reducing log noise without altering test assertions or behavior.

Changes

Cohort / File(s) Summary
Logger Level Helper Module
test/support/module_logger_level_helpers.ex
New module providing suppress_module_log_level/2 function. Reads current module logger level, applies requested level, and registers cleanup callback to restore original level on test exit.
Test Modules Using Logger Helper
test/aggregates/snapshotting_postgres_test.exs, test/event_store/adapters/event_store/event_store_prefix_test.exs, test/event_store/adapters/event_store/event_store_test.exs, test/opentelemetry/application_e2e_test.exs, test/support/event_store_test_case.ex
Each module adds alias to ModuleLoggerLevelHelpers and introduces setup_all callback that suppresses warning-level logs from DBConnection.Connection. Changes are consistent across all files with minimal additions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Whiskers twitch with logging cheer,
DBConnection's warnings disappear!
Helpers hop through test setup clean,
Restoring logs in between.
Less noise, more clarity—tests now sing! 🎵

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test(eventstore): silence expected disconnect chatter' directly and specifically describes the main change: suppressing expected disconnect log noise in EventStore tests.
Description check ✅ Passed The description clearly relates to the changeset, detailing the rationale for suppressing log messages from DBConnection teardown and the scope of the suppression.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/test-silence-postgrex-disconnect-info

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/support/module_logger_level_helpers.ex (1)

8-17: Consider adding a dedicated DBConnection helper to remove repeated literals.

DBConnection.Connection + :warning is repeated across multiple test modules. A wrapper here would centralize intent and reduce drift risk.

♻️ Proposed refactor
 defmodule Commanded.TestSupport.ModuleLoggerLevelHelpers do
@@
   def suppress_module_log_level(module, level) do
@@
   end
+
+  def suppress_dbconnection_disconnect_logs do
+    suppress_module_log_level(DBConnection.Connection, :warning)
+  end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/support/module_logger_level_helpers.ex` around lines 8 - 17, Extract the
repeated literal pair DBConnection.Connection and :warning into a dedicated
helper (e.g., suppress_dbconnection_warning or suppress_db_conn_warning) that
delegates to suppress_module_log_level(module, level) by calling
suppress_module_log_level(DBConnection.Connection, :warning); add this new
function near suppress_module_log_level in
test/support/module_logger_level_helpers.ex and update all test modules that
currently call suppress_module_log_level(DBConnection.Connection, :warning) to
call the new helper instead to centralize intent and reduce duplication.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/support/module_logger_level_helpers.ex`:
- Around line 8-17: Extract the repeated literal pair DBConnection.Connection
and :warning into a dedicated helper (e.g., suppress_dbconnection_warning or
suppress_db_conn_warning) that delegates to suppress_module_log_level(module,
level) by calling suppress_module_log_level(DBConnection.Connection, :warning);
add this new function near suppress_module_log_level in
test/support/module_logger_level_helpers.ex and update all test modules that
currently call suppress_module_log_level(DBConnection.Connection, :warning) to
call the new helper instead to centralize intent and reduce duplication.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbef0f5f-5c49-4fd7-8508-adb0cf78fbfe

📥 Commits

Reviewing files that changed from the base of the PR and between 2f63bfa and 69be472.

📒 Files selected for processing (6)
  • test/aggregates/snapshotting_postgres_test.exs
  • test/event_store/adapters/event_store/event_store_prefix_test.exs
  • test/event_store/adapters/event_store/event_store_test.exs
  • test/opentelemetry/application_e2e_test.exs
  • test/support/event_store_test_case.ex
  • test/support/module_logger_level_helpers.ex

@yordis
yordis merged commit 3761509 into main Apr 29, 2026
3 checks passed
@yordis
yordis deleted the yordis/test-silence-postgrex-disconnect-info branch April 29, 2026 07:24
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