Skip to content

MPT-19124 speed up tests#262

Merged
jentyk merged 2 commits intomainfrom
feat/MPT-19124
Mar 30, 2026
Merged

MPT-19124 speed up tests#262
jentyk merged 2 commits intomainfrom
feat/MPT-19124

Conversation

@jentyk
Copy link
Copy Markdown
Member

@jentyk jentyk commented Mar 30, 2026

Closes MPT-19124

  • Converted many pytest fixtures across the e2e test suite from function scope to session scope (fixtures now created once per test session and reused)
  • Scope changes applied across numerous conftest.py files under tests/e2e (including the top-level e2e conftest and multiple helpdesk, accounts, billing, catalog, commerce, notifications, audit, billing, and other module subdirectories)
  • Fixed pdf_fd fixture to use a context-managed yielding implementation (properly opening/closing the file handle while yielding the same file object)
  • Result: faster e2e test runs due to reduced fixture setup/teardown overhead

@jentyk jentyk requested a review from a team as a code owner March 30, 2026 14:13
@jentyk jentyk requested review from d3rky and robcsegal March 30, 2026 14:13
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: e8f2ab4e-453f-42c1-b16e-eddd9f25197c

📥 Commits

Reviewing files that changed from the base of the PR and between 08c3443 and d7bc467.

📒 Files selected for processing (1)
  • tests/e2e/conftest.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/e2e/conftest.py

📝 Walkthrough

Walkthrough

Pytest fixtures in E2E test configuration files were changed from function scope to session scope across the root E2E conftest and multiple helpdesk submodule conftests. One fixture (pdf_fd) now yields a context-managed file handle. No return values or fixture dependencies were otherwise modified.

Changes

Cohort / File(s) Summary
Root E2E Configuration
tests/e2e/conftest.py
Many fixtures (base_url, api_timeout, mpt_vendor, async_mpt_vendor, mpt_ops, async_mpt_ops, mpt_client, async_mpt_client, rp_logger, logger, project_root_path, pdf_fd, pdf_url, jpg_url, e2e_config, product_id, logo_fd, user_id, account_id, seller_id, buyer_id, buyer_account_id, licensee_id, authorization_id, price_list_id, user_group_id, commerce_product_id) changed from function scope to scope="session". pdf_fd now yields a context-managed file descriptor.
Helpdesk Cases
tests/e2e/helpdesk/cases/conftest.py
invalid_case_id changed to scope="session".
Helpdesk Channels
tests/e2e/helpdesk/channels/conftest.py
channel_id, invalid_channel_id changed to scope="session".
Helpdesk Chats
tests/e2e/helpdesk/chats/conftest.py, tests/e2e/helpdesk/chats/answers/conftest.py, tests/e2e/helpdesk/chats/answers/parameters/conftest.py, tests/e2e/helpdesk/chats/attachment/conftest.py, tests/e2e/helpdesk/chats/links/conftest.py, tests/e2e/helpdesk/chats/messages/conftest.py, tests/e2e/helpdesk/chats/participants/conftest.py
Chat-related fixtures (chat_id, invalid_chat_id, invalid_chat_answer_id, invalid_chat_answer_parameter_id, invalid_chat_attachment_id, invalid_chat_link_id, invalid_chat_message_id, invalid_chat_participant_id) changed to scope="session".
Helpdesk Forms & Parameters
tests/e2e/helpdesk/forms/conftest.py, tests/e2e/helpdesk/parameter_groups/conftest.py, tests/e2e/helpdesk/parameter_groups/parameters/conftest.py, tests/e2e/helpdesk/parameters/conftest.py
invalid_form_id, invalid_parameter_group_id, invalid_parameter_group_parameter_id, invalid_parameter_id changed to scope="session".
Helpdesk Queues
tests/e2e/helpdesk/queues/conftest.py
invalid_queue_id changed to scope="session".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains exactly one Jira issue key in the correct format (MPT-19124) at the beginning.
Test Coverage Required ✅ Passed PR modifies only test files within tests/ folder, specifically pytest fixture definitions in conftest.py files. No code files outside tests/ were modified.
Single Commit Required ✅ Passed The PR contains exactly one commit as indicated in the commit messages summary: test(e2e): fix pdf_fd fixture to properly manage file handle.

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


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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e/conftest.py`:
- Around line 83-87: The fixtures pdf_fd and logo_fd open files and return file
objects without closing them; change each fixture to open the file into a local
variable (e.g., fd = pathlib.Path.open(icon_path, "rb")), use yield fd instead
of return, and ensure deterministic cleanup by closing the file in a finally
block (or after the yield) so the file descriptor is closed when the fixture
teardown runs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 1ce1a4ef-535c-4d6b-9a30-490cb12de8dd

📥 Commits

Reviewing files that changed from the base of the PR and between a2a7921 and 08c3443.

📒 Files selected for processing (15)
  • tests/e2e/conftest.py
  • tests/e2e/helpdesk/cases/conftest.py
  • tests/e2e/helpdesk/channels/conftest.py
  • tests/e2e/helpdesk/chats/answers/conftest.py
  • tests/e2e/helpdesk/chats/answers/parameters/conftest.py
  • tests/e2e/helpdesk/chats/attachment/conftest.py
  • tests/e2e/helpdesk/chats/conftest.py
  • tests/e2e/helpdesk/chats/links/conftest.py
  • tests/e2e/helpdesk/chats/messages/conftest.py
  • tests/e2e/helpdesk/chats/participants/conftest.py
  • tests/e2e/helpdesk/forms/conftest.py
  • tests/e2e/helpdesk/parameter_groups/conftest.py
  • tests/e2e/helpdesk/parameter_groups/parameters/conftest.py
  • tests/e2e/helpdesk/parameters/conftest.py
  • tests/e2e/helpdesk/queues/conftest.py

@sonarqubecloud
Copy link
Copy Markdown

@jentyk jentyk merged commit bc30a22 into main Mar 30, 2026
4 checks passed
@jentyk jentyk deleted the feat/MPT-19124 branch March 30, 2026 14:36
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.

2 participants