Conversation
091ce6f to
ca25ce6
Compare
ca25ce6 to
6cc08c4
Compare
6cc08c4 to
1beffaa
Compare
4bcfab8 to
e05187e
Compare
26a88cd to
7c346ca
Compare
7c346ca to
2c3f2ac
Compare
| assert ( | ||
| preshared_after != preshared_before | ||
| ), "Preshared key not changed on the nlx server" | ||
| preshared_after = inspect_preshared_key(nlx_conn) |
There was a problem hiding this comment.
This should be await'ed ..? Or no?
There was a problem hiding this comment.
looks like it should, but even before my changes it was not awaited, so idk how it worked 😄 will fix it
| except ProcessExecError: | ||
| log.warning( | ||
| "disable_path cleanup: INPUT rule for %s already removed", |
There was a problem hiding this comment.
Should we check for the ProcessExecError error message like we do in DockerProcess, in case it failed with for some other reason? Otherwise log or re-raise the Exception
| inspect = await self._execute.inspect() | ||
| await asyncio.sleep(0.01) | ||
| if inspect["ExitCode"] is None: | ||
| proc = subprocess.run( |
There was a problem hiding this comment.
Is subrocess.run() a blocking call?
| "[%s] Cleanup failed: %s", | ||
| while inspect["Pid"] == 0 and inspect["ExitCode"] is None: | ||
| inspect = await self._execute.inspect() | ||
| await asyncio.sleep(0.01) |
There was a problem hiding this comment.
I wonder if we can use await asyncio.wait_for() somehow to avoid the spin lock with the sleep()
| def _resolve_setup_params(request: pytest.FixtureRequest) -> List[SetupParameters]: | ||
| """Dynamically resolve available *_setup_params fixtures. | ||
|
|
||
| Tries alpha, beta, gamma in order. Stops at the first missing fixture. |
There was a problem hiding this comment.
Is there a case where we can expect only "alpha" and "gamma" to be defined?
There was a problem hiding this comment.
there usually is not, but you pin pointed an issue, fixed
6bb1383 to
0e4a66e
Compare
|
+1 |
0e4a66e to
e8e2694
Compare
Add helpers_fixtures.py with generic env/env_mesh fixtures that use dynamic setup parameter resolution via _resolve_setup_params(). Includes vpn_tags compositional fixture pattern and supporting utility changes to docker_process.py and linux_router.py.
Convert test_vpn.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_mesh_plus_vpn.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_pq.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_adapter.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
…es.py Convert test_connection_states.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_direct_feature.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
…t.py Convert test_dns_through_exit.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
…_event.py Convert test_fire_connecting_event.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
…rt.py Convert test_flame_graph_chart.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_mesh_firewall.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
…e.py Convert test_mesh_remove_node.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_meshnet_id.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_neptun.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_network_monitor.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
…kering.py Convert test_node_state_flickering.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_pinging.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_proxy.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_reconnections.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
Convert test_telio_tasks.py to use setup-phase env/env_mesh fixtures with compositional vpn_tags and autouse mutation fixtures instead of factory-pattern runtime setup.
inspect_preshared_key is an async function, but was called without await. This caused the calls to return coroutine objects instead of executing the function body, silently skipping the internal preshared key assertions and making the rekey comparison always pass vacuously.
- helpers_fixtures.py: Use continue instead of break in _resolve_setup_params() to allow non-consecutive node configurations (e.g., alpha+gamma without beta) - linux_router.py: Check e.stderr content in ProcessExecError handlers before swallowing iptables cleanup errors, re-raise unexpected errors to avoid silently hiding real failures - docker_process.py: Replace blocking subprocess.run() with async asyncio.create_subprocess_exec() to avoid blocking the event loop during exec cleanup - docker_process.py: Replace spin lock with asyncio.wait_for() using a 10-second timeout to prevent infinite spinning, and extract _wait_for_process_start() and _kill_exec_if_running() helper methods to consolidate duplicated cleanup logic
e8e2694 to
98d4a91
Compare
Problem
Nat-lab test files use a factory-pattern for environment setup where each test manually calls
setup_mesh_nodes()orsetup_environment()at runtime, managingAsyncExitStacklifecycle inline. This leads to:env_vpn_conntracked,env_pq_nlx_vpn,env_pq_nlx_vpn_rekey, etc.) that differ only in minor parameter mutationsSolution
Introduce a
helpers_fixtures.pymodule with two generic setup-phase fixtures —env_meshandenv— that handle all environment lifecycle in pytest's fixture phase. By moving setup into fixtures, environment provisioning and teardown time is no longer counted as part of the test's execution duration, giving more accurate test timing metrics. Key design decisions:_resolve_setup_params()usesrequest.getfixturevalue()to auto-detect whichalpha_setup_params,beta_setup_params,gamma_setup_paramsare parametrized on the test, eliminating the need for separate 1-node/2-node/3-node fixture variantsvpn_tagsfixture: A default fixture returning[]that tests override at class/module level to inject VPN server connections, replacing dedicated VPN-specific fixtures_mutate_pq_version,_mutate_conntracker) to apply parameter mutations, replacing 5 specialized environment fixtures with the genericenv/env+ compositionlinux_router.pywraps all iptables teardown commands intry/except ProcessExecErrorto prevent cascading failuresThis reduces the fixture count from 22 specialized fixtures to 2 generic ones (plus 1 kept specialized:
env_mesh_3node_ring_fwwhich requires pre-setup API manipulation). Each of the 19 converted test files gets its own commit for reviewability.☑️ Definition of Done checklist