Skip to content

Llt 7043 pytest fixtures for helpers#1714

Draft
gytsto wants to merge 12 commits intomainfrom
LLT-7043_pytest_fixtures_for_helpers
Draft

Llt 7043 pytest fixtures for helpers#1714
gytsto wants to merge 12 commits intomainfrom
LLT-7043_pytest_fixtures_for_helpers

Conversation

@gytsto
Copy link
Contributor

@gytsto gytsto commented Mar 18, 2026

Problem

--describe problem being solved--

Solution

--describe selected solution--

☑️ Definition of Done checklist

  • Commit history is clean (requirements)
  • README.md is updated
  • Functionality is covered by unit or integration tests

@gytsto gytsto requested a review from a team as a code owner March 18, 2026 09:08
@gytsto gytsto force-pushed the LLT-7043_pytest_fixtures_for_helpers branch from 091ce6f to ca25ce6 Compare March 18, 2026 09:43
@gytsto gytsto force-pushed the LLT-7043_pytest_fixtures_for_helpers branch from ca25ce6 to 6cc08c4 Compare March 18, 2026 11:01
@gytsto gytsto force-pushed the LLT-7043_pytest_fixtures_for_helpers branch from 6cc08c4 to 1beffaa Compare March 18, 2026 11:29
gytsto added 8 commits March 19, 2026 09:53
…e phase

Replace factory-pattern fixture calls (setup_mesh_nodes_factory,
setup_environment_factory, setup_connections_factory) with dedicated
@pytest_asyncio.fixture functions that perform all environment setup
during pytest's fixture setup phase, before test bodies execute.

Tests now receive ready-to-use objects (nodes, clients, connections)
as fixture parameters instead of calling factory functions at runtime.

Changes:
- helpers_fixtures.py: Add setup-phase environment fixtures
  (mesh_vpn_environment, vpn_then_mesh_environment,
  mesh_vpn_3node_environment, dual_vpn_environment,
  single_vpn_environment, vpn_reconnect_environment,
  firewall_blacklist_environment) with convenience extractor fixtures
  using standardized {prefix}_{role}_{component} naming. Remove unused
  IPStack import. Retain factory fixtures for backward compatibility.
- test_mesh_plus_vpn.py: Convert all 5 tests from factory calls to
  setup-phase fixtures.
- test_vpn.py: Convert all 7 tests from factory calls to setup-phase
  fixtures.
- test_proxy.py: Update fixture references to match unified naming.
…rdown

- test_proxy: use exit_stack.enter_async_context() instead of await for
  block_udp_port() which is an @asynccontextmanager, fixing TypeError
- linux_router: wrap disable_path() teardown iptables delete commands in
  try/except ProcessExecError to prevent cascading failures when rules
  are already removed during exit stack LIFO cleanup
…nused params with _

- Strip '# pylint: disable=unused-argument' comments from all 15 test files
- For params actually used in the function body: just remove the comment
- For unused environment fixtures: prefix with _ (e.g. _single_mesh_environment)
- For unused parametrized setup_params (alpha/beta/gamma_setup_params): keep
  original names since they must match fixture names in helpers_fixtures.py,
  and retain pylint: disable=unused-argument inline comments
- Prefix unused exit_stack fixture params with _ in test_pq.py
…cessor fixtures

- Remove 21 simple accessor fixtures from helpers_fixtures.py that just
  extracted nodes/clients/connections from environment objects
- Keep 3 special fixtures (vpn_server_connection, dual_vpn_server_connections,
  single_vpn_server_connection) that do actual setup work
- Refactor all test functions to receive the environment fixture directly
  and destructure nodes/clients/connections at the top of the test body
- Remove unused setup_params from test function signatures where they
  are not read in the test body (parametrize decorators unchanged)
…xtures

- Add 5 new environment fixtures to helpers_fixtures.py:
  pq_vpn_environment, pq_vpn_rekey_environment,
  pq_vpn_handshake_environment, pq_vpn_plain_environment,
  adapter_mesh_environment
- Convert all 7 tests in test_pq.py from factory pattern to fixtures
- Convert 3 of 4 tests in test_adapter.py from factory pattern to fixtures
- Keep test_adapter_service_loading with factory pattern (interleaved setup)
- Rename inconsistent parametrize names (setup, setup_params) to
  alpha_setup_params for fixture chain compatibility
- Remove setup_environment_factory if no longer used
… test_neptun

- Replace single_alpha_client with single_environment.clients[0]
- Replace mesh_alpha_client with mesh_2node_environment.clients[0]
- Fixes CI failure from removed accessor fixtures
@gytsto gytsto force-pushed the LLT-7043_pytest_fixtures_for_helpers branch from 4bcfab8 to e05187e Compare March 19, 2026 07:53
@gytsto gytsto marked this pull request as draft March 19, 2026 08:23
gytsto added 3 commits March 19, 2026 13:00
- Rename all environment fixtures to use env_ prefix convention:
  env_{topology}_{vpn}_{modifier}
- Delete adapter_mesh_environment (exact duplicate of single_mesh_environment)
- Rename 15 environment fixtures for consistency:
  single_environment → env_1node
  single_mesh_environment → env_mesh_1node
  mesh_2node_environment → env_mesh_2node
  single_vpn_environment → env_vpn_1node
  vpn_environment → env_vpn_conntracked
  dual_vpn_environment → env_vpn_dual
  firewall_blacklist_environment → env_vpn_2node_no_mesh
  mesh_vpn_environment → env_mesh_vpn_2node
  vpn_then_mesh_environment → env_vpn_then_mesh_2node
  mesh_vpn_3node_environment → env_mesh_vpn_3node
  mesh_remove_node_environment → env_mesh_3node_ring_fw
  pq_vpn_environment → env_pq_nlx_vpn
  pq_vpn_rekey_environment → env_pq_nlx_vpn_rekey
  pq_vpn_handshake_environment → env_pq_nlx_vpn_handshake
  pq_vpn_plain_environment → env_nlx_vpn
- Update all 15 consumer test files
- Reduce fixture count from 22 to 21
Introduce a `vpn_tags` fixture that defaults to `[]` and can be
overridden at module or class level to inject VPN servers into
generic environment fixtures. This eliminates the need for
separate VPN-specific fixtures.

Changes:
- Add `vpn_tags` default fixture returning `[]`
- Modify `env_mesh_1node`, `env_mesh_2node`, `env_1node` to accept
  `vpn_tags` and pass `vpn=vpn_tags or None`
- Add new fixtures: `env_mesh_3node`, `env_2node`
- Delete 6 redundant VPN-specific fixtures: `env_mesh_vpn_2node`,
  `env_mesh_vpn_3node`, `env_vpn_1node`, `env_vpn_dual`,
  `env_vpn_2node_no_mesh`, `env_nlx_vpn`
- Migrate 5 test files to use vpn_tags overrides
- Reduce total fixture count from 21 to 17
Replace 5 node-count-specific environment fixtures (env_mesh_1node,
env_mesh_2node, env_mesh_3node, env_1node, env_2node) with 2 generic
fixtures that auto-detect available setup params:

- env_mesh: calls setup_mesh_nodes with params resolved via
  _resolve_setup_params() using request.getfixturevalue()
- env: calls setup_environment with the same pattern

The _resolve_setup_params() helper tries alpha_setup_params,
beta_setup_params, gamma_setup_params in order, stopping at the
first FixtureLookupError. Tests keep their existing separate
@pytest.mark.parametrize decorators — no additional boilerplate needed.

Changes:
- Add _resolve_setup_params() helper with auto-detection
- Add env_mesh and env generic fixtures
- Delete 5 node-count-specific fixtures
- Migrate 15 consumer test files
- Reduce fixture count from 17 to 13
… pattern

Replace 5 specialized environment fixtures with the generic env/env_mesh
fixtures combined with compositional fixtures (vpn_tags overrides and
autouse mutation fixtures) in the consuming test files:

- env_vpn_conntracked → env + conntracker autouse in TestVpnConnection
- env_vpn_then_mesh_2node → env + existing vpn_tags override
- env_pq_nlx_vpn → env + PQ version autouse in TestPqVpnConnection
- env_pq_nlx_vpn_rekey → env + PQ rekey autouse in TestPqVpnRekey
- env_pq_nlx_vpn_handshake → env + PQ handshake autouse in TestPqVpnHandshake

Only env_mesh_3node_ring_fw remains as it requires pre-setup API access.
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