Commit Graph

269 Commits (0183c5bf9bdb3c92cc99163ef02b35fa4649487c)

Author SHA1 Message Date
Tyler Goodlet 2b4cf59ee1 Drop sleep 2021-05-07 11:21:40 -04:00
Tyler Goodlet 5ca963148e Disable leftover debug mode 2021-05-07 11:21:40 -04:00
Tyler Goodlet 4798d3b5db Drop lingering rpc_module_paths refs 2021-05-07 11:21:40 -04:00
Tyler Goodlet 247483ee93 Drop run and rpc_module_paths from streaming tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet 9e64161538 Drop run and rpc_module_paths from rpc tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet 3bddf9a94b Drop run and rpc_module_paths from spawning tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet 1eedd463cb Drop run and rpc_module_paths from pubsub tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet b46e60ab9d Drop run from multi prog tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet cb527c2562 Mostly drop run from local tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet 1584c547cd Drop run and rpc_module_paths from discovery tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet 2efd8ed167 Drop run and rpc_module_paths from cancel tests 2021-05-07 11:21:40 -04:00
Tyler Goodlet b1f657e246 De-compact async with tuple on 3.8-
Turns out can't use the nicer syntax before python 3.9 (even though it
doesn't seem documented anywhere?).

Relates to #207
2021-04-28 16:35:15 -04:00
Tyler Goodlet 2498a4963b Update all tests to new streaming API 2021-04-28 12:23:14 -04:00
Tyler Goodlet 1f1619c730 Convert all test suite sync funcs 2021-04-27 12:08:30 -04:00
Tyler Goodlet 47565cfbf3 Use root as default name from `tractor.run()` 2021-02-25 08:51:28 -05:00
Tyler Goodlet cd636b270e Update debug tests to expect 'root' actor name 2021-02-24 13:38:20 -05:00
Tyler Goodlet 8fabd27dbe Lint fixes 2021-02-24 13:13:51 -05:00
Tyler Goodlet a93321e48e Don't run stdlib example as part of test set 2021-02-21 15:41:21 -05:00
Tyler Goodlet 07653bc02e Run parallel examples 2021-02-21 14:08:23 -05:00
Tyler Goodlet 59421d9f3a Fix some borked tests 2021-01-08 20:55:11 -05:00
Tyler Goodlet 5127effd88 Drop warning level logging assert(s) 2020-12-26 15:45:55 -05:00
Tyler Goodlet 4bf9b27f57 Drop all .statespace refs; it was a silly idea 2020-12-22 19:33:16 -05:00
Tyler Goodlet 0eba5f4708 Port remaining tests to pass func refs 2020-12-22 10:39:47 -05:00
Tyler Goodlet 493f2efb50 Port tests to `Portal.run_from_ns()` 2020-12-22 10:39:47 -05:00
Tyler Goodlet a668f714d5 Allow passing function refs to `Portal.run()`
This resolves and completes #69 allowing all RPC invocation APIs to pass
function references directly instead of explicit `str` names for the
target namespace and function (this is still done implicitly
underneath).  This brings us closer to `trio`'s task running API as well
as acknowledges that any inter-host RPC system (and API) will likely
need to be implemented on top of local RPC primitives anyway. Even if
this ends up **not** being true we can always go to "function stubs" as
part of our IAC protocol or, add a new method to do explicit namespace
calls: `.run_from_module()` or whatever everyone votes on.

Resolves #69

Further, this commit drops `Actor.statespace` from the entire system
since a user can easily get this same functionality using module
level variables. Fix docs to match all these changes (luckily mostly
already done due to example scripts referencing).
2020-12-21 09:09:55 -05:00
Tyler Goodlet dc475b54ab More obnoxious CI timeout handling 2020-12-18 19:26:29 -05:00
Tyler Goodlet a95488ad2f Handle pexpect's internal timeout 2020-12-18 17:57:44 -05:00
Tyler Goodlet 47f68a0532 Skip debugger tests on non-trio backends 2020-12-17 16:37:05 -05:00
Tyler Goodlet 797bcc1df2 Handle early timeouts on last debugger test 2020-12-17 13:35:45 -05:00
Tyler Goodlet 201771a521 'Fix mypy, change interal type name to `ReceiveStream`, settle on `.shield()`' 2020-12-17 12:01:49 -05:00
Tyler Goodlet 15ead6b561 Add a way to shield a stream's underlying channel
Add a ``tractor._portal.StreamReceiveChannel.shield_channel()`` context
manager which allows for avoiding the closing of an IPC stream's
underlying channel for the purposes of task re-spawning. Sometimes you
might want to cancel a task consuming a stream but not tear down the IPC
between actors (the default). A common use can might be where the task's
"setup" work might need to be redone but you want to keep the
established portal / channel in tact despite the task restart.

Includes a test.
2020-12-16 21:42:28 -05:00
Tyler Goodlet 0118589875 Add race case handling for mp backend 2020-12-12 13:30:14 -05:00
Tyler Goodlet a8406c8626 Toss in another tests with daemon subactors 2020-10-15 23:16:56 -04:00
Tyler Goodlet 61a8df358c Comments tweak 2020-10-14 09:06:40 -04:00
Tyler Goodlet 1b6ee2ecf6 Skip sync sleep test on windows 2020-10-13 15:26:46 -04:00
Tyler Goodlet 15edcc622d Skip it on windows too 2020-10-13 15:13:46 -04:00
Tyler Goodlet fd59f4ad16 On windows .spawn dne? 2020-10-13 14:56:26 -04:00
Tyler Goodlet a934eb063c Factor `repodir()` helper into conftest.py 2020-10-13 14:49:31 -04:00
Tyler Goodlet a49deb46f1 Revert "Make tests a package (for relative imports)"
This reverts commit 1710b642a5.
2020-10-13 14:42:16 -04:00
Tyler Goodlet 666966097a Revert "Change to relative conftest.py imports"
This reverts commit 2b53c74b1c.
2020-10-13 14:42:02 -04:00
Tyler Goodlet ba52de79e1 Skip quad ex on local mp tests as well 2020-10-13 14:20:19 -04:00
Tyler Goodlet 24ef919334 Skip sync sleep test on mp backend 2020-10-13 14:16:20 -04:00
Tyler Goodlet 1710b642a5 Make tests a package (for relative imports) 2020-10-13 10:50:21 -04:00
Tyler Goodlet a88a6ba7a3 Add pattern matching to test 2020-10-13 00:36:34 -04:00
Tyler Goodlet 0e344eead8 Add a "cancel arrives during a sync sleep in child" test
This appears to demonstrate the same bug found in #156. It looks like
cancelling a subactor with a child, while that child is running sync code,
can result in the child never getting cancelled due to some strange
condition where the internal nurseries aren't being torn down as
expected when a `trio.Cancelled` is raised.
2020-10-12 23:25:22 -04:00
Tyler Goodlet acb4cb0b2b Add test showing issue with child in tty lock when cancelled 2020-10-07 06:08:31 -04:00
Tyler Goodlet abf8bb2813 Add a deep nested error propagation test 2020-10-06 09:21:53 -04:00
Tyler Goodlet 2b53c74b1c Change to relative conftest.py imports 2020-10-05 11:58:58 -04:00
Tyler Goodlet 371025947a Add a multi-subactor test where the root errors 2020-10-05 11:58:58 -04:00
Tyler Goodlet 31c1a32d58 Add re-entrant root breakpoint test; demonstrates a bug.. 2020-10-05 11:58:58 -04:00
Tyler Goodlet e387e8b322 Add a multi-subactor test with nesting 2020-10-05 11:58:58 -04:00
Tyler Goodlet 73a32f7d9c Add initial subactor debug tests 2020-10-05 11:58:58 -04:00
Tyler Goodlet 0a2a94fee0 Add initial root actor debugger tests 2020-10-05 11:58:58 -04:00
Tyler Goodlet e7ee0fec34 Pass a copy of the expected exposed modules 2020-09-24 10:12:10 -04:00
Guillermo Rodriguez 5e3ce765dd
Drop mac support, will continue the experiment on another branch 2020-09-03 10:41:09 -03:00
Guillermo Rodriguez ad68ff665f
Missing a platform.system() check 2020-09-03 09:57:04 -03:00
Guillermo Rodriguez c993e36e95
Simplified CI detection 2020-09-03 09:44:24 -03:00
Guillermo Rodriguez 03e5852acf
Added some missing CI integration pieces 2020-09-02 13:19:42 -03:00
Tyler Goodlet 451170bb63 Pass explicit kwargs to new discovery test funcs 2020-08-13 13:26:08 -04:00
Tyler Goodlet 0c8dcd0ec5 Use allocated arbiter port in local reg test 2020-08-13 11:54:37 -04:00
Tyler Goodlet 1ae0efb033 Make rpc_module_paths a list 2020-08-13 11:53:45 -04:00
Tyler Goodlet acd5b80f4c Add close channel test with remote arbiter 2020-08-08 15:17:04 -04:00
Tyler Goodlet c821690834 Actor cancellation is now more latent; loosen timeing 2020-08-08 15:16:10 -04:00
Tyler Goodlet 7f74182a8a Never allow more then info logging in daemon; causes blocking 2020-08-08 15:15:43 -04:00
Tyler Goodlet 3a868fec30 Cancel root nursery to trigger failure
The real issue is if the root nursery gets cancelled prior to
de-registration with the arbiter. This doesn't seem easy to
reproduce by side effect of a KBI however that is how it was
discovered in practise.
2020-08-07 11:34:17 -04:00
Tyler Goodlet d2d8860dad Add test for dereg failure on manual stream close
There was code from the last de-registration fix PR that I had commented
(to do with shielding arbiter dereg steps in `Actor._async_main()`) because
the block didn't seem to make a difference under infinite streaming
tests. Turns out it **for sure** is needed under certain conditions (likely
if the actor's root nursery is cancelled prior to actor nursery exit).
This was an attempt to simulate the failure mode if you manually close the
stream **before** cancelling the containing **actor**.

More tests to come I guess.
2020-08-07 09:16:01 -04:00
Tyler Goodlet a5279f80a7 Actually reproduce the de-registration problem
This truly reproduces #141. It turns out the problem only occurs when
we're cancelled in the middle of consuming "infinite streams".
Good news is this tests a lot of edge cases :)
2020-08-03 18:28:09 -04:00
Tyler Goodlet 699bfd1857 Run unreg on cancel tests with remote arbiter as well 2020-08-03 15:41:41 -04:00
Tyler Goodlet 2ccaa94c60 Move daemon fixture up to conftest 2020-08-03 15:39:54 -04:00
Tyler Goodlet 0d9483376d Test cancel with SIGINT on non-windows as well 2020-08-03 13:01:56 -04:00
Tyler Goodlet cd2d8c217a Test that subactors deregister on cancel 2020-08-03 12:53:03 -04:00
Tyler Goodlet da56d0f043 Add slight delays to SIGINT tests on mp 2020-07-29 13:27:15 -04:00
Tyler Goodlet 8f17c89cf9 Skip **every** quad test for mp on ci 2020-07-29 10:26:19 -04:00
Tyler Goodlet 5715fd4599 Skip streaming tests 2020-07-27 12:20:46 -04:00
Tyler Goodlet e8a38e4d15 Fix cancelled type handling 2020-07-27 11:15:05 -04:00
Tyler Goodlet 3c7ec72f8e Fix SIGINT test names 2020-07-26 23:37:44 -04:00
Tyler Goodlet 5a27065a10 Finally tame the super flaky tests
- ease up on first stream test run deadline
- skip streaming tests in CI for mp backend, period
- give up on > 1 depth nested spawning with mp
- completely give up on slow spawning on windows
2020-07-26 22:53:40 -04:00
Tyler Goodlet 891edbab5f Run the trio spawner in nested tests 2020-07-25 18:19:17 -04:00
Tyler Goodlet dddbeb0e71 Run Windows on trio and mp backends
The new pure trio spawning backend uses `subprocess` internally which is
also supported on windows so let's run it in CI.
2020-07-25 13:41:48 -04:00
Tyler Goodlet a215df8dfc Add true ctrl-c tests using an out-of-band SIGINT
Verify ctrl-c, as a user would trigger it, properly cancels the actor
tree. This was an issue with `trio-run-in-process` that clearly wasn't
being handled correctly but for sure is now with the plain old
`trio` process spawner.

Resolves #115
2020-07-24 17:08:52 -04:00
Tyler Goodlet 4de75c3a9d Test cancel via api and keyboard interrupt
An initial attempt to discover an issue with trio-run-inprocess.
This is a good test to have regardless.
2020-07-24 17:08:52 -04:00
Tyler Goodlet 5adf2f3b0c Add logging to some cancel tests 2020-07-24 17:08:52 -04:00
Guillermo Rodriguez 56463a08df First attempt at removing trip & updating hazmat -> lowlevel 2020-07-24 17:08:52 -04:00
Tyler Goodlet d62610c44e Search for guard and strip instead of hardcoding 2020-02-10 12:59:44 -05:00
Tyler Goodlet 63bcd99323 Only error the exs test when "Error" in last line of output 2020-02-10 12:14:16 -05:00
Tyler Goodlet f2030a2714 Better document the window's gotcha solution in test code 2020-02-09 14:59:22 -05:00
Tyler Goodlet 7880934505 Add tests for all docs examples
Parametrize our docs example test to include all (now fixed) examples
from the `READ.rst`. The examples themselves have been fixed/corrected
to run but they haven't yet been updated in the actual docs. Once #99
lands these example scripts will be directly included in our
documentation so there will be no possibility of presenting incorrect
examples to our users! This technically fixes #108 even though the new
example aren't going to be included directly in our docs until #99
lands.
2020-02-09 02:01:39 -05:00
Tyler Goodlet 70636a98f6 Use the windows "gotchcas" fix for example tests
Apply the fix from @chrizzFTD where we invoke the entry point using
module exec mode on a ``__main__.py`` and import the
``test_example::`main()` from within that entry point script.
2020-02-09 01:07:07 -05:00
Tyler Goodlet c6f3ab5ae2 Initial examples testing attempt
A per #98 we need tests for examples from the docs as they would be run
by a user copy and pasting the code. This adds a small system for loading
examples from an "examples/" directory and executing them in
a subprocess while checking the output. We can use this to also verify
end-to-end expected logging output on std streams (ex. logging on
stderr).

To expand this further we can parameterize the test list using the
contents of the examples directory instead of hardcoding the script
names as I've done here initially.

Also, fix up the current readme examples to have the required/proper `if
__name__ == '__main__'` script guard.
2020-02-07 19:36:52 -05:00
Tyler Goodlet a6b249cd52 Forkserver just can't seem to cut it... 2020-01-26 23:17:06 -05:00
Tyler Goodlet 5fd38d4618 Force `mp` backend if option is blank? 2020-01-26 23:16:43 -05:00
Tyler Goodlet b4cb7439a1 Drop useless fork error branch 2020-01-26 22:46:48 -05:00
Tyler Goodlet 7c1bc1fce4 Make windows job names explicit 2020-01-26 22:17:38 -05:00
Tyler Goodlet e18fec9b17 Always force mp backend on Windows 2020-01-26 22:09:06 -05:00
Tyler Goodlet ecced3d09a Allow choosing the spawn backend per test session
Add a `--spawn-backend` option which can be set to one of {'mp',
'trio_run_in_process'} which will either run the test suite using the
`multiprocessing` or `trio-run-in-process` backend respectively.
Currently trying to run both in the same session can result in hangs
seemingly due to a lack of cleanup of forkservers / resource trackers
from `multiprocessing` which cause broken pipe errors on occasion (no
idea on the details).

For `test_cancellation.py::test_nested_multierrors`, use less nesting
when mp is used since it breaks if we push it too hard with the
whole recursive subprocess spawning thing...
2020-01-26 21:36:08 -05:00
Tyler Goodlet 783fe53b06 Don't mix trip with multiprocessing for now
It seems that mixing the two backends in the test suite results in hangs
due to lingering forkservers and resource managers from
`multiprocessing`? Likely we'll need either 2 separate CI runs to work
or someway to be sure that these lingering servers are killed in between
tests.
2020-01-24 00:55:40 -05:00
Tyler Goodlet bc259b7eab Use trip as default in all tests for now 2020-01-24 00:54:19 -05:00
Tyler Goodlet 44996fe328 Add trip to start_method parametrizations 2020-01-23 01:16:10 -05:00
Tyler Goodlet e1a55a6f4f Importing happens once locally now so expect a local error 2020-01-21 10:28:32 -05:00
Tyler Goodlet 915bf17a9a 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.
2019-11-25 12:05:15 -05:00
Tyler Goodlet 2d4b6de4f4 Spawn even less suba-actors in Windows CI
Seems like we've probably got some greater limitations
with Windows and "nested" spawned sub-processes...
2019-11-22 21:23:25 -05:00
Tyler Goodlet 97df927714 Run first example test under both start methods 2019-10-30 00:31:28 -04:00
Tyler Goodlet 6d9ac53bd5 Add nested multierror testing
Add a test to verify that `trio.MultiError`s are properly propagated up
a simple actor nursery tree. We don't have any exception marshalling
between processes (yet) so we can't validate much more then a simple
2-depth tree. This satisfies the final bullet in #43.

Note I've limited the number of subactors per layer to around 5 since
any more then this seems to break the `multiprocessing` forkserver;
zombie subprocesses seem to be blocking teardown somehow...

Also add a single depth fast fail test just to verify that it's the
nested spawning that triggers this forkserver bug.
2019-10-30 00:30:40 -04:00
Tyler Goodlet d406383cd3 Add a preliminary nested subactor `MultiError` test
This exemplifies the undefined behaviour in #88 and begins to test for
the last bullet in #43.
2019-10-26 15:04:13 -04:00
Tyler Goodlet 6dbb3f7ae6 Extend cancellation tests
In an effort towards #43. This completes the first major bullet's worth of tests
described in that issue.
2019-10-26 09:55:07 -04:00
Tyler Goodlet 6ec9752f46 Slight slowdown on windows / py3.8? 2019-10-16 11:02:18 -04:00
Tyler Goodlet 7e8b7091cb Check for proper SIGINT return code
They finally got https://bugs.python.org/issue1054041 in Python 3.8
2019-10-15 23:22:48 -04:00
Tyler Goodlet 5760bb1b7c Adjust test timeout/sync handling for windows 2019-03-31 15:34:44 -04:00
Tyler Goodlet b965d20cba Add stream func tests 2019-03-29 19:10:56 -04:00
Tyler Goodlet faa1f373b5 Add subactor loglevel propagation test
Can't seem to get the `capfd` fixture to capture subprocess logging to
stderr even though the console report shows the log message as being
captured? Skipping the test on the forkserver method for now.
2019-03-23 23:27:32 -04:00
Christian López Barrón 5fc51fd745 multi_program signal for windows missing SIGKILL, SIGINT 2019-03-13 21:32:45 +11:00
Christian López Barrón 2138d55a60 increased trio.sleep time for other actors to spawn 2019-03-13 21:32:45 +11:00
Christian López Barrón efffca371a pytest_generate_tests remove `fork` only if it's in list 2019-03-13 21:32:45 +11:00
Tyler Goodlet 9a780485dc Use "clean channel shutdown" in streaming example
Resolves #65
2019-03-10 22:08:50 -04:00
Tyler Goodlet b70f4eafcb Flip tests to use `start_method` kwarg 2019-03-08 20:06:16 -05:00
Tyler Goodlet d6ca722bcc Sprinkle `spawn_method` fixture throughout tests 2019-03-06 00:37:02 -05:00
Tyler Goodlet 483ae42a46 Add a `spawn_method` dynamic fixture 2019-03-06 00:36:37 -05:00
Tyler Goodlet 78ddd33e3a Move to `trio.CancelScope` 2019-02-16 14:25:06 -05:00
Tyler Goodlet 85a0700716 Add back line that breaks with async gens 2019-02-15 22:10:55 -05:00
Tyler Goodlet 51f082fff7 Use mem chan in streaming tests 2019-02-15 17:10:57 -05:00
Tyler Goodlet 41c202db68 Add a multi-task subscriber test
In combination with `.aclose()`-ing the async gen instance returned from
`Portal.run()` this demonstrates the python bug:
https://bugs.python.org/issue32526

I've commented out the line that triggers the bug for now since this
case provides motivation for adding our own `trio.abc.ReceiveMemoryChannel`
implementation to be used instead of async gens directly (returned from
`Portal.run()`) since the latter is **not** task safe.
2019-02-15 17:04:41 -05:00
Tyler Goodlet b0b35284f4 Add call/decorate time type checking tests 2019-01-25 00:13:13 -05:00
Tyler Goodlet 2b1e8773bb Verify subs topics at each step 2019-01-23 22:35:04 -05:00
Tyler Goodlet 36ee6695fb Add initial pubsub test 2019-01-21 12:31:03 -05:00
Tyler Goodlet d2f0537850 Add tests for import-time failures 2019-01-12 17:56:39 -05:00
Tyler Goodlet fe4a39550d Add remote module error handling tests 2019-01-01 16:12:34 -05:00
Tyler Goodlet 47b531a43a Add test to verify remote task cancellation 2018-12-10 23:13:58 -05:00
Tyler Goodlet 512a2f25a2 Expose `tractor_test` in the same way as `trio` 2018-11-26 11:26:04 -05:00
Tyler Goodlet 0879150399 Move `tractor_test` to new module 2018-11-26 11:20:53 -05:00
Tyler Goodlet 23c7519fec Jeeze 3.7.1 got even faster? 2018-11-22 14:25:31 -05:00
Tyler Goodlet a482681f9c Leverage `pytest.raises()` better; fix a bunch of docs 2018-11-22 11:43:04 -05:00
Tyler Goodlet 3e74cc6f11 Verify nested boxed errors 2018-11-19 16:53:21 -05:00
Tyler Goodlet 7a2b7d9d14 Delay tweak for py3.7.1 2018-11-19 14:17:01 -05:00
Tyler Goodlet 9102c48810 Add multierror cancellation tests 2018-11-19 14:16:42 -05:00
Tyler Goodlet aa32f42715 Avoid hanging multi-prog test when SIGINT fails 2018-11-09 01:36:45 -05:00
Tyler Goodlet 034146f2b1 Verify arbiter self registration 2018-09-21 00:32:23 -04:00
Tyler Goodlet 7dd91d0684 Wait longer for arbiter-daemon to spawn on py3.6 2018-09-17 09:17:11 -04:00
Tyler Goodlet 827a6c6014 Make `rpc_modules` a positional arg to `tractor.run_daemon()` 2018-09-10 22:31:23 -04:00
Tyler Goodlet 037c4c3797 Comment tweak 2018-09-10 15:28:19 -04:00
Tyler Goodlet d12136d44d Add some mult-program tests
Run the arbiter-actor in a separate program and do some basic tests to
make sure everything works - particularly, registration and
cancellation.
2018-09-08 09:44:29 -04:00
Tyler Goodlet 0ca668453c Running without a main func is a type error 2018-09-05 18:13:23 -04:00
Tyler Goodlet a998a5e415 Forgot to remove spawn tests from test_local.py 2018-09-04 22:17:02 -04:00
Tyler Goodlet c2457f7cce Move basic spawning tests to separate module 2018-09-02 22:07:32 -04:00
Tyler Goodlet 18e101d38e Move streaming tests into separate module 2018-09-02 21:58:42 -04:00
Tyler Goodlet 51076ebb5c Break cancellation tests into new module 2018-09-02 11:51:58 -04:00
Tyler Goodlet 3dcf16c43d Min cancel delay >= 0 2018-08-31 20:38:34 -04:00
Tyler Goodlet a64c2a70bd Base cancel delays on speed of a non-cancelled run 2018-08-19 16:08:02 -04:00
Tyler Goodlet 8c110c79fb A teensy more lax on the speed test 2018-08-17 16:55:00 -04:00
Tyler Goodlet ea60a3dff9 Test the `wait_for_actor()` api 2018-08-13 00:06:22 -04:00
Tyler Goodlet 99e2cf9a13 Draft v2 after new `run_in_actor()` API
Revamp the docs after some feedback from @vodik.
See #24 #25 for additional details.
2018-08-07 18:05:35 -04:00