Commit Graph

299 Commits (998762ab4ff83631dc58cf536ce3d97a4204270f)

Author SHA1 Message Date
David Wilson 9617f4d7bf Revert "try to catch EINTR on travis"
This reverts commit 42797d5cff.
6 years ago
David Wilson fbb67e837e tests: import nice_stdout plugin 6 years ago
David Wilson 42797d5cff try to catch EINTR on travis 6 years ago
David Wilson ffc7306cf8 tests: better runner_two_simultaneous_jobs.yml. 6 years ago
David Wilson 1d96d80e8d tests: osx_setup.yml missing line 6 years ago
David Wilson 3994f1b30a ansible: implment async job time limit. 6 years ago
David Wilson df8fe59eda tests: replace hard-coded sleep with a polling loop 6 years ago
David Wilson 64b60be50c tests: split runner_new_process out of runner_one_job 6 years ago
David Wilson f7d2eace08 tests: importer fixes 6 years ago
David Wilson cee76ee7b9 tests: gcloud setup fixes. 6 years ago
David Wilson 3b0addcfb0 service: v2. Closes #213 6 years ago
David Wilson 633585524f tests: don't need separate module for id_allocation_test any more
This used to be because everything would explode while importing
__main__ under py.test, but that was fixed months ago.
6 years ago
David Wilson ddf28987a0 master: split Select() into new module to reduce wire size.
service.py currently imports master.py(+parent.py) just to get Select().
6 years ago
David Wilson b0ce6eecd7 fork: support on_start= argument. 6 years ago
David Wilson 00edf0d66d core: have ExternalContext accept a config dict rather than kwargs.
The parameter lists had gotten out of control.
6 years ago
David Wilson eac4cc7afe tests: speed things up 6 years ago
David Wilson b0aa413173 tests: import benchmark reproduction setup playbook
Incomplete, also needs to mess around with Gcloud routing and handle box
setup/teardown, because that's another "well engineered" waste of time.
6 years ago
David Wilson a99c7a12f9 tests: output split groups in gcloud.py 6 years ago
David Wilson dbcee4041a tests: refactor gcloud.py to be dynamic inventory. 6 years ago
David Wilson a3995f8e5f ansible: remove hard-coded dw username. 6 years ago
David Wilson 2c58591129 Bump Ansible version in dev_requirements.txt 6 years ago
David Wilson 78d375e0c5 core: CallError should handle any exception type.
Previously SystemExit would be pickled.
6 years ago
David Wilson faaac43a78 Disable SSH variables test on vanilla Ansible. 6 years ago
David Wilson 68d6e6bf34 ansible: tests for all SSH variables.
Closes #184.
6 years ago
David Wilson 356647bef4 issue #132: initial unidirectional routing mode. 6 years ago
David Wilson 2a4157723a tests: fix breakage from moving is_stdlib_name() 6 years ago
David Wilson 7d9b7eec0c tests: must wrap log_to_file() in is_master
Without it, end up with a billion loggers attached in some tests
6 years ago
David Wilson 2ad0d0521d ansible: reload /etc/resolv.conf for each task.
The OpenShift installer modifies /etc/resolv.conf then tests the new
resolver configuration, however, there was no mechanism to reload
resolv.conf in our reuseable interpreter.

https://github.com/openshift/openshift-ansible/blob/release-3.9/roles/openshift_web_console/tasks/install.yml#L137

This inserts an explicit call to res_init() for every new style
invocation, with an approximate cost of ~1usec on Linux since glibc
verifies resolv.conf has changed before reloading it.

There is little to be done for users of the thread-safe resolver APIs,
their state is hidden from us. If bugs like that manifest, whack-a-mole
style 'del sys.modules[thatmod]' patches may suffice.
6 years ago
David Wilson 60781ecab6 tests: fix test for vanilla Ansible. 6 years ago
David Wilson eb56a8f98d tests: add debug 6 years ago
David Wilson 267f787d20 issue #217: tests: import (unused) module_utils tests. 6 years ago
David Wilson ee741da2b3 tests: reenable remaining Ansible tests. 6 years ago
David Wilson cecef992b0 issue #218: core: add Secret and Blob types. 6 years ago
David Wilson be5c03c152 tests: many test fixes. Travis broken for >1 week. 6 years ago
David Wilson 69f58875c8 tests: more ansible fixes from recent brakage. 6 years ago
David Wilson b20174729d issue #199: fix readonly_homedir test. 6 years ago
David Wilson f98279fc95 tests: fix LRU test after splitting up Connection class.
The module the connection class is now loaded as is
"ansible.plugins.connection.mitogen_ssh", etc., which breaks the test.
Instead, check if the connection is an instance of the base Connection
class.
6 years ago
David Wilson f9e1905ec6 issue #199: ansible: stop writing temp files for new style modules
While adding support for non-new style module types, NewStyleRunner
began writing modules to a temporary file, and sys.argv was patched to
actually include the script filename. The argv change was never required
to fix any particular bug, and a search of the standard modules reveals
no argv users. Update argv[0] to be '', like an interactive interpreter
would have.

While fixing #210, new style runner began setting __file__ to the
temporary file path in order to allow apt.py to discover the Ansiballz
temporary directory. 5 out of 1,516 standard modules follow this
pattern, but in each case, none actually attempt to access __file__,
they just call dirname on it. Therefore do not write the contents of
file, simply set it to the path as it would exist, within a real
temporary directory.

Finally move temporary directory creation out of runner and into target.
Now a single directory exists for the duration of a run, and is emptied
by runner.py as necessary after each task invocation.

This could be further extended to stop rewriting non-new-style modules
in a with_items loop, but that's another step.

Finally the last bullet point in the documentation almost isn't a lie
again.
6 years ago
David Wilson 6109de51a0 tests: Ansible SSH timeout test
Also change Docker image to new 'mitogen' organization.
6 years ago
David Wilson d4d4f46006 tests: update check_host_keys parameter style in testlib. 6 years ago
David Wilson b7fe0e09f4 tests: su integration test. 6 years ago
David Wilson 3203846708 issue #239: ansible: ignore remote_tmp in new style runner. 6 years ago
David Wilson baa4e75526 tests: tidy up thread_pileup for use as a toy benchmark. 6 years ago
David Wilson 7c5bbc5168 setns: support changing user.
To match existing third party plugin.
6 years ago
David Wilson 1be03eb458 parent: change create_child interface.
To allow for additional arguments.
6 years ago
David Wilson fa4746f656 ansible: add connection delegation test targets.
For command line use only, no integration tests yet.
6 years ago
David Wilson 962ba862e9 tests: use test-targets group, not all group 6 years ago
David Wilson 86c9978e09 Ensure mod.__file__ is set; closes #210. 6 years ago
David Wilson e63ae4768e core: support Receiver.get(thread_dead=False)
For tests.
6 years ago
David Wilson 6541779dd6 tests: import Ansible file transfer benchmark 6 years ago
David Wilson 7c88e4d013 Move _DEAD into header, autogenerate dead messages
This change blocks off 2 common scenarios where a race condition is
upgraded to a hang, when the library could internally do better.

* Since we don't know whether the receiver of a `reply_to` is expecting
  a raw or pickled message, and since in the case of a raw reply, there
  is no way to signal "dead" to the receiver, override the reply_to
  field to explicitly mark a message as dead using a special handle.

  This replaces the serialized _DEAD sentinel value with a slightly
  neater interface, in the form of the reserved IS_DEAD handle, and
  enables an important subsequent change: when a context cannot route a
  message, it can send a generic 'dead' reply back towards the message
  source, ensuring any sleeping thread is woken with ChannelError.

  The use of this field could potentially be extended later on if
  additional flags are needed, but for now this seems to suffice.

* Teach Router._invoke() to reply with a dead message when it receives a
  message for an invalid local handle.

* Teach Router._async_route() to reply with a dead message when it
  receives an unroutable message.
6 years ago
David Wilson 8c3b1fcf15 ansible: disable script interpreter processing for new-style
Re: #199
6 years ago
David Wilson 2f02b5c0b1 ansible: prevent Unicode strings leaking into sys.argv
The module name comes from YAML via Jinja2.. it's always Unicode. Mixing
it into a temporary directory name produces a Unicode tempdir name,
which ends up in sys.argv via TemporaryArgv.
6 years ago
David Wilson e56608ab91 parent: don't wait for SIGTERM to complete. 6 years ago
David Wilson dc4433ace6 issue #202: ansible: forget all dependent contexts on Stream disconnect
This is a partial fix, there are still at least 2 cases needing covered:

- In-progress connections must have CallError or similar sent to any
  waiters
- Once connection delegation exists, it is possible for other worker
  processes to be active (and in any step in the process), trying to
  communicate with a context that we know can no longer be communicated
  with. The solution to that isn't clear yet.

Additionally ensure root has /bin/bash shell in both Docker images.
6 years ago
David Wilson 9fe14e841c parent: reap the child process if connection fails
For example if no response is received in :attr:`connect_timeout`
seconds, the child would be left running.
6 years ago
David Wilson e7831a801f issue #195: handle non-ASCII scripts in runner.py. 6 years ago
David Wilson 85e1f5f515 ansible: remove JobResultService, more compatible async jobs; closes #191.
And by "compatible" I mean "terrible". This does not implement async job
timeouts, but I'm not going to bother, upstream async implementation is
so buggy and inconsistent it resists even having its behaviour captured
in tests.
6 years ago
David Wilson 6ad18b6719 issue #191: move async tests to their own category 6 years ago
David Wilson e43c6c531b Mostly implement hybrid TTY/socket mode for sudo and SSH.
Presently there is still no mechanism to add :attr:`tty_stream` to the
multiplexer after connection is successful, but for now it's not
expected that anything will be logged to it anyway.

Closes #148.
6 years ago
David Wilson fca22efe90 tests: enable profile_tasks callback plugin 6 years ago
David Wilson c6284e00e9 Use subprocess to start child processes; closes #185. 6 years ago
David Wilson 1e882a72c0 tests: install virtualenv in the Docker images. 6 years ago
David Wilson b91785c9a1 tests: workaround for issue_109 6 years ago
David Wilson ce260933d9 tests: consistent play naming everywhere 6 years ago
David Wilson d827bdb848 tests: fixes to get regression/ running under vanilla Ansible 6 years ago
David Wilson b882b78d35 tests: clean up remaining reg tests
Delete some that are impossible to detect, fix up the remainder to
detect the condition they describe.
6 years ago
David Wilson aeeba54d96 tests: better regression test for issue #109 6 years ago
David Wilson f4d791662e ansible: better planner logging, try again 6 years ago
David Wilson b4bb1c5a2a tests: fix suspected readdir() ordering issue (!) 6 years ago
David Wilson 0046a3de0b tests: insert debug print for travis :( 6 years ago
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