Add process tree depth control to nested multierror test

Another step toward having a complete test for #89.
Subactor breadth still seems to cause the most havoc and is why I've
kept that value to just 2 for now.
drop_event_clear
Tyler Goodlet 2019-11-24 19:22:01 -05:00
parent d2a01e8b81
commit 915bf17a9a
1 changed files with 47 additions and 25 deletions

View File

@ -261,13 +261,26 @@ async def test_some_cancels_all(num_actors_and_errs, start_method):
pytest.fail("Should have gotten a remote assertion error?") pytest.fail("Should have gotten a remote assertion error?")
async def spawn_and_error(num) -> None: async def spawn_and_error(breadth, depth) -> None:
name = tractor.current_actor().name name = tractor.current_actor().name
async with tractor.open_nursery() as nursery: async with tractor.open_nursery() as nursery:
for i in range(num): for i in range(breadth):
await nursery.run_in_actor( if depth > 0:
f'{name}_errorer_{i}', assert_err args = (
f'spawner_{i}_depth_{depth}',
spawn_and_error,
) )
kwargs = {
'breadth': breadth,
'depth': depth - 1,
}
else:
args = (
f'{name}_errorer_{i}',
assert_err,
)
kwargs = {}
await nursery.run_in_actor(*args, **kwargs)
@tractor_test @tractor_test
@ -276,25 +289,34 @@ async def test_nested_multierrors(loglevel, start_method):
This test goes only 2 nurseries deep but we should eventually have tests This test goes only 2 nurseries deep but we should eventually have tests
for arbitrary n-depth actor trees. for arbitrary n-depth actor trees.
""" """
if platform.system() == 'Windows': # XXX: forkserver can't seem to handle any more then 2 depth
# Windows CI seems to be partifcularly fragile on Python 3.8.. # process trees for whatever reason.
num_subactors = 2 # Any more process levels then this and we start getting pretty slow anyway
else: depth = 3
# XXX: any more then this and the forkserver will subactor_breadth = 2
# start bailing hard...gotta look into it
num_subactors = 4
with trio.fail_after(120):
try: try:
async with tractor.open_nursery() as nursery: async with tractor.open_nursery() as nursery:
for i in range(subactor_breadth):
for i in range(num_subactors):
await nursery.run_in_actor( await nursery.run_in_actor(
f'spawner_{i}', f'spawner_{i}',
spawn_and_error, spawn_and_error,
num=num_subactors, breadth=subactor_breadth,
depth=depth,
) )
except trio.MultiError as err: except trio.MultiError as err:
assert len(err.exceptions) == num_subactors assert len(err.exceptions) == subactor_breadth
for subexc in err.exceptions: for subexc in err.exceptions:
assert isinstance(subexc, tractor.RemoteActorError) assert isinstance(subexc, tractor.RemoteActorError)
if depth > 1 and subactor_breadth > 1:
# XXX not sure what's up with this..
if platform.system() == 'Windows':
assert (subexc.type is trio.MultiError) or (
subexc.type is tractor.RemoteActorError)
else:
assert subexc.type is trio.MultiError assert subexc.type is trio.MultiError
else:
assert (subexc.type is tractor.RemoteActorError) or (
subexc.type is trio.Cancelled)