Commit Graph

228 Commits (8a089e975d9151f43ff297bff19cb013fcdcbb2a)

Author SHA1 Message Date
David Wilson ef47347cdf tests: raft of fixes for vanilla Ansible 6 years ago
David Wilson 89e11ed25c tests: make osx_setup a little more generic again 6 years ago
David Wilson 2c3d2db4ec tests: fix output checks for Linux 6 years ago
David Wilson 7e49e73683 tests: add perl-JSON to the test images too.
Needed for the runner tests.
6 years ago
David Wilson ac80bf12f0 tests: start making osx_setup.yml more generic 6 years ago
David Wilson 16b5aa2d10 tests: disable host key checking for Paramiko. 6 years ago
David Wilson 41d2661ecb tests: fix sudo rule order. 6 years ago
David Wilson ed915b6e63 tests: magic mitogen_shutdown_all action
LRU tests break when run as part of the whole suite rather than
individually, because LRU stuff is already happening for earlier tests.
6 years ago
David Wilson 6614d17021 tests: explicit sudo rules to require password from sudo_nopw
This account is used on Travis. It needs to be forced to type passwords
in some cases
6 years ago
David Wilson ba8022424b tests: more work to standardize user accounts. 6 years ago
David Wilson ce6fb05d87 tests: 'fix' responder test.
Needs a complete rewrite, but this will do for now.
6 years ago
David Wilson 00aef80fac tests: /bin/bash login shell for all users. 6 years ago
David Wilson 63e2ec6406 tests: expanduser lookup runs locally 6 years ago
David Wilson 472610805f tests: fix remote_tmp test on 2.5.x. 6 years ago
David Wilson e2eac65347 tests: import mitogen_ansible_playbook.sh helper 6 years ago
David Wilson 89676b1257 tests: put unittest.skip() around fakessh tests for the time being 6 years ago
David Wilson 6390e36a4e tests: document selecting a target distribution. 6 years ago
David Wilson f203a91e1a tests: support CentOS Docker images.
- namespace & document test accounts in README.md
- standardize the password format everywhere, and ensure the passwords
  differ everywhere.
- Add MITOGEN_TEST_DISTRO environment variable.
6 years ago
David Wilson 9f94fb78c8 issue #159: make LRU size configurable. 6 years ago
David Wilson 6394226722 issue #159: verify no more than 20 tasks exist on the remote 6 years ago
David Wilson 633cd888a0 issue #182: test for previous commit. 6 years ago
David Wilson 9acca37050 issue #159: lots more test users. 6 years ago
David Wilson 0c803141a7 tests: fix filename. 6 years ago
David Wilson ec720eab1a Merge commit 'refs/pull/178/head' of github.com:dw/mitogen 6 years ago
David Wilson 3682ac6e29 fork: ensure importer handle is installed on the new router. 6 years ago
David Wilson c14f6c98d1 ansible: import osx_setup.yml. 6 years ago
David Wilson 98ee3e177a ansible: tests for sudo behaviour; closes #143. 6 years ago
David Wilson 3613162bc0 ansible: enable forking when requested and for async jobs.
Closes #105.
References #155.

mitogen/service.py:
    Refactor services to support individually exposed methods with
    different security policies for each method.

    - @mitogen.service.expose() to expose a method and set its policy
    - @mitogen.service.arg_spec() to validate input.
    - Require basic service message format to be a tuple of
      `(method, kwargs)`, where kwargs is always a dict.
    - Update DeduplicatingService to match the new scheme.

ansible_mitogen/connection.py:
    - Rename 'method' to 'method_name' to disambiguate it from the
      service.call()'s method= argument.

ansible_mitogen/planner.py:
    - Generate an ID for every job, sync or not, and fetch job results
      from JobResultService rather than via the initiating function
      call's return value.
    - Planner subclasses now get to select whether their Runner should
      run in a forked process. The base implementation requests this if
      the 'mitogen_isolation_mode=fork' task variable is present.

ansible_mitogen/runner.py:
    Teach runners to deliver their result via JobResultService executing
    in their indirect parent mux process.

ansible_mitogen/plugins/actions/mitogen_async_status.py:
    Split the implementation up into methods, and more compatibly
    emulate Ansible's existing output.

ansible_mitogen/process.py:
    Mux processes now host JobResultService.

ansible_mitogen/services.py:
    Update existing services to the new mitogen.service scheme, and
    implement JobResultService:

    * listen() method for synchronous jobs. planner.invoke() registers a
      Sender with the service prior to invoking the job, then sleeps
      waiting for the service to write the job result to the
      corresponding Receiver.

    * Non-blocking get() method for implementing mitogen_async_status
      action.

    * Child-accessible push() method for delivering task results.

ansible_mitogen/target.py:
    New helpers for spawning a virginal subprocess on startup, from
    which asynchronous and mitogen_task_isolation=fork jobs are forked.
    Necessary to avoid a task inheriting potentially
    polluted/monkey-patched parent environment, since remaining jobs
    continue to run in the original child process.

docs/ansible.rst:
    Add/merge/remove some behaviours/risks.

tests/ansible/integration:
    New tests for forking/async.
6 years ago
Alex Willmer 1bc32adad4 Issue #160: Cache minimize_source()
Before

```
python tests/bench/local.py
0 120.245933533
1 119.300842285
2 118.355035782
3 123.839855194
```

After

```
python tests/bench/local.py
0 66.3640499115
1 65.9508705139
2 72.4799633026
3 65.7958984375
```
6 years ago
Alex Willmer dc3f5730a2 Merge branch 'master' into eye-of-the-token-its-the-thrill-of-the-light 6 years ago
David Wilson b247c320d2 issue #164: rename tests for clarity 6 years ago
David Wilson bc4a6b39bf issue #164: teach debops_tests.sh to use SSH
Login with a non-privileged account over SSH rather than just jumping
straight in as root via Docker.
6 years ago
David Wilson 35fdd97f9a issue #164: utility to print Docker hostname for use from shell scripts. 6 years ago
David Wilson b9d4ec57b3 issue #164: some more ActionMixin tests. 6 years ago
David Wilson 29288b236b issue #164: import run_ansible_playbook.sh. 6 years ago
David Wilson db894478f8 issue #164: make become_flags work without FOO=2 env var. 6 years ago
David Wilson e4b49997d6 issue #164: whups, delete checked in binaries. 6 years ago
David Wilson d068a36c1e issue #164: more dir layout contortions.
all.yml slurps in tests from each file/subdir in the CWD.
6 years ago
David Wilson 680dc1bf68 issue #164: basic connection loader tests. 6 years ago
David Wilson 20ecd0af02 issue #164: fix makefile 6 years ago
David Wilson 48a0938d04 issue #164: add action module to return active strategy. 6 years ago
David Wilson 0247561fc7 issue #164: rename lib/modules 6 years ago
David Wilson 6aeb4e9f05 issue #164: precisely emulate Ansible's stdio behaviour.
* Use identical logic to select when stdout/stderr are merged, so
  'stdout', 'stdout_lines', 'stderr', 'stderr_lines' contain the same
  output before/after the extension.

* When stdout/stderr are merged, synthesize carriage returns just like
  the TTY layer.

* Mimic the SSH connection multiplexing message on stderr. Not really
  for user code, but so compare_output_test.sh needs fewer fixups.
6 years ago
David Wilson c5ca2e87ea issue #164: stop tests on first failure 6 years ago
David Wilson 26cc0f2724 issue #164: fix remote_tmp handling on <2.5 6 years ago
David Wilson 3ebe600389 issue #164: convert "examples" into actual tests
- Add new Travis mode, "ansible_tests.sh" that runs
  integrations/all.yml. Slowly build this up over time to cover more of
  the existing junk.

- Add basic assertions on the output of the existing runner__* files.

- Wire up 2.4.3/2.5.0 jobs in Travis.
6 years ago
David Wilson ae75a0ca8c issue #164: rearrange playbooks a little more 6 years ago
David Wilson 563639961d issue #164: dir structure is gross, but at least tab completion works :> 6 years ago
David Wilson 49aa8834b0 issue #164: split "examples" out into regression/integration tests. 6 years ago
David Wilson 4805f3cf36 issue #164: slightly flatten docker image layers 6 years ago
David Wilson 8ca8b43df1 tests/bench: import "slightly more reliable time" script 6 years ago
David Wilson eb402c8bd4 tests/bench: import wrapper script used for blog charts 6 years ago
David Wilson de27fb3a28 issue #174: test all io_op() logic. 6 years ago
Alex Willmer dc60f05a40 tests: Switch to unit2 test runner, with coverage
This means test files are imported as modules, not run as scripts. THey
can still be run individually if so desired. Test coverage is measured,
and an html report generated in htmlcov/. Test cases are automativally
discovered, so they need not be listed twice. An overall
passed/failed/skipped summary is printed, rather than for each file.

Arguments passed to ./test are passed on to unit2. For instance

    ./test -v

will print each test name as it is run.
6 years ago
Alex Willmer 7b8fef5284 tests: Make the tests directory an importable package
Required for test discovery by e.g. unit2, pytest
6 years ago
Alex Willmer a22294dda9 call_function_test: Fix assumption that we run as a script 6 years ago
Alex Willmer 0dcaeb21a2 master_test: Don't assume __file__ points to source code
When run under a test runner the unit tests are imported as modules.
This triggers .pyc generation, after which __file__ resolves to the .pyc
file.
6 years ago
Alex Willmer 841c2b13a1 fakessh_test: Apply timeout decorators to rsync tests
timeoutcontext.timeout uses SIGALRM, hence it will only work on Unix
like operating systems.
6 years ago
Alex Willmer 48623763d6 minimize_source: Implement reindentation 6 years ago
Alex Willmer 556ee2aec6 minimize_source: Handling indentation
In the case that string(s) are replaced, any indent or dedent tags must
be re-inserted after the replacemnts.
6 years ago
Alex Willmer 36c5ff1d05 minimize_source: Make comments test invariant on hashbang/coding handling
strip_comments() currently ignores comments on lines 1 and 2, in order
to preserve lines such as

The comments test had normal comments on those lines, hence it was
failing.
6 years ago
Alex Willmer 3bf61bb311 tests: Clarify which minimize_source samples are the reference 6 years ago
Alex Willmer 35ae4e4227 Issue #160: Add minimize_source testcases 6 years ago
David Wilson bbb0f1bbd8 issue #155: fix double-fork behaviour and test it this time. 6 years ago
David Wilson 4c433dbed1 parent_test: Add explanation. 6 years ago
David Wilson bde1778373 tests: merge tty_create_child() test into parent_test and fix hang 6 years ago
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.
6 years ago
David Wilson f726ef86de tests: first_stage_test regression due to 1ff27ada49 6 years ago
David Wilson 40b978c9b7 core: Fix source verification.
Previously:

* src_id could be spoofed
* auth_id was checked but the message was still delivered!
6 years ago
David Wilson fe614aa966 core: cleanup handlers on broker crash; closes #112. 6 years ago
David Wilson 1ff27ada49 Add maximum message size checks. Closes #151. 6 years ago
David Wilson 80a97fbc9b core: Rename Sender.put() to Sender.send().
Been annoying me for months.
6 years ago
David Wilson 085b3d21bd core: fix call_function_test regression
Second time in 3 weeks. So stupid. This time write tests.
6 years ago
David Wilson 0f29baa077 core: support pickling senders, Receiver.to_sender()
CC @moreati, in case this impacts you
6 years ago
David Wilson 17aef51e6e tests: Import .local() latency test 6 years ago
David Wilson a8a31728a0 tests: Import Latch soak test 6 years ago
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.
6 years ago
David Wilson 761cd9eaf8 tests: import tty_create_child_test.py. 6 years ago
David Wilson 7b12f84366 core: support CallError(str) for service.py. 6 years ago
David Wilson fccca54068 tests: ensure OpenSSL is initialized prior to test. 6 years ago
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.
6 years ago
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.
6 years ago
David Wilson 4f93c6823a issue #155: skeletal fork_test. 6 years ago
David Wilson 2d7821b824 tests: test_stream_name: fix non-localhost Docker 6 years ago
David Wilson 23e279b617 tests: get import_test limping back to health. 6 years ago
David Wilson f4ba66e3ee issue #155: allocate child IDs in batches of 1000.
Avoids a roundtrip for every fork.
6 years ago
David Wilson 2132c311b2 tests: mark some tests as skipped 6 years ago
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.
6 years ago
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'
```
6 years ago
Alex Willmer 0f82f68fee parent: Precompute preamble sizes for first stage
SSH command size: 453 (no change)
Preamble size: 8941 (-5 bytes)
6 years ago
Alex Willmer b433645d11 tests: Fix import error 6 years ago
Alex Willmer c6f3bfd93a tests: Correct path to apply_mode_spec() 6 years ago
David Wilson 23f78ca5a2 README: move testing bits into tests directory. 6 years ago
David Wilson f5b5e4849e tests: import very basic latch_test 6 years ago
David Wilson f6d87faf37 tests: import ansible_helpers_test. 6 years ago
Alex Willmer 4b373c421b core: Standardise type of Importer.whitelist
This seemed a reasonable streamlining, but I'm happy to be overruled.
6 years ago
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
6 years ago
Alex Willmer 491355548d tests: Fix typo in ResolveRelPathTest 6 years ago
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.
6 years ago
Alex Willmer eee312a57e tests: Fix expected values FindRelatedTest for Django 1.11.4 6 years ago