Rename fixture `arb_addr` -> `reg_addr` and set the session value globally as `._root._default_lo_addrs`
parent
a8c0fc3b79
commit
2e5ba84270
|
@ -93,12 +93,18 @@ _reg_addr: tuple[str, int] = (
|
||||||
'127.0.0.1',
|
'127.0.0.1',
|
||||||
random.randint(1000, 9999),
|
random.randint(1000, 9999),
|
||||||
)
|
)
|
||||||
_arb_addr = _reg_addr
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def arb_addr():
|
def reg_addr() -> tuple[str, int]:
|
||||||
return _arb_addr
|
|
||||||
|
# globally override the runtime to the per-test-session-dynamic
|
||||||
|
# addr so that all tests never conflict with any other actor
|
||||||
|
# tree using the default.
|
||||||
|
from tractor import _root
|
||||||
|
_root._default_lo_addrs = [_reg_addr]
|
||||||
|
|
||||||
|
return _reg_addr
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
|
@ -140,30 +146,35 @@ def sig_prog(proc, sig):
|
||||||
def daemon(
|
def daemon(
|
||||||
loglevel: str,
|
loglevel: str,
|
||||||
testdir,
|
testdir,
|
||||||
arb_addr: tuple[str, int],
|
reg_addr: tuple[str, int],
|
||||||
):
|
):
|
||||||
'''
|
'''
|
||||||
Run a daemon actor as a "remote arbiter".
|
Run a daemon root actor as a separate actor-process tree and
|
||||||
|
"remote registrar" for discovery-protocol related tests.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
if loglevel in ('trace', 'debug'):
|
if loglevel in ('trace', 'debug'):
|
||||||
# too much logging will lock up the subproc (smh)
|
# XXX: too much logging will lock up the subproc (smh)
|
||||||
loglevel = 'info'
|
loglevel: str = 'info'
|
||||||
|
|
||||||
cmdargs = [
|
code: str = (
|
||||||
sys.executable, '-c',
|
"import tractor; "
|
||||||
"import tractor; tractor.run_daemon([], registry_addr={}, loglevel={})"
|
"tractor.run_daemon([], registry_addrs={reg_addrs}, loglevel={ll})"
|
||||||
.format(
|
).format(
|
||||||
arb_addr,
|
reg_addrs=str([reg_addr]),
|
||||||
"'{}'".format(loglevel) if loglevel else None)
|
ll="'{}'".format(loglevel) if loglevel else None,
|
||||||
|
)
|
||||||
|
cmd: list[str] = [
|
||||||
|
sys.executable,
|
||||||
|
'-c', code,
|
||||||
]
|
]
|
||||||
kwargs = dict()
|
kwargs = {}
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
# without this, tests hang on windows forever
|
# without this, tests hang on windows forever
|
||||||
kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP
|
kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP
|
||||||
|
|
||||||
proc = testdir.popen(
|
proc = testdir.popen(
|
||||||
cmdargs,
|
cmd,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
|
|
|
@ -220,6 +220,10 @@ async def hard_kill(
|
||||||
# whilst also hacking on it XD
|
# whilst also hacking on it XD
|
||||||
# terminate_after: int = 99999,
|
# terminate_after: int = 99999,
|
||||||
|
|
||||||
|
# NOTE: for mucking with `.pause()`-ing inside the runtime
|
||||||
|
# whilst also hacking on it XD
|
||||||
|
# terminate_after: int = 99999,
|
||||||
|
|
||||||
) -> None:
|
) -> None:
|
||||||
'''
|
'''
|
||||||
Un-gracefully terminate an OS level `trio.Process` after timeout.
|
Un-gracefully terminate an OS level `trio.Process` after timeout.
|
||||||
|
|
Loading…
Reference in New Issue