Commit Graph

12490 Commits

Author SHA1 Message Date
Bo Maryniuk
2f5b133149 Fix unit test to attempt remove PID file as root 2018-02-12 18:54:23 +01:00
Bo Maryniuk
3a8e43f806 Add tear-down method 2018-02-12 18:54:23 +01:00
Bo Maryniuk
7a0e3e983c Use pytest 2018-02-12 18:54:23 +01:00
Nicole Thomas
bc13ff8b48
Merge pull request #45941 from terminalmage/issue45679
Fix incorrect translation of docker port_bindings -> ports
2018-02-12 11:28:36 -05:00
Nicole Thomas
d3a8f06911
Merge pull request #45927 from rallytime/utils-paths
Update old utils path to new path for which() function
2018-02-09 17:30:51 -05:00
Nicole Thomas
c0e01cea05
Merge pull request #45950 from rallytime/bp-45902
Back-port #45902 to oxygen.rc1
2018-02-09 17:30:17 -05:00
Nicole Thomas
570bbc9cd7
Merge pull request #45931 from gtmanfred/publisher
Fix publisher_acl for oxygen
2018-02-09 15:52:49 -05:00
Erik Johnson
89cbd72a0d
Don't try to sort ports when translating docker input
This sorting was done mainly for the benefit of the test suite, but
Python 3 will raise an error when you try to sort a mixture of int and
tuple types, so sorting breaks down when there are UDP ports.

Instead, this just leaves them as an unsorted list when passed to the
API, and the test suite does the sorting before the assertEqual.
2018-02-09 11:33:10 -06:00
Erik Johnson
29d0271b73
Don't try to sort ports when translating docker input
This sorting was done mainly for the benefit of the test suite, but
Python 3 will raise an error when you try to sort a mixture of int and
tuple types, so sorting breaks down when there are UDP ports.

Instead, this just leaves them as an unsorted list when passed to the
API, and the test suite does the sorting before the assertEqual.
2018-02-09 11:14:03 -06:00
Erik Johnson
0ff41c5835
Add regression test for issue 45893 2018-02-09 11:40:22 -05:00
rallytime
9c49c8d47c
Remove extra patch 2018-02-09 09:41:35 -05:00
rallytime
e04e7bdfc9
Remove extra patch 2018-02-09 09:40:22 -05:00
Ollie Armstrong
f8b8e072f6
Resolve linting errors 2018-02-09 14:09:17 +00:00
Nicole Thomas
861d5e20fb
Merge branch 'develop' into zabbix-inventory 2018-02-09 08:57:09 -05:00
Nicole Thomas
f4acb18d4b
Merge pull request #45912 from gtmanfred/vmware
add test to verify vmware clusters can be used in vmware cloud
2018-02-09 07:15:51 -05:00
Erik Johnson
9cd47b39dd
Fix incorrect translation of docker port_bindings -> ports
The logic which ensures that we expose ports which are being bound,
even when not explicitly configured, was done incorrectly. UDP ports
were being passed to the API as '1234/udp' instead of (1234, 'udp').
This results in the port not being exposed properly.

The logic has been corrected. Additionally both the "ports" input
translation function, as well as the post-processing code (where the
port numbers configured in port_bindings were being added) both
contained code to "fix" any ports which were configured using
'portnum/tcp', as these must be passed to the API simply as integers. To
reduce code duplication, this normalization is now only performed at the
very end of the post-processing function, after ports have been
translated, and any missing ports from the port_bindings have been
added.

The unit test for the port_bindings input translation code, which was
written based upon the same incorrect reading of the API docs that
resulted in the incorrect behavior, have been updated to confirm the
(now) correct behavior. The unit test for the ports input translation
code has been updated to reflect the new normalization behavior.

Finally, an integration test has been added to ensure that we properly
expose UDP ports which are added as part of the post-processing
function.
2018-02-08 23:23:43 -06:00
Erik Johnson
f35d9f6fef
Fix incorrect translation of docker port_bindings -> ports
The logic which ensures that we expose ports which are being bound,
even when not explicitly configured, was done incorrectly. UDP ports
were being passed to the API as '1234/udp' instead of (1234, 'udp').
This results in the port not being exposed properly.

The logic has been corrected. Additionally both the "ports" input
translation function, as well as the post-processing code (where the
port numbers configured in port_bindings were being added) both
contained code to "fix" any ports which were configured using
'portnum/tcp', as these must be passed to the API simply as integers. To
reduce code duplication, this normalization is now only performed at the
very end of the post-processing function, after ports have been
translated, and any missing ports from the port_bindings have been
added.

The unit test for the port_bindings input translation code, which was
written based upon the same incorrect reading of the API docs that
resulted in the incorrect behavior, have been updated to confirm the
(now) correct behavior. The unit test for the ports input translation
code has been updated to reflect the new normalization behavior.

Finally, an integration test has been added to ensure that we properly
expose UDP ports which are added as part of the post-processing
function.
2018-02-08 23:22:43 -06:00
twangboy
29912adc15
Move the test_rehash test to test_win_functions 2018-02-08 17:44:30 -07:00
Gareth J. Greenaway
80c0636ccd
A couple updates and changes 2018-02-08 16:04:59 -08:00
Gareth J. Greenaway
a3b052ec92
Adding a flag to various cmdmod functions to allow overriding the retcode that is returned. This is useful when a command will return a non-zero retcode but the command is still considered successful. 2018-02-08 16:04:58 -08:00
Christian McHugh
25467df447 support python2 and 3 2018-02-08 23:02:12 +00:00
Christian McHugh
40686adf21 lint cleanup 2018-02-08 22:52:21 +00:00
Daniel Wallace
dc91055059
Revert "Separates key_dir from cache_dir, The key files (i.e. '.root_key', '.sudo_...') must not be shared with other masters."
This reverts commit 20bf4eed1d.

This change breaks publisher_acls.

1) The key_dir's permissions are controlled by `permissive_pki_access` which is
   not required by publisher_acls.  By default, it is also changed back to 700
   each time that the salt-master restarts, so it will have to be chmodded each
   time.
2) The default directory for these keys is changed, which will break a lot of
   users publisher_acls setups on an upgrade to Oxygen, and require them to go
   back in to chmod new directories.

I was going through and switching out the key dir to default back to
/var/cache/salt/master, and allow it to be changed, and also be able to specify
that it is a sensitive dir, but once I ran across the `permissive_pki_access`
stuff, I thought it was better to just revert this change and try again against
Fluorine, since we do not have a lot of tests in this area around publisher_acl.
2018-02-08 12:55:25 -07:00
rallytime
a16ea53430
Update old utils path to new path for which() function 2018-02-08 14:38:25 -05:00
rallytime
34ecdffa71
Replace old utils paths with new paths 2018-02-08 14:23:22 -05:00
Adam Friedman
1a75786b5a
Fix linter warnings.
saltstack/salt#45884
2018-02-09 05:16:59 +11:00
Daniel Wallace
3e093ba022
fix pylint 2018-02-08 09:37:11 -07:00
rallytime
255cc7ffb0
Merge branch 'oxygen' into 'develop'
No conflicts.
2018-02-08 11:24:56 -05:00
rallytime
d80547e0b8
Merge branch '2017.7' into 'oxygen'
Conflicts:
  - salt/fileclient.py
  - salt/grains/disks.py
  - salt/modules/cmdmod.py
  - salt/state.py
  - salt/states/file.py
  - salt/utils/gitfs.py
  - salt/utils/win_functions.py
  - tests/integration/modules/test_state.py
  - tests/unit/cache/test_localfs.py
2018-02-08 11:23:31 -05:00
Gareth J. Greenaway
6d1018bd18
Porting PR #45844 to Develop branch. Doing this manually as a lot of the layout of utils/schedule.py has changed from Oxygen to Develop 2018-02-08 07:26:49 -08:00
Erik Johnson
3f42a58363
Force Salt's YAML loader to load all strings as unicode types
This reduces the likelihood that non-unicode strings make their way into
Salt and cause str/unicode mismatches resulting in UnicodeDecodeErrors.
2018-02-08 09:04:49 -06:00
Nicole Thomas
c88352a26f
Merge pull request #45844 from garethgreenaway/track_scheduled_next_time_skipped_jobs
[oxygen] Track the next scheduled fire time and when jobs are skipped.
2018-02-08 09:12:23 -05:00
Nicole Thomas
7e0cd38066
Merge pull request #45892 from terminalmage/issue45473
Add unit tests for gitfs features new to Oxygen
2018-02-08 08:50:10 -05:00
Daniel Wallace
56c5a333cd
add test to verify clusters
This test just double checks that the get_mor_containers is called twice when
trying to use a Cluster, and once if a datastore is specified.
2018-02-07 17:03:13 -07:00
Adam Friedman
a2bc155c73
Use __utils__['cloud.'] instead of salt.cloud.utils.
saltstack/salt#45884
2018-02-08 08:39:33 +11:00
Adam Friedman
de26b03e2c
Fix copy/paste bug in dimensiondata provider integration test.
saltstack/salt#45884
2018-02-08 08:39:07 +11:00
Adam Friedman
6b1b6be427
Add integration tests for dimensiondata cloud provider.
saltstack/salt#45884
2018-02-08 08:38:58 +11:00
Daniel Wallace
e892f75660
fix digital ocean tests 2018-02-07 14:04:37 -07:00
Christian McHugh
6a662c2cef add usergroup tests 2018-02-07 20:50:40 +00:00
Erik Johnson
a0586748b6
Remove unused imports 2018-02-07 14:44:15 -06:00
Erik Johnson
9d200efc26
Add regression test for issue 45893 2018-02-07 14:32:59 -06:00
Gareth J. Greenaway
09d960c0cb
Updating utils/schedule.py to be able to track when jobs are skipped because of the max_running parameter. This change moves that check out of handle_func and moves it to it's own function. Also updated skip tests to include a test that _skip_reason is included in the results when a job is skipped. 2018-02-07 11:39:10 -08:00
Gareth J. Greenaway
b23e5a7db2
Updating utils/schedule.py to be able to track when jobs are skipped because of the max_running parameter. This change moves that check out of handle_func and moves it to it's own function. Also updated skip tests to include a test that _skip_reason is included in the results when a job is skipped. 2018-02-07 11:39:09 -08:00
Nicole Thomas
a309933104
Merge pull request #45885 from terminalmage/issue45845
Catch and report YAML errors in jinja load_yaml
2018-02-07 14:08:48 -05:00
Ollie Armstrong
b2d5227c27
Remove unused import 2018-02-07 18:33:37 +00:00
Ollie Armstrong
5c0fcfdfb6
Add tests for salt.modules.selinux.fcontext_get_policy 2018-02-07 18:29:36 +00:00
Erik Johnson
fb05654b71
Add unit tests for new Oxygen gitfs features
Also expand unit tests to test both GitPython and pygit2
2018-02-07 12:00:44 -06:00
Erik Johnson
a0f7eec7e5
Work around upstream pygit2 bug affecting unicode refs
This adds a workaround for a bug fixed upstream on 2 Feb 2018, which
caused a branch or tag containing a unicode character to raise a
UnicodeDecodeError. Additionally, it changes how we handle version
analysis in salt.utils.gitfs. We should be using the LooseVersion from
salt.utils.versions instead of distutils.version.
2018-02-07 12:00:44 -06:00
Nicole Thomas
ec590aff87
Merge pull request #45834 from terminalmage/cmdmod-unicode-compat
2 unicode-compatibility fixes for cmdmod.py
2018-02-07 09:51:14 -05:00
Erik Johnson
b4e24a69e6
Move get_context to salt.utils.stringutils
This avoids circular dependencies when salt.utils.jinja (which is
imported by salt.utils.templates) needs to use get_context()
2018-02-07 02:09:56 -06:00
Erik Johnson
22c676ce57
Add option to cmdmod funcs to specify the output encoding 2018-02-07 02:01:55 -06:00
Erik Johnson
6cef37f310
2 unicode-compatibility fixes for cmdmod.py
First, `shlex.split()` will raise an exception when passed a unicode
type with unicode characters in the string. This modifies our
`shlex.split()` helper to first convert the passed string to a `str`
type, and then return a decoded copy of the result of the split.

Second, this uses our `to_unicode` helper to more gracefully decode the
stdout and stderr from the command. Unit tests have been added to
confirm that the output is properly decoded, including instances where
decoding fails because the return from the command contains binary data.
2018-02-07 02:01:55 -06:00
Daniel Wallace
57ab20308e
fix msazure cloud test 2018-02-06 14:50:20 -07:00
Daniel Wallace
f88ff75c19
fix gce tests 2018-02-06 13:27:11 -07:00
Nicole Thomas
07f673aef5
Merge branch 'develop' into issue_44297 2018-02-05 10:09:05 -05:00
Nicole Thomas
c2ffacdb5d
Merge pull request #45807 from rallytime/merge-develop
[develop] Merge forward from oxygen to develop
2018-02-05 10:04:28 -05:00
Nicole Thomas
900aadcd67
Merge pull request #45721 from garethgreenaway/44978_show_duration_when_no_state_run
[2017.7] Ensure duration and start time exist
2018-02-05 09:59:32 -05:00
Nicole Thomas
80a2d009b4
Merge pull request #45517 from kstreee/fix-mkdir
Fixes base dir making logic to ensure not raising the exception when base directory already exists.
2018-02-05 09:56:22 -05:00
Christian McHugh
041df80e47 add unit tests for zabbix user and host_inventory methods 2018-02-04 22:45:30 +00:00
Volodymyr Samodid
de6c8e4848
fix test_create for mdadm module 2018-02-02 21:58:29 +02:00
Nicole Thomas
becfb56ed0
Merge pull request #45786 from isbm/isbm-localectl-use
Multiple bugfixes for localemod
2018-02-02 09:09:22 -05:00
kstreee
24d41f2451
Fixes base dir making logic to ensure not raising the exception when base directory already exists. 2018-02-02 09:55:08 +09:00
Nicole Thomas
543ef6d8a4
Merge pull request #45703 from terminalmage/path
Improve/remove PATH environment modifications
2018-02-01 16:07:16 -05:00
Nicole Thomas
7d5cf806f9
Merge pull request #45772 from terminalmage/decode-all-the-things
Decode payloads on Python 2 to preserve unicode in jobs and fileclient reqs
2018-02-01 16:06:50 -05:00
Benjamin Drung
b6181b5ed6 Fix Unicode tests when run with LC_ALL=POSIX
When running the unit tests with the locale set to POSIX, some Unicode
tests fail:

$ LC_ALL=POSIX python3 ./tests/runtests.py --unit
[...]
======================================================================
ERROR: test_list_products (unit.modules.test_zypper.ZypperTestCase)
[CPU:0.0%|MEM:73.2%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/modules/test_zypper.py", line 236, in
test_list_products
    'stdout': get_test_data(filename)
  File "tests/unit/modules/test_zypper.py", line 53, in get_test_data
    return rfh.read()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
828: ordinal not in range(128)

======================================================================
ERROR: test_non_ascii (unit.templates.test_jinja.TestGetTemplate)
[CPU:0.0%|MEM:73.2%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/templates/test_jinja.py", line 341, in test_non_ascii
    result = fp.read()
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5:
ordinal not in range(128)

======================================================================
ERROR: test_non_ascii_encoding
(unit.templates.test_jinja.TestGetTemplate)
[CPU:0.0%|MEM:73.2%]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/unit/templates/test_jinja.py", line 303, in
test_non_ascii_encoding
    fp_.read(),
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5:
ordinal not in range(128)
----------------------------------------------------------------------

Therefore open files in binary mode and explicitly decode them with
utf-8 instead of their default locale.
2018-02-01 19:24:23 +01:00
Erik Johnson
01194d6cdd
Update syslog_ng tests to reflect change in PATH behavior 2018-02-01 10:54:09 -06:00
Erik Johnson
1b78e49e1c
win_path: Do not normalize path to lowercase
This removes the lowercase normalization and handles case-insensitive
path matches. It also combines local path and system path inspection
into a single helper function in both add() and remove(), for simplicity.

Additionally, the add/remove unit tests have been rewritten to test
a wider array of use cases.
2018-02-01 10:54:09 -06:00
Erik Johnson
1b5c45a1fd
Add support for negative indexes 2018-02-01 10:54:09 -06:00
Erik Johnson
52ebc31f3d
Add comment regarding PATH handling 2018-02-01 10:54:09 -06:00
Erik Johnson
19d75b8eb9
Improve/remove PATH environment modifications
- `salt/modules/rbenv.py`: Forces use of str types in the custom env dict
  passed to `cmd.run_all`.
- `salt/modules/syslog_ng.py`: Ditches janky PATH munging in favor of
  the stable and long-existing support built into cmdmod.py
- `salt/modules/win_path.py`: Forces use of str types in path
  modification functions.
- `salt/states/win_path.py`: Completely rewritten. Duplicated code from
  the execution module removed in favor of calls to the execution
  module. Tests junked and 14 new tests written.
- `salt/utils/path.py`: The `which()` function was mistakenly modified
  in 20033ee to inject the directories in the POSIX default path into
  the PATH environment variable (even for Windows!). We never used the
  PATH to find the executables, we simply cycled through the dirs one by
  one and looked for an executable file matching the named path. The
  code that modifies the path is now removed. In addition, `which()` now
  uses `salt.utils.path.join()`, which gracefully handles mismatched
  str and unicode directory components to prevent decode errors.
  `join()` has also been simplified to use `salt.utils.data.decode()` to
  normalize directory components to unicode.
2018-02-01 10:54:09 -06:00
Erik Johnson
99de368afa
PY2: Fix system.set_computer_desc and set_computer_desc when desc is unicode
Both string_escape and unicode_escape don't like unicode content. This
scraps the escape encoding and simply does a series of string
replacements to disabmibguate quotes, newlines, and tab characters.
2018-02-01 10:30:12 -06:00
Erik Johnson
e0f4f70569
Update test to reflect type change due to unicode_literals 2018-02-01 10:30:12 -06:00
Bo Maryniuk
9e86a7d5f6 Lintfix: E8303 -- too many empty lines 2018-02-01 12:58:15 +01:00
rallytime
c031a4b535
Merge branch 'oxygen' into 'develop'
Conflicts:
  - salt/utils/cloud.py
2018-01-31 13:15:40 -05:00
Bo Maryniuk
5af6f147e6 Add unit test on set_locale for error handling when update-locale is not installed 2018-01-31 15:55:34 +01:00
Bo Maryniuk
4131f2e964 Fix unit test (mock everything!) 2018-01-31 15:52:36 +01:00
Bo Maryniuk
222b929d92 Add unit test for dbus locale parser which does not matching the results. 2018-01-31 15:42:32 +01:00
Bo Maryniuk
d2dcf9986e Add unit test for dbus locale parser matching the results. 2018-01-31 15:36:51 +01:00
Nicole Thomas
3cad6affbb
Lint: Add extra blank line 2018-01-31 09:29:33 -05:00
Bo Maryniuk
9468f7d91e Flatten the code 2018-01-31 13:28:07 +01:00
Bo Maryniuk
eeb08405f4 Remove old-style camel assertion in favour of PyTest built-in assertions 2018-01-31 13:24:47 +01:00
Bo Maryniuk
ec77e92dcf Move unit test test_avail to py.test 2018-01-31 13:20:46 +01:00
Bo Maryniuk
a4e44c40f9 Add unit test for gen_locale is handling error while calling not installed localedef on Suse os-family. 2018-01-31 13:17:53 +01:00
Bo Maryniuk
3d4e44e18c Add unit test gen_locale is calling localedef on Suse os-family. 2018-01-31 13:14:35 +01:00
Bo Maryniuk
16419ec6d3 Add check on gen_locale for Suse-specific path 2018-01-31 13:00:12 +01:00
Bo Maryniuk
58dde2ccbc Add unit test for gen_locale on Suse os_family with invalid locale 2018-01-31 12:54:42 +01:00
Bo Maryniuk
00f2695c79 Lintfix W1699: Python3 incompat 2018-01-31 10:19:04 +01:00
Bo Maryniuk
d423df4ded Lintfix E8301: expected 1 blank line 2018-01-31 10:17:44 +01:00
Bo Maryniuk
ea0b2e171f Lintfix: E8302, PEP8 expected two blank lines 2018-01-31 10:17:04 +01:00
Gareth J. Greenaway
59fc7fcb34
Bumping up the timeout for integration.cloud.providers.test_ec2 tests. 2018-01-30 15:01:36 -08:00
Bo Maryniuk
13087b2062 Fix unit test: capture log message and redirect it to the test assertion 2018-01-30 21:14:04 +01:00
Bo Maryniuk
8a9dacc30b Fix unit tests for HAS_DBUS removal 2018-01-30 21:05:00 +01:00
Bo Maryniuk
56f5645a09 Add unit test for localectl on arbitrary structure parser 2018-01-30 20:59:23 +01:00
Bo Maryniuk
5af33fbb0d Add unit test for localectl output parse on broken content 2018-01-30 20:51:23 +01:00
Bo Maryniuk
bcd04fa0ab Add log call verification 2018-01-30 20:47:26 +01:00
Bo Maryniuk
4f39075883 Add unit test for calling localectl parser on an empty output 2018-01-30 20:47:04 +01:00
Bo Maryniuk
a5d3098e9e Add unit test for localectl output status parser when no systemd installed 2018-01-30 20:38:33 +01:00
Bo Maryniuk
b4b0ea7d58 Add unit test for localectl output status parser 2018-01-30 20:36:17 +01:00
Bo Maryniuk
ec4ef24cd3 Add unit test for set_locale on unknown system 2018-01-30 19:16:15 +01:00
Bo Maryniuk
98c5ed8ef6 Remove an old unit test for set_locale 2018-01-30 19:15:54 +01:00