Commit Graph

115 Commits

Author SHA1 Message Date
David Wilson bbb0f1bbd8 issue #155: fix double-fork behaviour and test it this time. 2018-03-29 23:57:24 +05:45
David Wilson 4c433dbed1 parent_test: Add explanation. 2018-03-29 23:49:45 +05:45
David Wilson bde1778373 tests: merge tty_create_child() test into parent_test and fix hang 2018-03-29 23:36:50 +05:45
David Wilson 6670cba41c Introduce handler policy functions; closes #138.
Now you can specify a function to add_handler() that authenticates the
message header, with has_parent_authority() and is_immediate_child()
built in.
2018-03-29 21:40:33 +05:45
David Wilson f726ef86de tests: first_stage_test regression due to 1ff27ada49 2018-03-29 21:33:18 +05:45
David Wilson 40b978c9b7 core: Fix source verification.
Previously:

* src_id could be spoofed
* auth_id was checked but the message was still delivered!
2018-03-29 20:24:54 +05:45
David Wilson fe614aa966 core: cleanup handlers on broker crash; closes #112. 2018-03-29 19:32:31 +05:45
David Wilson 1ff27ada49 Add maximum message size checks. Closes #151. 2018-03-29 18:54:55 +05:45
David Wilson 80a97fbc9b core: Rename Sender.put() to Sender.send().
Been annoying me for months.
2018-03-29 15:43:48 +05:45
David Wilson 085b3d21bd core: fix call_function_test regression
Second time in 3 weeks. So stupid. This time write tests.
2018-03-29 15:34:20 +05:45
David Wilson 0f29baa077 core: support pickling senders, Receiver.to_sender()
CC @moreati, in case this impacts you
2018-03-29 15:32:40 +05:45
David Wilson 17aef51e6e tests: Import .local() latency test 2018-03-29 14:36:43 +05:45
David Wilson a8a31728a0 tests: Import Latch soak test 2018-03-29 14:31:57 +05:45
David Wilson 03fcf057dd tests: just call log_to_file() from testlib
Now we can run test.sh with MITOGEN_LOG_LEVEL=debug and things just
work.
2018-03-29 07:25:11 +00:00
David Wilson 761cd9eaf8 tests: import tty_create_child_test.py. 2018-03-29 13:03:08 +05:45
David Wilson 7b12f84366 core: support CallError(str) for service.py. 2018-03-29 11:53:02 +05:45
David Wilson fccca54068 tests: ensure OpenSSL is initialized prior to test. 2018-03-27 14:56:03 +05:45
David Wilson 4903052f42 fork: reseed Python/SSL PRNGs
Mac's SSL seems to have a pthread_atfork handler or similar that does
this for us, no clue if Linux is the same.
2018-03-27 11:58:17 +05:45
David Wilson 48351a1889 issue #155: parent: support Context.shutdown(), reap children on exit.
This permits graceful shutdown of individual contexts, without tearing
down everything.

Update mitogen.parent.Stream to also wait for the child to exit, to
prevent the buildup of zombie processes. This introduces a blocking wait
for process exit on the Broker thread, let's see if we can get away with
it. Chances are reasonable that it'll cause needless hangs on heavily
loaded machines.
2018-03-24 19:19:51 +05:45
David Wilson 4f93c6823a issue #155: skeletal fork_test. 2018-03-24 16:28:13 +05:45
David Wilson 2d7821b824 tests: test_stream_name: fix non-localhost Docker 2018-03-22 13:25:56 +05:45
David Wilson 23e279b617 tests: get import_test limping back to health. 2018-03-22 05:07:31 +05:45
David Wilson f4ba66e3ee issue #155: allocate child IDs in batches of 1000.
Avoids a roundtrip for every fork.
2018-03-22 03:41:04 +05:45
David Wilson 2132c311b2 tests: mark some tests as skipped 2018-03-19 21:58:35 +05:45
David Wilson 8aada2646c core: support throwing LatchError in every sleeping thread
This is to allow Select() to be used as a generic queueing primitive
that supports graceful shutdown.
2018-03-19 21:58:35 +05:45
Alex Willmer e3b700b553 tests: Fix no such option -o running FakeSsh.test_okay()
Full output of failed test

```
ERROR: test_okay (__main__.FakeSshTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/ssh_test.py", line 16, in test_okay
    ssh_path=testlib.data_path('fakessh.py'),
  File "/home/alex/src/mitogen/mitogen/master.py", line 650, in ssh
    return self.connect('ssh', **kwargs)
  File "/home/alex/src/mitogen/mitogen/parent.py", line 463, in connect
    return self._connect(context_id, klass, name=name, **kwargs)
  File "/home/alex/src/mitogen/mitogen/parent.py", line 449, in _connect
    stream.connect()
  File "/home/alex/src/mitogen/mitogen/ssh.py", line 104, in connect
    super(Stream, self).connect()
  File "/home/alex/src/mitogen/mitogen/parent.py", line 395, in connect
    self._connect_bootstrap()
  File "/home/alex/src/mitogen/mitogen/ssh.py", line 116, in
_connect_bootstrap
    time.time() + 10.0):
  File "/home/alex/src/mitogen/mitogen/parent.py", line 207, in
iter_read
    (''.join(bits)[-300:],)
mitogen.core.StreamError: EOF on stream; last 300 bytes received:
'Usage: fakessh.py [options]\n\nfakessh.py: error: no such option: -o\n'
```
2018-03-19 21:58:34 +05:45
Alex Willmer 0f82f68fee parent: Precompute preamble sizes for first stage
SSH command size: 453 (no change)
Preamble size: 8941 (-5 bytes)
2018-03-19 21:58:34 +05:45
Alex Willmer b433645d11 tests: Fix import error 2018-03-19 21:58:33 +05:45
Alex Willmer c6f3bfd93a tests: Correct path to apply_mode_spec() 2018-03-19 21:58:33 +05:45
David Wilson 23f78ca5a2 README: move testing bits into tests directory. 2018-03-19 21:58:32 +05:45
David Wilson f5b5e4849e tests: import very basic latch_test 2018-03-19 21:58:32 +05:45
David Wilson f6d87faf37 tests: import ansible_helpers_test. 2018-03-19 21:58:31 +05:45
Alex Willmer 4b373c421b core: Standardise type of Importer.whitelist
This seemed a reasonable streamlining, but I'm happy to be overruled.
2018-03-19 21:58:31 +05:45
Alex Willmer 8338caa419 tests: Add mitogen.core.is_blacklisted_import() tests
These test the current behviour, which may not be exactly the intended
behaviour. Refs #98
2018-03-19 21:58:31 +05:45
Alex Willmer 491355548d tests: Fix typo in ResolveRelPathTest 2018-03-19 21:58:30 +05:45
Alex Willmer ef35d55523 tests: Remove jinja2/markupsafe modules from FindRelatedTest
Not sure how they got there, but Django doesn't use Jinja without
explicit configuration.
2018-03-19 21:58:30 +05:45
Alex Willmer eee312a57e tests: Fix expected values FindRelatedTest for Django 1.11.4 2018-03-19 21:58:30 +05:45
Alex Willmer 4424bfbb7a tests: Add new FindRelatedImportsTest 2018-03-19 21:58:30 +05:45
Alex Willmer 9e43f5e6ba tests: Remove module under search from expected results
This matches a tweak made in 8765f761c9
2018-03-19 21:58:30 +05:45
Alex Willmer 0f9bfc1e21 tests: Rename FindRelatedImportsTest -> FindRelatedTest 2018-03-19 21:58:30 +05:45
David Wilson afc8697288 core: Ensure add_handler() callbacks really receive _DEAD on shutdown 2018-03-19 21:58:30 +05:45
David Wilson ccd9c62399 tests: stubs for future whitelist/blacklist tests. 2018-03-19 21:58:29 +05:45
Alex Willmer f4405c6bbc Split IterReadTest & WriteAllTest into test_parent
This matches their respective functions under test, which now reside in
mitogen.parent.
2018-03-19 21:58:29 +05:45
Alex Willmer 4fb1b928b7 Adjust unittest for master -> parent split
Tests should now match changes in
4d31300dd0
2018-03-19 21:58:29 +05:45
Alex Willmer 9ccff0f5d1 Fix TypeError while initiliazing ImporterMixin
Since f44356af32 mitogen.core.Importer()
takes a Router instance.
2018-03-19 21:58:29 +05:45
Alex Willmer fa0f390d4d FIx syntax error in FindRelatedImportsTest.test_django_db_models 2018-03-19 21:58:29 +05:45
David Wilson dd088908df select: clean up API. 2018-03-19 21:58:28 +05:45
David Wilson 219718740b Move django test script into permanent test 2018-03-19 21:58:28 +05:45
David Wilson ec1de4b4b9 tests: ensure strace is available in the docker image..
..and enable privileged=True since that's needed for ptrace()
2018-03-19 21:58:28 +05:45
David Wilson b2909ee5f4 Replace nasty print statements in six_brokenpkg. 2018-03-19 21:58:28 +05:45