|
23 | 23 | from xdist.remote import WorkerInfo |
24 | 24 |
|
25 | 25 |
|
26 | | -def parse_spec_config(config: pytest.Config) -> list[str]: |
| 26 | +def parse_tx_spec_config(config: pytest.Config) -> list[str]: |
27 | 27 | xspeclist = [] |
28 | 28 | tx: list[str] = config.getvalue("tx") |
29 | 29 | for xspec in tx: |
@@ -57,8 +57,17 @@ def __init__( |
57 | 57 | if self.testrunuid is None: |
58 | 58 | self.testrunuid = uuid.uuid4().hex |
59 | 59 | self.group = execnet.Group(execmodel="main_thread_only") |
| 60 | + for proxy_spec in self._getpxspecs(): |
| 61 | + # Proxy gateways do not run workers, and are meant to be passed with the `via` attribute |
| 62 | + # to additional gateways. |
| 63 | + # They are useful for running multiple workers on remote machines. |
| 64 | + if getattr(proxy_spec, "id", None) is None: |
| 65 | + raise pytest.UsageError( |
| 66 | + f"Proxy gateway {proxy_spec} must include an id" |
| 67 | + ) |
| 68 | + self.group.makegateway(proxy_spec) |
60 | 69 | if specs is None: |
61 | | - specs = self._getxspecs() |
| 70 | + specs = self._gettxspecs() |
62 | 71 | self.specs: list[execnet.XSpec] = [] |
63 | 72 | for spec in specs: |
64 | 73 | if not isinstance(spec, execnet.XSpec): |
@@ -107,8 +116,11 @@ def setup_node( |
107 | 116 | def teardown_nodes(self) -> None: |
108 | 117 | self.group.terminate(self.EXIT_TIMEOUT) |
109 | 118 |
|
110 | | - def _getxspecs(self) -> list[execnet.XSpec]: |
111 | | - return [execnet.XSpec(x) for x in parse_spec_config(self.config)] |
| 119 | + def _gettxspecs(self) -> list[execnet.XSpec]: |
| 120 | + return [execnet.XSpec(x) for x in parse_tx_spec_config(self.config)] |
| 121 | + |
| 122 | + def _getpxspecs(self) -> list[execnet.XSpec]: |
| 123 | + return [execnet.XSpec(x) for x in self.config.getoption("px")] |
112 | 124 |
|
113 | 125 | def _getrsyncdirs(self) -> list[Path]: |
114 | 126 | for spec in self.specs: |
|
0 commit comments