forked from goodboy/tractor
1
0
Fork 0

Adjust multi-daemon test to be more deterministic

eg_backup
Tyler Goodlet 2022-10-14 15:40:48 -04:00
parent 347591c348
commit c0dd5d7ffc
2 changed files with 55 additions and 28 deletions

View File

@ -27,6 +27,17 @@ async def main():
# retreive results # retreive results
async with p0.open_stream_from(breakpoint_forever) as stream: async with p0.open_stream_from(breakpoint_forever) as stream:
# triggers the first name error
try:
await p1.run(name_error)
except tractor.RemoteActorError as rae:
assert rae.type is NameError
async for i in stream:
# a second time try the failing subactor and this tie
# let error propagate up to the parent/nursery.
await p1.run(name_error) await p1.run(name_error)

View File

@ -582,14 +582,14 @@ def test_multi_daemon_subactors(
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
# there is a race for which subactor will acquire # there can be a race for which subactor will acquire
# the root's tty lock first # the root's tty lock first so anticipate either crash
# message on the first entry.
before = str(child.before.decode())
bp_forever_msg = "Attaching pdb to actor: ('bp_forever'" bp_forever_msg = "Attaching pdb to actor: ('bp_forever'"
name_error_msg = "NameError" name_error_msg = "NameError: name 'doggypants' is not defined"
before = str(child.before.decode())
if bp_forever_msg in before: if bp_forever_msg in before:
next_msg = name_error_msg next_msg = name_error_msg
@ -611,9 +611,7 @@ def test_multi_daemon_subactors(
child.sendline('c') child.sendline('c')
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode()) assert_before(child, [next_msg])
assert next_msg in before
# XXX: hooray the root clobbering the child here was fixed! # XXX: hooray the root clobbering the child here was fixed!
# IMO, this demonstrates the true power of SC system design. # IMO, this demonstrates the true power of SC system design.
@ -632,31 +630,49 @@ def test_multi_daemon_subactors(
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
# wait for final error in root # expect another breakpoint actor entry
while True:
child.sendline('c') child.sendline('c')
child.expect(r"\(Pdb\+\+\)") child.expect(r"\(Pdb\+\+\)")
before = str(child.before.decode()) assert_before(child, [bp_forever_msg])
try:
# root error should be packed as remote error
assert "_exceptions.RemoteActorError: ('name_error'" in before
break
except AssertionError:
assert bp_forever_msg in before
if ctlc: if ctlc:
do_ctlc(child) do_ctlc(child)
# should crash with the 2nd name error (simulates
# a retry) and then the root eventually (boxed) errors
# after 1 or more further bp actor entries.
child.sendline('c')
child.expect(r"\(Pdb\+\+\)")
assert_before(child, [name_error_msg])
# wait for final error in root
# where it crashs with boxed error
while True:
try: try:
child.sendline('c') child.sendline('c')
child.expect(pexpect.EOF) child.expect(r"\(Pdb\+\+\)")
assert_before(
child,
[bp_forever_msg]
)
except AssertionError:
break
except TIMEOUT: # child.sendline('c')
# Failed to exit using continue..? # assert_before(
child.sendline('q')
# child.sendline('c')
assert_before(
child,
[
# boxed error raised in root task
"Attaching to pdb in crashed actor: ('root'",
"_exceptions.RemoteActorError: ('name_error'",
]
)
child.sendline('c')
child.expect(pexpect.EOF) child.expect(pexpect.EOF)