Skip to content

Conversation

@goodboy
Copy link
Owner

@goodboy goodboy commented Jul 11, 2025

Follow up to #375 adding,

  • multi-IPC transport parametrization controls to the test harness
    via a new --tpt-proto arg

  • a first draft micro-suite of unit-tests for the new
    tractor.ipc._server subsys APIs

  • pluginize-ation of various useful (and general) fixtures and CLI
    flags for consumption in dependent projects which are built on
    tractor as a runtime, previously these only were found in
    specific conftest.py files but now can be included via,

    pytest_plugins: tuple[str] = (
        "tractor._testing.pytest",
    )
  • any other make CI green.


Follow-through from #375

  • (fecbba7) support for multi-tpt via pytest flags
  • a couple test suite(s) of tests to audit .ipc._server
  • (95f3abc) the new .ipc._server subsys in unit-style-isolation,
    • server side only to ensure APIs and sin-actor-runtime operation.

Still Todo before landing


Follow-up (if not landed here)

goodboy added 12 commits July 13, 2025 15:26
Such that we can run (opting-in) tests on both TCP and UDS backends and
ensure the `reg_addr` fixture and various timeouts are adjusted
accordingly.

Impl deats,
- add a new `tpc_proto` CLI option and fixture to allow choosing which
  "transport protocol" will be used in the test suites (either globally
  or contextually).
- rm `_reg_addr` instead opting for a `_rando_port` which will only be
  used for `reg_addr`s which are net-tpt-protos.
- rejig `reg_addr` fixture to set a ideally session-unique `testrun_reg_addr`
  based on the `tpt_proto` setting making appropriate calls to `._addr`
  APIs as needed.
- refine `daemon` fixture a bit with typing, `tpt_proto` timings, and
  stderr capture.
- in `test_discovery` do a ton of type-annots, add `debug_mode` fixture
  opt ins, augment `spawn_and_check_registry()` with `psutil.Process`
  passing for introspection (when things go wrong..).
Via a new accumulative `--tpt-proto` arg you can select which
`tpt_protos: list[str]`-fixture protocol keys will be delivered to
opting in tests!

B)

Also includes,
- CLI quote handling/stripping.
- default of 'tcp'.
- only support one selection per session at the moment (until we figure
  out how we want to support multiples, either simultaneously or
  sequentially).
- draft a (masked) dynamic-`metafunc` parametrization in the
  `pytest_generate_tests()` hook.
- first proven and working use in the `test_advanced_faults`-suite (and
  thus its underlying
  `examples/advanced_faults/ipc_failure_during_stream.py` script)!
 |_ actually needed this to prove that the suite only has 2 failures on
    'uds' seemingly due to low-level `trio` error semantics translation
    differences to do with with calling `socket.close()`..

On a very nearly related topic,
- draft an (also commented out) `set_script_runtime_args()` fixture idea
  for a std way of `partial`-ling in runtime args to `examples/`
  scripts-as-modules defining a `main()` which would proxy to
  `tractor.open_nursery()`.
In `tests/test_advanced_faults.py` that is.
Since instead of zero-responses like we'd expect from a network-socket
we actually can get a few differences from the OS when "everything IPC
is known"

XD

Namely it's about underlying `trio` exceptions versus how we wrap them
and how we expect to box them. A `TransportClosed` boxing improvement
is coming in follow up btw to make this all work!

B)
Such that the global test-session always (and only) runs against the CLI
specified `--tpt-proto=` transport protocol.
Namely while what I was actually trying to solve was why
`TransportClosed` was getting raised from `Portal.cancel_actor()` but
still useful edge case auditing either way. Also opts into the
`debug_mode` fixture with apprope timeout adjustment B)
For now it just boots a server, parametrized over all tpt-protos, sin
any actor runtime bootup. Obvi the future todo is ensuring it all works
with a client connecting via the equivalent lowlevel
`.ipc._chan._connect_chan()` API(s).
Namely any CLI driven runtime-config fixtures such as,

- `--spawn-backend` and `start_method`,
- `--tpdb` and `debug_mode`,
- `--tpt-proto` and `tpt_protos`/`tpt_proto`,
- `reg_addr` as driven by the above.

This moves all fixtures and necessary hook funcs (CLI parsing,
configuring and test-gen) to the `._testing.pytest` module and thus
allows any dependent project to leverage these fixtures in their own
test suites after pointing to that plugin mod using,

```python
    # conftest.py
    pytest_plugins: tuple[str] = (
        "tractor._testing.pytest",
    )
```

Also, add a new `._testing.addr` helper mod which now contains
a factored `get_rando_addr()` helper for creating test-sesh unique
tpt-specific registry (or other) IPC endpoint addrs.
We already have the `.ipc` sub-pkg name so it seems a bit
redundant/noisy for a namespace path Bp

Leave an alias for the `Server` rn since it's already used in a few
other internal mods.. will likely rename later if everyone is cool with
it..
Like it sounds, verifying that when that param is passed to the runtime
startup eps (`.open_root_actor()/.open_nursery()`), the appropriate
tpt-protocol is deployed for IPC (both the server and bound endpoints)
in both the root and any sub-actors (as passed down from rent to child
via the `.msg.types.SpawnSpec`).
For now just as sanity that we're not breaking anything on that
transport backend (since just a little while back there were issues with
crash handling in subs..) when it comes to crash-REPLing.
@goodboy goodboy force-pushed the multi_ipc_testing branch from 2c7238c to c9cd810 Compare July 13, 2025 19:35
Bc why clutter the intro like everyone else.. instead put them just
above the install section.
@goodboy goodboy force-pushed the multi_ipc_testing branch from c9cd810 to 1eb0d78 Compare July 13, 2025 19:49
@@ -0,0 +1,95 @@
'''
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guilledk mostly it'd be nice to get eyes on this new susys-unit-suite more then anything else 🙏🏼

return trio.run(main)

return wrapper

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aforementioned pytest plugin factoring for usage in other tractor dependents using the pointer mentioned in the descr.

)


def get_rando_addr(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also of (more minor) note for any reviewers; just a helper to generate rando-non-colliding tpt-proto-specific addrs to avoid multi-test-suite collisions running on the same host.

@goodboy goodboy requested a review from guilledk July 13, 2025 22:32
@goodboy
Copy link
Owner Author

goodboy commented Jul 13, 2025

@guilledk think this is ready for a quick check!

Copy link
Collaborator

@guilledk guilledk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking hawt

@goodboy goodboy merged commit 2248ffb into main Jul 13, 2025
2 checks passed
@goodboy goodboy deleted the multi_ipc_testing branch July 13, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants