Change to new context-cancelled msg contents: pikerd is canceller

master
Tyler Goodlet 2023-05-26 17:16:43 -04:00
parent 024cf8b8c2
commit 4f67ac0337
2 changed files with 19 additions and 8 deletions

View File

@ -103,6 +103,9 @@ async def _open_test_pikerd(
a different port then the default to allow testing alongside a different port then the default to allow testing alongside
a running stack. a running stack.
Calls `.service._actor_runtime.maybe_open_pikerd()``
to boot the root actor / tractor runtime.
''' '''
import random import random
from piker.service import maybe_open_pikerd from piker.service import maybe_open_pikerd

View File

@ -33,8 +33,8 @@ def test_runtime_boot(
): ):
''' '''
Verify we can boot the `pikerd` service stack using the Verify we can boot the `pikerd` service stack using the
`open_test_pikerd` fixture helper and that registry address details `open_test_pikerd()` fixture helper and that contact-registry
match up. address details match up.
''' '''
async def main(): async def main():
@ -55,6 +55,9 @@ def test_runtime_boot(
assert pikerd_portal.channel.raddr == daemon_addr assert pikerd_portal.channel.raddr == daemon_addr
assert pikerd_portal.channel.raddr == portal.channel.raddr assert pikerd_portal.channel.raddr == portal.channel.raddr
# no service tasks should be started
assert not services.service_tasks
trio.run(main) trio.run(main)
@ -121,8 +124,7 @@ def test_ensure_ems_in_paper_actors(
async def main(): async def main():
# type declares # type declares
book: OrderClient client: OrderClient
trades_stream: tractor.MsgStream
pps: dict[str, list[BrokerdPosition]] pps: dict[str, list[BrokerdPosition]]
accounts: list[str] accounts: list[str]
dialogs: dict[str, Status] dialogs: dict[str, Status]
@ -139,8 +141,8 @@ def test_ensure_ems_in_paper_actors(
mode='paper', mode='paper',
loglevel=loglevel, loglevel=loglevel,
) as ( ) as (
book, client,
trades_stream, _, # trades_stream: tractor.MsgStream
pps, pps,
accounts, accounts,
dialogs, dialogs,
@ -152,6 +154,9 @@ def test_ensure_ems_in_paper_actors(
assert not pps assert not pps
assert not dialogs assert not dialogs
assert not client._sent_orders
assert accounts
pikerd_subservices = ['emsd', 'samplerd'] pikerd_subservices = ['emsd', 'samplerd']
async with ( async with (
@ -169,10 +174,13 @@ def test_ensure_ems_in_paper_actors(
print('ALL SERVICES STARTED, terminating..') print('ALL SERVICES STARTED, terminating..')
await services.cancel_service('emsd') await services.cancel_service('emsd')
# ensure we receive a remote cancellation error caused by the
# pikerd root actor since we used the `.cancel_service()` API
# above B)
with pytest.raises( with pytest.raises(
tractor._exceptions.ContextCancelled, tractor._exceptions.ContextCancelled,
) as exc_info: ) as exc_info:
trio.run(main) trio.run(main)
cancel_msg: str = '_emsd_main()` was remotely cancelled by its caller' cancelled_msg: str = "was remotely cancelled by remote actor (\'pikerd\'"
assert cancel_msg in exc_info.value.args[0] assert cancelled_msg in exc_info.value.args[0]