Skip to content

test(nodes): the Elasticsearch store test restores the package attribute it binds - #2915

Merged
dk-rocketride merged 1 commit into
developfrom
fix/es-test-restores-package-attr
Nov 1, 2026
Merged

dk-rocketride merged 1 commit into
developfrom
fix/es-test-restores-package-attr

Conversation

@dk-rocketride

@dk-rocketride dk-rocketride commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #2912, from its CodeRabbit thread. I fixed it here, not on #2912: a commit there would have dismissed the approval.

test_the_elasticsearch_store_does_not_open_with_an_unfilled_key imports nodes.store_elasticsearch.elasticsearch_store inside patch.dict(sys.modules, ...) with stand-in elasticsearch modules. The import also binds the module as an attribute of nodes.store_elasticsearch. patch.dict restores sys.modules on exit but not that attribute, so a later test that reads it (or a dotted mock.patch target) could get the stand-in-backed module. monkeypatch now restores the attribute, or deletes it if it wasn't there.

Test-only. The file's 5 tests pass in the current engine image.

🤖 Generated with Claude Code

https://claude.ai/code/session_015nTVr6jfSFYm1GppxbjghP

Summary by CodeRabbit

  • Tests
    • Improved isolation of Elasticsearch credential tests by restoring package state after the test, reducing the chance of unintended effects on other tests. This change affects test reliability only and does not alter user-facing Elasticsearch behavior.

…ute it binds

Importing nodes.store_elasticsearch.elasticsearch_store inside patch.dict
also sets it as an attribute of nodes.store_elasticsearch. patch.dict
restores sys.modules on exit, not that attribute, so a later test reading
it could get the module built on the stand-in elasticsearch. monkeypatch
now restores it (CodeRabbit on #2912).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015nTVr6jfSFYm1GppxbjghP
@github-actions

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9d2a4bc and aa90917.

Files selected for processing: 1
  • nodes/test/test_elasticsearch_credentials.py

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

Walkthrough

The Elasticsearch credential test saves the package’s existing elasticsearch_store attribute before importing the module.

Changes: Elasticsearch credential test

Layer / File(s) Summary
Save package attribute before import
nodes/test/test_elasticsearch_credentials.py
The test captures the existing elasticsearch_store attribute, using None if it is absent, before the import.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Possibly related PRs

Suggested labels: module:nodes, tests

Suggested reviewers: stepmikhaylov

Merge Risk: Minimal · up to aa909

The test cleanup preserves package state correctly and is safe to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the test change: the Elasticsearch store test restores the package attribute that its import binds. The raw summary says the test now snapshots the existing elasticsearch_store attri…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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 names the test change: the Elasticsearch store test restores the package attribute that its import binds. The raw summary says the test now snapshots the existing elasticsearch_store attribute before the import and restores it afterward, so the title matches the main change. The title uses the conventional test(nodes): prefix and is 81 characters long, which is acceptable.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 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

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

@asclearuc asclearuc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks @dk-rocketride — a precise test-isolation fix: patch.dict(sys.modules, ...) restores the module table but not the package attribute the import binds, and monkeypatch.setattr(..., raising=False) restores that attribute, or deletes it when it was absent.

Approve

No inline comments. I checked that importing nodes.store_elasticsearch outside the patch.dict block adds no new import side effect: the package __init__ only imports IEndpoint, IGlobal and IInstance, which the two earlier tests in this file already import through _iglobal.

@dk-rocketride
dk-rocketride merged commit b7a9a96 into develop Nov 1, 2026
@dk-rocketride
dk-rocketride deleted the fix/es-test-restores-package-attr branch November 1, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:nodes Python pipeline nodes tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants