The Depends decorator allows you to optionally remove functions if sepecific globals/modules don't exist. This is particuarly helpful in larger scale deployments where some functions of the module work everywhere, but others require (for example) a service to be installed. This way you can avoid having to try/except all over the module to only load certain functions etc.
Add ability to specify timeouts for arbitrary commands.
If timeout is reached, subprocess is sent sigterm, and later sigkill
if it still exists. Issue #5322
Support running supervisor from a virtualenv/custom path.
Support custom supervisor config file.
Create real tests using a virtual environment.
Supervisor state:
Fix restart when process is already running.
Support restart on watch.
Create real tests using a virtual environment.
Affected functions:
- `pip.install`
- `pip.installed`
- `virtualenv.managed`
When using `runas` in conjunction with a local-filesystem `requirements` file with these functions,
`pip.install` will create a temporary copy of the requirements file,
then change ownership of that file to the `runas` user.
The purpose of this is to avoid file permission errors when accessing the original requirements file.
However, this breaks when that file has a "-r otherfile.txt" line.
In these cases, set `no_chown` to `True`.
The original path to the requirements file will be kept,
and other requirements files included from the top-level file will be correctly found.
* fixed invalid assumption in file module tests that all linux platforms have
groups with the same name as users (joe:joe etc.). But for
example ArchLinux has only joe:users.
* file module tests now loads user's canonical group name from pwd and
grp python module instead.
I don't recall linux sysctl output being as messy as what I see on 10.8, so this module still needs some work I think to prevent it from choking on the odd 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.
* 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.
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.
* 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.
* 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.
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
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`
In addition to traditional file system path test discovery it is
useful to run a test by stating it's dotted python path. For example,
this will only run the cmdmod integration tests from the
module suite::
$ runtests.py -n tests.integration.modules.cmdmod
This caused problems when adding another host and you'd end up with
entries such as:
```
192.168.1.2\t\thost2\thost2alias192.168.1.1\t\thost1\thost1alias
```
Test updated to reflect.
Given a state entry like the following:
```
host-staging-web:
host:
- present
- ip: 10.102.130.100
- names:
- staging-web.fqdn.com
- staging-web
- alt-staging-hostname
```
You'd end up with three different entries in your hosts file:
```
10.102.130.100 staging-web.fqdn.com
10.102.130.100 staging-web.fqdn.com staging-web
10.102.130.100 staging-web.fqdn.com staging-web alt-staging-hostname
```
This corrects it by removing the previous line before appending the
newly crafted on, and adds tests to prove it.
Integration tests requiring a salt master and daemon were seperated
from pure unit tests. For now both are run with runtest.py. In
the future it could take arguments for which type of tests to run.