Commit graph

352 commits

Author SHA1 Message Date
Toshio Kuratomi 41f5ce80fa Some algorithmic unittests for the apt and docker modules 2016-04-27 10:38:13 -07:00
Tegan Snyder bf0da4aa3c add centrify dzdo escalation (#15219)
add dzdo context, and test
2016-04-25 11:24:26 -04:00
Toshio Kuratomi 44e21f7062 Allow AnsibleModules to be instantiated more than once in a module
Fix SELINUX monkeypatch in test_basic
2016-04-23 14:04:45 -07:00
Toshio Kuratomi 03126f7097 Fix cut and paste error of test code 2016-04-19 10:38:44 -07:00
Toshio Kuratomi 0a31c24938 Merge pull request #15419 from nitzmahone/module_debug_arg_override
add _load_params debug overrides for module args/file passed on cmdline
2016-04-19 07:49:05 -07:00
James Cammarata 6eefc11c39 Make the loop variable (item by default) settable per task
Required for include+with* tasks which may include files that also
have tasks containing a with* loop.

Fixes #12736
2016-04-19 01:42:40 -04:00
nitzmahone 5b336832af add _load_params debug overrides for module args/file passed on cmdline
Updated python module wrapper explode method to drop 'args' file next to module.
Both execute() and excommunicate() debug methods now pass the module args via file to enable debuggers that are picky about stdin.
Updated unit tests to use a context manager for masking/restoring default streams and argv.
2016-04-18 11:06:46 -07:00
Robin Roth 49cdc565c5 remove nose.tools use 2016-04-15 19:40:08 +02:00
Robin Roth 4088aa2b4c get rid of assert_in 2016-04-15 19:30:49 +02:00
Robin Roth 692bf51fde move gen_testcase to hacking/tests
* also use json instead of pprint
2016-04-15 17:14:43 +02:00
Robin Roth 37188ea336 cleanup tests
* use nose test generator
* more comments
* move facts import inside the skipped function, fix python3 warning
2016-04-15 17:14:14 +02:00
Robin Roth 2b104fe6ad fix tests for SLES and CoreOS
* include #15230
2016-04-15 17:13:59 +02:00
Robin Roth 3c883d8a6d add testcases from refactor PR 2016-04-14 18:26:00 +02:00
Toshio Kuratomi 208ad36ce4 Merge pull request #15344 from abadger/ziploader
Ziploader "recursive imports" and caching
2016-04-13 10:27:01 -07:00
Jonathon Klobucar 7bee994e1c Fix for serial when percent amount is less than one host (#15396)
Ansible when there was a percentage that was calculated to be less than
1.0 would run all hosts as the value for a rolling update.

The error is due to the fact that Python will round a
float that is under 1.0 to 0, which will trigger the case of
0 hosts. The 0 host case tells ansible to run all hosts.

The fix will see if the percentage calculation after int
conversion is 0 and will else to 1 host.
2016-04-13 10:49:38 -04:00
Toshio Kuratomi 75546678d9 Fix unittests 2016-04-12 08:01:07 -07:00
Toshio Kuratomi dcc5dfdf81 Controller-side module caching.
This makes our recursive, ast.parse performance measures as fast as
pre-ziploader baseline.

Since this unittest isn't testing that the returned module data is
correct we don't need to worry about os.rename not having any module
data.  Should devise a separate test for the module and caching code
2016-04-12 08:01:07 -07:00
Strahinja Kustudić eed6cf5dad Adds 'ansible_check_mode' boolean magic variable
* Makes it possible to pass any options variable to VariableManager
  by changing `load_options_vars(options)` in `lib/ansible/utils/vars.py`
2016-04-08 00:26:02 +02:00
Toshio Kuratomi 4b0aa1214c Ziploader
* Ziploader proof of concept (jimi-c)

* Cleanups to proof of concept ziploader branch:

* python3 compatible base64 encoding
* zipfile compression (still need to enable toggling this off for
  systems without zlib support in python)
* Allow non-wildcard imports (still need to make this recusrsive so that
  we can have module_utils code that imports other module_utils code.)
* Better tracebacks: module filename is kept and module_utils directory
  is kept so that tracebacks show the real filenames that the errors
  appear in.

* Make sure we import modules that are used into the module_utils files that they are used in.

* Set ansible version in a more pythonic way for ziploader than we were doing in module replacer

* Make it possible to set the module compression as an inventory var

This may be necessary on systems where python has been compiled without
zlib compression.

* Refactoring of module_common code:

* module replacer only replaces values that make sense for that type of
  file (example: don't attempt to replace python imports if we're in
  a powershell module).
* Implement configurable shebang support for ziploader wrapper
* Implement client-side constants (for SELINUX_SPECIAL_FS and SYSLOG)
  via environment variable.
* Remove strip_comments param as we're never going to use it (ruins line
  numbering)

* Don't repeat ourselves about detecting REPLACER

* Add an easy way to debug

* Port test-module to the ziploader-aware modify_module()

* strip comments and blank lines from the wrapper so we send less over the wire.

* Comments cleanup

* Remember to output write the module line itself in powershell modules

* for line in lines strips the newlines so we have to add them back in
2016-04-05 11:06:17 -07:00
jpic 4985411816 Test other use-cases for PluginLoader's config 2016-04-05 14:45:40 +02:00
jpic da175d0a57 Bugfix: proper plugin configuration was reset
Before this patch, if config was ['/some/path'] then it would enter the
else block and config would be set to [].

The regression this patch fixes was introduced by 700db154.
2016-04-05 14:41:49 +02:00
James Cammarata 5fdac707fd New unit tests for #13630 fix 2016-03-28 15:54:07 -04:00
Toshio Kuratomi 52e9209491 Don't create world-readable module and tempfiles without explicit user permission 2016-03-23 09:52:19 -07:00
Toshio Kuratomi d3583108ec Fix log_invocation test on python2 with hash randomization 2016-03-23 08:01:21 -07:00
Matt Martz ad30bad14f Skip test_module_utils_basic__log_invocation until we can figure out the cause of the failure 2016-03-22 21:59:03 -05:00
Toshio Kuratomi ed9e164b80 Fix ansible_sudo_pass inventory variable so that it overrides setting of sudo password from the command line 2016-03-21 10:20:40 -07:00
Brian Coca db61e9be0c add ansible_executable inventory var
also handle the overrides appropriately
also new executable to set shell type
2016-03-17 18:54:37 -07:00
James Cammarata 8eadc1d8eb Adding more unit tests for AnsibleModule things in basic.py 2016-03-17 02:02:15 -04:00
James Cammarata 81788e627d Adding unit tests for TaskResult 2016-03-14 01:33:46 -04:00
Toshio Kuratomi 2b8a0cdddc Fix ssh connection unittests for python3.4 2016-03-09 11:14:02 -08:00
James Cammarata 9d61a6cba8 Fixing PlayIterator bugs
* Unit tests exposed a problem where nested blocks did not correctly
  hit rescue/always portions of parent blocks
* Cleaned up logic in PlayIterator
* Unfortunately fixing the above exposed a potential problem in the
  block integration tests, where a failure in an "always" section may
  always lead to a failed state and the termination of execution
  beyond that point, so certain parts of the block integration test
  were disabled.
2016-03-09 13:31:30 -05:00
James Cammarata f0d3284ead Adding more unit tests for ssh connection plugin 2016-03-08 14:50:35 -05:00
James Cammarata 2f472fd4e9 Adding start of ssh connection unit tests 2016-03-08 01:07:16 -05:00
James Cammarata 299d93f6e9 Updating unit tests for PlayIterator
This knowingly introduces a broken test, planning to fix that later.
2016-03-07 13:03:06 -05:00
James Cammarata b853e932d1 Adding unit tests for symbolic mode conversion stuff in basic.py 2016-03-01 16:41:57 -05:00
James Cammarata 18240d350c Adding a skip for the literal_eval test on py3 2016-03-01 14:33:05 -05:00
James Cammarata 0ea3a9d08d Removing tabs from test_basic.py 2016-03-01 14:15:15 -05:00
James Cammarata 1de9357c2f Attempt at cleaning up issues introduced by new basic.py unit tests 2016-03-01 14:06:58 -05:00
James Cammarata e011f52557 Expanding unit tests for module_utils/basic.py 2016-03-01 13:53:13 -05:00
James Cammarata c56e3aabfb Clean up jsonify unit test with format to remove json lib differences 2016-02-29 15:08:59 -05:00
James Cammarata 7c049c3200 Fixing up jsonify and adding unit tests 2016-02-29 14:51:23 -05:00
James Cammarata a9d25f455c More unit tests for ActionBase 2016-02-29 12:59:58 -05:00
James Cammarata e588437067 Adding some unicode params to the ActionBase module formatting test 2016-02-27 10:05:22 -05:00
Toshio Kuratomi 7cb29cdbec Workaround py2.6's StringIO 2016-02-26 17:59:00 -08:00
Toshio Kuratomi b70bf3b056 Use io.StringIO and io.BytesIO instead of StringIO.StringIO for compat with py3 2016-02-26 16:43:05 -08:00
Toshio Kuratomi c29f51804b Fix mixing of bytes and str in module replacer (caused traceback on python3) 2016-02-26 16:43:05 -08:00
James Cammarata 01d835700b Cleaning up some py version problems with ActionBase unit tests 2016-02-26 16:22:35 -05:00
James Cammarata 3518a05db6 Starting to expand unit tests for ActionBase plugin class 2016-02-26 12:47:59 -05:00
James Cammarata e02b98274b issue callbacks per item and retry fails
- now workers passes queue to task_executor so it can send back events per item and on retry attempt
- updated result class to pass along events to strategy
- base strategy updated to forward new events to callback
- callbacks now remove 'items' on final result but process them directly when invoked per item
- new callback method to deal with retry attempt messages (also now obeys nolog)
- updated tests to match new signature of task_executor

fixes #14558
fixes #14072
2016-02-23 15:07:06 -05:00
Brian Coca 6dc910c13a shell + become fixes
1 less level of shell + quoting
simplified become commands, less quote and shell
2016-02-15 13:00:13 -05:00