Skip to content

Add ZeroMQ pytest fixtures to start the broker service inside pytest - #7464

Merged
agoscinski merged 5 commits into
aiidateam:mainfrom
agoscinski:feat/zmq-fixtures
Jul 22, 2026
Merged

Add ZeroMQ pytest fixtures to start the broker service inside pytest#7464
agoscinski merged 5 commits into
aiidateam:mainfrom
agoscinski:feat/zmq-fixtures

Conversation

@agoscinski

@agoscinski agoscinski commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

The main motivation of these changes is to automatically start the ZMQ broker for plugin developers that use aiida_profile with the zeromq broker backend. For other profiles the fixture run_broker_service_for_profile can be used to start the broker for it. I tested the fixture on the aiida-quantumespresso nightly tests (see PR aiidateam/aiida-quantumespresso#1275)

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

ZeroMQ broker lifecycle

Layer / File(s) Summary
Broker configuration and initialization
src/aiida/brokers/zeromq/broker.py, src/aiida/tools/pytest_fixtures/configuration.py, tests/tools/pytest_fixtures/test_configuration.py
ZeromqBroker accepts profiles with supervised_by_daemon=False, profile factories select backend-specific defaults, and unsupported backends raise ValueError.
Shared pytest broker service
src/aiida/tools/pytest_fixtures/broker.py, src/aiida/tools/pytest_fixtures/__init__.py
Adds exported session fixtures that start, monitor, yield, and stop ZeroMQ broker services.
Test fixture lifecycle wiring
tests/conftest.py, tests/brokers/test_zeromq_broker.py, tests/brokers/test_zeromq_communicator.py
Moves broker startup to shared fixtures, updates broker and communicator tests, and removes obsolete subprocess management.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant pytest as pytest session
  participant broker_fixture as broker service fixture
  participant ZeromqBroker
  participant subprocess as broker subprocess
  pytest->>broker_fixture: request session broker service
  broker_fixture->>ZeromqBroker: construct from profile
  broker_fixture->>subprocess: start broker service
  subprocess-->>broker_fixture: become reachable
  broker_fixture-->>pytest: yield session control
  pytest->>subprocess: send SIGINT
  subprocess-->>pytest: shut down
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
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.
Title check ✅ Passed The title clearly matches the main change: new pytest fixtures to start the ZeroMQ broker service during tests.
Description check ✅ Passed The description is related to the changeset and correctly explains the intent to auto-start the ZMQ broker in pytest.

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.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.70175% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.63%. Comparing base (4c81e9d) to head (fcb2135).

Files with missing lines Patch % Lines
src/aiida/tools/pytest_fixtures/broker.py 78.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7464      +/-   ##
==========================================
- Coverage   80.63%   80.63%   -0.00%     
==========================================
  Files         580      581       +1     
  Lines       46754    46806      +52     
==========================================
+ Hits        37697    37737      +40     
- Misses       9057     9069      +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@agoscinski
agoscinski marked this pull request as ready for review July 21, 2026 05:27

@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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/aiida/tools/pytest_fixtures/broker.py`:
- Around line 1-3: Add the repository’s standard copyright header at the
beginning of the new broker fixture source file, before the module docstring.
Copy the exact header format and notice from an existing Python source file,
leaving the existing module contents unchanged.
- Around line 21-40: Update the aiida_broker_service docstring and usage example
to describe passing a Profile, matching run_service’s profile parameter and its
construction of ZeromqBroker(profile). Remove references to supplying an
existing ZeromqBroker while preserving the documented timeout and
context-manager behavior.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6da108c4-0e14-44f8-b66f-343e46cba3cd

📥 Commits

Reviewing files that changed from the base of the PR and between 9bffcdb and 7a2dde3.

📒 Files selected for processing (7)
  • src/aiida/brokers/zeromq/broker.py
  • src/aiida/tools/pytest_fixtures/__init__.py
  • src/aiida/tools/pytest_fixtures/broker.py
  • src/aiida/tools/pytest_fixtures/configuration.py
  • tests/brokers/test_zeromq_broker.py
  • tests/brokers/test_zeromq_communicator.py
  • tests/conftest.py

Comment thread src/aiida/tools/pytest_fixtures/broker.py
Comment thread src/aiida/tools/pytest_fixtures/broker.py Outdated
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.

@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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/tools/pytest_fixtures/test_configuration.py (1)

64-64: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Escape the regex metacharacter in the match string.

The match parameter in pytest.raises accepts a regular expression. The . in core.unsupported is a regex metacharacter and should be escaped to prevent unintended matches (e.g., coreXunsupported).

🛠️ Proposed fix
-    with pytest.raises(ValueError, match='Unsupported broker backend: core.unsupported'):
+    with pytest.raises(ValueError, match=r'Unsupported broker backend: core\.unsupported'):
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tools/pytest_fixtures/test_configuration.py` at line 64, Escape the dot
in the pytest.raises match expression for the unsupported backend assertion so
it matches the literal backend name rather than any character. Update only the
match string in this test while preserving the existing ValueError expectation.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/aiida/tools/pytest_fixtures/__init__.py`:
- Line 6: The imported aiida_broker fixture is missing from the shared broker
module, while duplicate local implementations exist in both broker test files.
Add the session-scoped aiida_broker fixture to broker.py, keeping the existing
package import in src/aiida/tools/pytest_fixtures/__init__.py; remove the
duplicated fixture definitions from tests/brokers/test_zeromq_broker.py lines
25-36 and tests/brokers/test_zeromq_communicator.py lines 24-35.

In `@tests/brokers/test_zeromq_broker.py`:
- Around line 185-195: Extend test_get_communicator_and_close after the
cached-instance assertions to invoke the broker’s close behavior, preferably
through aiida_broker.close(), and assert the communicator is closed afterward.
Preserve the existing checks that get_communicator returns a cached, initially
open instance.

---

Nitpick comments:
In `@tests/tools/pytest_fixtures/test_configuration.py`:
- Line 64: Escape the dot in the pytest.raises match expression for the
unsupported backend assertion so it matches the literal backend name rather than
any character. Update only the match string in this test while preserving the
existing ValueError expectation.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f6905a26-f087-4623-b086-8cae068d6589

📥 Commits

Reviewing files that changed from the base of the PR and between 1d49231 and b318e1f.

📒 Files selected for processing (8)
  • src/aiida/brokers/zeromq/broker.py
  • src/aiida/tools/pytest_fixtures/__init__.py
  • src/aiida/tools/pytest_fixtures/broker.py
  • src/aiida/tools/pytest_fixtures/configuration.py
  • tests/brokers/test_zeromq_broker.py
  • tests/brokers/test_zeromq_communicator.py
  • tests/conftest.py
  • tests/tools/pytest_fixtures/test_configuration.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/aiida/brokers/zeromq/broker.py
  • tests/conftest.py

Comment thread src/aiida/tools/pytest_fixtures/__init__.py Outdated
Comment thread tests/brokers/test_zeromq_broker.py Outdated
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Rename the test and its docstring to match what it actually
covers.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Rename the test and its docstring to match what it actually
covers.

@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)
tests/tools/pytest_fixtures/test_configuration.py (1)

64-64: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Escape regex metacharacters in pytest.raises match.

The match argument in pytest.raises is evaluated as a regular expression. The period . acts as a wildcard metacharacter. Using a raw string and escaping it will ensure an exact match and resolve the static analysis warning.

♻️ Proposed refactor
-    with pytest.raises(ValueError, match='Unsupported broker backend: core.unsupported'):
+    with pytest.raises(ValueError, match=r'Unsupported broker backend: core\.unsupported'):
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/tools/pytest_fixtures/test_configuration.py` at line 64, Update the
pytest.raises assertion in the configuration test to use a raw regex string and
escape the period in “core.unsupported,” ensuring the match is exact rather than
treating the period as a wildcard.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/tools/pytest_fixtures/test_configuration.py`:
- Line 64: Update the pytest.raises assertion in the configuration test to use a
raw regex string and escape the period in “core.unsupported,” ensuring the match
is exact rather than treating the period as a wildcard.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 236de145-47c2-43e7-ae47-e2fab55662af

📥 Commits

Reviewing files that changed from the base of the PR and between b318e1f and 0c4138b.

📒 Files selected for processing (8)
  • src/aiida/brokers/zeromq/broker.py
  • src/aiida/tools/pytest_fixtures/__init__.py
  • src/aiida/tools/pytest_fixtures/broker.py
  • src/aiida/tools/pytest_fixtures/configuration.py
  • tests/brokers/test_zeromq_broker.py
  • tests/brokers/test_zeromq_communicator.py
  • tests/conftest.py
  • tests/tools/pytest_fixtures/test_configuration.py
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/aiida/tools/pytest_fixtures/init.py
  • src/aiida/tools/pytest_fixtures/configuration.py
  • src/aiida/brokers/zeromq/broker.py
  • tests/brokers/test_zeromq_communicator.py
  • tests/brokers/test_zeromq_broker.py
  • tests/conftest.py

agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Rename the test and its docstring to match what it actually
covers.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 21, 2026
Rename the test and its docstring to match what it actually
covers.
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
Rename the test and its docstring to match what it actually
covers.
@agoscinski

Copy link
Copy Markdown
Collaborator Author

CI failure is due to flaky test

___________ test_calc_job_monitors_process_poll_interval_integrated ____________
[gw0] linux -- Python 3.10.20 /home/runner/work/aiida-core/aiida-core/.venv/bin/python3
tests/engine/processes/calcjobs/test_monitors.py:208: in test_calc_job_monitors_process_poll_interval_integrated
    assert len(logs) == 1
E   assert 0 == 1
E    +  where 0 = len([])

@agoscinski
agoscinski merged commit 88ccac9 into aiidateam:main Jul 22, 2026
18 of 19 checks passed
agoscinski added a commit that referenced this pull request Jul 22, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit that referenced this pull request Jul 22, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit that referenced this pull request Jul 22, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit that referenced this pull request Jul 22, 2026
The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
@agoscinski
agoscinski deleted the feat/zmq-fixtures branch July 22, 2026 06:25
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
Rename the test and its docstring to match what it actually
covers.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
The `ZeromqBroker` constructor previously raised a `ConfigurationError`
whenever `supervised_by_daemon` was false, on the grounds that the
location of the service state files would be unknown. That reasoning
does not hold: the service directory and log file are derived from the
profile configuration (`Config.filepaths`) and are therefore known
regardless of who supervises the service lifecycle. The
`supervised_by_daemon` flag only decides *who* starts and stops the
service, not *where* it writes its files.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
Add a test asserting that `aiida_profile_factory` raises for a broker
backend that has no default configuration.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
Add reusable pytest fixtures that run the ZeroMQ broker service for the
session fixture `aiida_profile`, so the broker is available to runners without
relying on the daemon to launch it:

- `run_aiida_broker_service_for_profile`: returns a context manager that
  starts a ZeroMQ broker service subprocess for a given profile and stops
  it (and cleans up its service directory) on exit.
- `run_aiida_broker_service`: autouse fixture that runs the service for the
  loaded `aiida_profile` for the whole session when its broker is ZeroMQ,
  and is a no-op for other backends (RabbitMQ, none) so it does not
  interfere with them.

Remove the now-unused `_run_zeromq_broker_server` helper and the
`zeromq_broker` fixture from `tests/conftest.py`. The session
`aiida_profile` fixture no longer starts the broker service itself, as
that is now handled by the autouse `run_aiida_broker_service` fixture.

Update the ZeroMQ broker and communicator tests to obtain the broker
from the session aiida profile instead of the temporary profile through
the `zeromq_broker_with_server` fixture. The tests now do only run when
the the session scoped aiida profile is used with the `core.zeromq`
broker backend.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
…ateam#7464)

The `_patch_zmq_broker_service_filepaths` helper in `tests/conftest.py` had
a single remaining caller: the `zeromq_broker` fixture in
`tests/brokers/test_zeromq_broker.py`. Inline its logic into that fixture
and remove the shared helper, along with the now-unused `patch` and
`contextmanager` imports, from `conftest.py`.
agoscinski added a commit to agoscinski/aiida-core that referenced this pull request Jul 31, 2026
Rename the test and its docstring to match what it actually
covers.
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