- In states.user.present, differentiate between None and empty list for
'groups': The empty list means the equivalent to passing '-G ""' to usermod,
i.e. remove all but the default group.
- In modules.useradd, always quote the value passed after the '-G' switch to
usermod and useradd, so they don't fail when we pass an empty string.
* Added `assertReturnSaltType` which is dictionary for non errors.
* Added `assertReturnNonEmptySaltType` which does the above and makes sure it's not empty.
* Fix `tests.integration.states.user.UserTest` which was using wrongly using `assertSaltTrueReturn` on 'user.info' calls.
* The `RedirectStdStreams` tests helper will allow to temporarily catch `stdout` and `stderr` output. Right now it's only used to **mute** the `tests.integration.runners.jobs.ManageTest.test_active()` output.
The remove command in the file module had guard, `os.path.exists`, in
front of all remove actions. That guard failed on broken symlinks, i.e.
it returned `false` even though the broken symlink existed. Since the
remove actions are properly guarded without the `os.path.exists` guard,
this commits removes it. Now the remove command will also remove broken
symlinks.
* Implement `SaltReturnAssertsMixIn.assertSaltNoneReturn` used in `tests.integration.states.cmd`.
* Migrate `tests.integration.states.cmd` to use `SaltReturnAssertsMixIn`.
* Expose what's happening in `integration.states.user.UserTest.test_user_if_present_with_gid()`.
* Update code that was using the old `SaltReturnAssertsMixIn`.
* Do proper type checking for salt calls, ie, a dict should be returned, if not, it's a failure, usually errors come as lists, show that to the user.
* Iterate through the salt call parts to make sure result is true, and if not, fail showing the part comment.
* In `salt.modules.pip.install()` we first check if file is already cached(in case being called from `salt.states.virtualenv.managed()`), if it's not, then try to cache it.
* If requirements and `runas` is passed, since `salt.fileclient`'s cache needs to be private, we create a temporary file with the contents of the requirements file, owned by the `runas` user, which then gets passed to the pip command.
* Always delete the user, even if test(`integration.states.virtualenv.VirtualenvTest.test_issue_1959_virtualenv_runas`) fails.
* Minor PEP-8.
* Created a mix which tests for the required assertion(True/False) and in case of a failure, shows salt comment kwarg in the raised assertion error so we know what was the original(salt's) failure.
* We basically copied subprocess from python 2.7 and import that one instead of the python 2.6 subprocess to run the tests. Since we import it under a different name, there should be no issues with the remaining of salt's source importing the regular subprocess module.
* When introducing the "Don't assume!" changes I also assumed that there were always more than one argument from the shell. Expanded the testcase to include this check.
* When `re.search`'ing, do a `re.MULTILINE` search. Not all matches happen on first line, specially using the `BufferedReader`.
* PEP-8 fixes.
* Removed `rowname` from `salt.utils.mysql_to_dict()` since it was not being used.
* Only instantiate a `LocalClient` on a test if one is required.
* Try to precipitate garbage collection on our minions connect and sync multi-processes.
* Raised max open files by 1024 since running in a vagrant machine 2048 was not enough, though, I think travis-ci defaults to a higher value.
* Wait a bit longer on the events testing.
* Separated the initial minions connected and minions synced into two different events and functions. Also corrected the `if` expected value when a timeout occurs.
* Always remove the repository directory.
* When testing recursive with git 1.7.9.5, we cannot test for a directory because it's a plain file with the contents:
gitdir: /tmp/salt-tests-tmpdir/salt_repo/.git/modules/vendor/modules/js/receiptverifier
* don't overwrite or delete when the force option is not true
* when the user `runas` doesn't have permission to create a directory in the
parent directory of `target` or `name`, the directory may be created in
preparation of git. So, don't remove the empty directory before cloning.
* the force option still removes the directory even if it is empty
* ensure submodules are initiated recursively everywhere for consistency
* catch all module calls for consistency
* tests to test
Rewrite file.recurse state module to leverage existing file.managed and file.directory
modules to do the heavy lifting. This removes code duplication and will make
templates available for file.recurse.
These improvements will be visible to the end-user:
- All files in directory can now be templatized
- destination directory is no longer created in test mode
- When clean mode is enabled, the module is capable of replacing
existing files with directories and vice versa
This one is pretty silly; hopefully the regex match is still specific
enough to be a good test.
% bash -c '/tmp/someenv/bin/pip install something'
bash: /tmp/someenv/bin/pip: No such file or directory
% zsh -c '/tmp/someenv/bin/pip install something'
zsh:1: no such file or directory: /tmp/someenv/bin/pip
While running the tests within a VirtualBox(vagrant) machine, if the salt source is mounted using shared folders, any tests involving hard links WILL fail. Any tests involving symlinks, can be made to work by setting some properties on the VirtualBox shared folder. By moving the tests `tmp` directory to `tempfile.gettempdir()` we avoid this false test case errors.
Previously using `state.template` or `state.template_str` would not be checked/rendered into proper formatting resulting in some templates not being correctly executed. For example, the following template worked:
```
/tmp/issue-2068-template-str:
virtualenv:
- managed
- no_site_packages: True
- distribute: True
pep8-pip:
pip:
- installed
- name: pep8
- bin_env: /tmp/issue-2068-template-str
- mirrors: http://testpypi.python.org/pypi
- require:
- virtualenv: /tmp/issue-2068-template-str
```
as opposed to the following which did not work:
```
/tmp/issue-2068-template-str:
virtualenv.managed:
- no_site_packages: True
- distribute: True
pep8-pip:
pip.installed:
- name: pep8
- bin_env: /tmp/issue-2068-template-str
- mirrors: http://testpypi.python.org/pypi
- require:
- virtualenv: /tmp/issue-2068-template-str
```
The dotted names should be converted into lists for example, which was the problems with the two examples above.
* In order to check if something went wrong while running the various pip commands using the command module, we need to know, at least, the return code, this way we can report the failure.
* `salt.modules.pip.uninstall()` now returns the `cmd.run_all` `dict` instead of a list of strings. **This breaks previous behaviour**.
* Added a test case for `salt.modules.pip.uninstall()` changes.
Some packages, carbon and graphite-web for example, install their packages to a specific root, using a `virtualenv` or not. `pip freeze` won't show those packages as installed.
* Moved the state `pip.installed` tests to it's own module, the correct one.
* Added a test which checks for the presence of errors while running `pip.installed` introduced while fixing #2028
* `salt.states.pip.installed()` now keeps a reference to the output of the `__salt__['pip.install']()` call. The reason for this is that we need to know and pass along any information about an eventual error when running that call. This is now done in addition to the old behaviour.
* Add some tests which triggered the issue.
The generation of keys does not involve all the checks required to accept/deny/list keys. This code change allows:
* regular users to generate keys
* `/etc/salt` and `/var/log/salt` not to exist or not to be readable by the current user
It also does not check for a running master. We have now lowered the requirements to run this script just for generating keys.
* Test both master and minion events firing
* Allow targeting the minions in `tests.integration.ModuleCase.run_function()`
* The above item allows to also test events firing using `tcp` as `ipc_mode` which is being used by the tests `sub_minion`
* `salt.modules.file.contains()`, `salt.modules.file.contains_regex()`, `salt.modules.file.contains_glob()` and `salt.utils.find` now do the searching/matching against chunks of data; using defaults, 32KB chunks of data in files; instead of searching/matching line by line.
* Based on the above changes `salt.states.file.append()`, when checking if the text to append is already present, now uses `salt.modules.file.contains_regex()` in order to match spanning multiple lines ignoring the addition/deletion of white-space or new lines, except inside commas.
* The regex used on the above item is built at runtime using `salt.utils.build_whitepace_splited_regex()`, just feed the text to it and you'll get back the proper regex to the matching/searching on, for example `salt.modules.file.contains_regex()`.
* Added tests for all this code.
Corey Quinn reported a issue where __grains__['os_family'] returned a
KeyError. This commits adds a check to the grains module test to ensure
os_family is present.
* `salt-call` default outputter returned from `salt.output.get_printout()` was `None` and `None` isn't callable neither outputs anything useful. In this case, the fault Outputter should be used.
* `get_printout()` also tested for `txt_out` which now is, in the cleaned up parsers, `text_out`. Fixed.
On the parsers cleanup branch, I though about making the available options as equal as possible. Since the log_file setting for the master and the minion could be separately set, I made the logfile option for the key also log_file. Yet, since there's no key specific config file, it shares master, one could only specify the log_file settings from the cli, it could not be hardcoded on the config file, unless, we made a separate config file just for key.
So, in order to reduce required changes, and keep it all as backwards compatible as possible, the key log file options is now, once again, `--key-logfile` which will allow us to hardcode it in the masters config file as `key_logfile`.
This will also, hopefully make travis behave better too.
When using `--no-clean` while running tests, some files/dirs still need to be removed, if not, test will fail. This commit tries to addresses those issues.
Reused the output options and logging setup mix-ins.
Fixed a bug introduced in previous commit on `salt.utils.parsers.SaltCPOptionParser._mixin_after_parsed()`, function does not accept any arguments.
For this, the timeout mix-in and both the target and output parser group mix-ins were re-used. Way less code and logic to keep track of.
Added a simple test for this binary too.
* Created 2 mix-ins as option groups, the output options and the target options. This will allow adding some explanatory text besides separating these options from the parser's main options.
* All options on the parser, including the grouped options are now merged to the loaded configuration which will latter get passed on.
* Also created the timeout mix-in which will be used in other binaries.
While performing integration tests, the "mockbin" directory is
inserted in the beginning of the $PATH environment variable.
This effectively means that every file placed in this directory will be
executed instead of real one from the system, which opens up the
opportunity to write more complex integration tests.
At the time the only wrapper for "su" command (used in "cmdmod") is
placed there.
Defined "integration.run_tests()" function which can be used to execute
a particular integration test case. Existing bolerplate code in modules
and states tests is replaced with following lines:
if __name__ == '__main__':
from integration import run_tests
run_tests(TestCaseName)
Typical usecase could look like this:
python integration/modules/pip.py --no-clean -vv
--no-clean option speeds up repeating test execution by skipping the cleanup
process before and after testing.
Typical use case command could look like
./runtests.py -vv --no-clean --name integration.modules.ssh
I don't really like doing this, but `/tmp/subsalttest dir` is already
hardcoded in other places for running tests.
Without this, when running tests under a mounted Vagrant drive,
`ssh-keygen` doesn't have permission to create the symlink for
known_hosts to known_hosts.old, causing a test to fail.
```
======================================================================
FAIL: test_rm_known_host (integration.modules.ssh.SSHModuleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/vagrant/tests/integration/modules/ssh.py", line 143, in
test_rm_known_host
self.assertEqual(ret, 'add')
AssertionError: 'exists' != 'add'
```
`link /vagrant/tests/integration/tmp/known_hosts to
/vagrant/tests/integration/tmp/known_hosts.old: Operation not permitted`