Skip to content

refactor(config): centralize env var parsing helpers#3453

Merged
mkoura merged 1 commit into
masterfrom
safe_env_reading
May 7, 2026
Merged

refactor(config): centralize env var parsing helpers#3453
mkoura merged 1 commit into
masterfrom
safe_env_reading

Conversation

@mkoura
Copy link
Copy Markdown
Collaborator

@mkoura mkoura commented May 7, 2026

Add helpers.get_env_int and helpers.get_env_path for consistent env var handling. get_env_int raises an informative ValueError on malformed input; get_env_path returns pl.Path | None.

Make CARDANO_NODE_SOCKET_PATH a required var with an explicit RuntimeError on missing value (was implicit KeyError). Drop redundant pl.Path(...) re-wraps at consumers now that BOOTSTRAP_DIR, SCHEDULING_LOG, and BLOCK_PRODUCTION_DB carry proper Path types.

The xdist scheduler keeps a local copy of the int helper to avoid importing the framework package from the pytest plugin.

Add `helpers.get_env_int` and `helpers.get_env_path` for consistent
env var handling. `get_env_int` raises an informative `ValueError` on
malformed input; `get_env_path` returns `pl.Path | None`.

Make `CARDANO_NODE_SOCKET_PATH` a required var with an explicit
`RuntimeError` on missing value (was implicit `KeyError`). Drop
redundant `pl.Path(...)` re-wraps at consumers now that
`BOOTSTRAP_DIR`, `SCHEDULING_LOG`, and `BLOCK_PRODUCTION_DB` carry
proper `Path` types.

The xdist scheduler keeps a local copy of the int helper to avoid
importing the framework package from the pytest plugin.
@mkoura mkoura requested review from Copilot and removed request for ArturWieczorek and saratomaz May 7, 2026 14:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR centralizes environment-variable parsing to reduce duplicated logic and make configuration handling more consistent across the framework, while also improving failure modes for missing/malformed values.

Changes:

  • Added helpers.get_env_int and helpers.get_env_path and migrated several env var reads to use them.
  • Made CARDANO_NODE_SOCKET_PATH explicitly required at configuration load time, raising a clearer RuntimeError when missing.
  • Updated consumers to treat BOOTSTRAP_DIR, SCHEDULING_LOG, and BLOCK_PRODUCTION_DB as pathlib.Path (or None) and removed redundant pl.Path(...) re-wrapping; kept a local int helper in the xdist scheduler plugin to avoid framework imports.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cardano_node_tests/utils/versions.py Uses centralized int env parsing for PROTOCOL_VERSION.
cardano_node_tests/utils/helpers.py Introduces get_env_int / get_env_path helpers for consistent env var parsing.
cardano_node_tests/utils/dbsync_service_manager.py Avoids redundant Path(...) wrapping for BOOTSTRAP_DIR usage.
cardano_node_tests/utils/configuration.py Centralizes env parsing, makes socket path required, and normalizes path-typed config values.
cardano_node_tests/utils/cluster_scripts.py Removes redundant Path(...) wrapping when consuming BOOTSTRAP_DIR.
cardano_node_tests/tests/tests_plutus_v3/test_mint_build.py Uses centralized int env parsing for UPGRADE_TESTS_STEP.
cardano_node_tests/tests/test_xdist_helper.py Uses centralized int env parsing for xdist worker count.
cardano_node_tests/tests/test_rollback.py Uses centralized int env parsing for ROLLBACK_NODES_OFFSET.
cardano_node_tests/tests/test_node_upgrade.py Uses centralized int env parsing for UPGRADE_TESTS_STEP.
cardano_node_tests/tests/test_blocks.py Uses centralized int env parsing for BLOCK_PRODUCTION_EPOCHS and tightens DB path assumption.
cardano_node_tests/tests/conftest.py Stops re-wrapping BOOTSTRAP_DIR and uses it as a Path.
cardano_node_tests/pytest_plugins/xdist_scheduler.py Adds local _get_env_int and uses it for CLUSTERS_COUNT parsing without framework imports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mkoura mkoura merged commit 393e50c into master May 7, 2026
7 checks passed
@mkoura mkoura deleted the safe_env_reading branch May 7, 2026 14: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.

2 participants