From 8632b38203fb9c1748720d260105f9d4e7943712 Mon Sep 17 00:00:00 2001 From: Alon Livne <2005alonlivne@gmail.com> Date: Sun, 12 Jan 2025 21:30:43 +0200 Subject: [PATCH] add tests for proxy gateways The test `test_proxy_gateway_setup_nodes` makes sure that 2 execnet gateways are created, but only one node is allocated. The test `test_proxy_gateway` tries to run a test on a proxy. --- testing/test_workermanage.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/testing/test_workermanage.py b/testing/test_workermanage.py index 491d042..ee4c62a 100644 --- a/testing/test_workermanage.py +++ b/testing/test_workermanage.py @@ -368,6 +368,35 @@ class TestNodeManager: (rep,) = reprec.getreports("pytest_runtest_logreport") assert rep.passed + def test_proxy_gateway_setup_nodes(self, pytester: pytest.Pytester) -> None: + nodemanager = NodeManager( + pytester.parseconfig( + "--px", "popen//id=my_proxy", "--tx", "popen//via=my_proxy" + ) + ) + nodes = nodemanager.setup_nodes(None) # type: ignore[arg-type] + + # Proxy gateways are considered as an execnet gateway + assert len(nodemanager.group) == 2 + + # Proxy gateways do not run workers + assert len(nodes) == 1 + + def test_proxy_gateway(self, pytester: pytest.Pytester) -> None: + pytester.makepyfile( + __init__="", + test_x=""" + def test_one(): + pass + """, + ) + reprec = pytester.inline_run( + "-d", "--px", "popen//id=my_proxy", "--tx", "popen//via=my_proxy" + ) + rep = reprec.getreports("pytest_runtest_logreport") + assert rep[1].passed + + class MyWarning(UserWarning): pass