These dunders are already being mocked appropriately below in the test, so we
don't need to define them in the test module's namespace.
The global definitions here were conflicting with the globals defined in
`saltmod_test.py`, and causing the following stacktrace in the test suite:
```
Traceback (most recent call last):
File "/root/SaltStack/salt/tests/unit/saltmod_test.py", line 71, in test_state
self.assertDictEqual(saltmod.state(name, tgt, highstate=True), test_ret)
File "/root/SaltStack/salt/salt/states/saltmod.py", line 252, in state
masterless = __opts__['__role'] == 'minion' and \
KeyError: '__role'
```
The type of the ``path`` value changed in #38188.
This updates the type in the unit test, as well as rearranges some
of the imports to be more standardized with ``ensure_in_syspath``.
A recent PR of mine removed the logic in symlink_list and fell back to
the cached file list generated in _file_lists(). However, this code
dates back from before the fileserver backends' symlink_list() functions
were modified to return a dict mapping links to their destinations.
This fixes the code in _file_lists() so that it returns the correct
data. It also fixes the fact that '.' was showing up in the dir list
produced by _file_lists(), and updates the associated integration test
to include the cachedir in the mocked opts.
* Typo in comment
* First convert to string if not already a string. Then to bytes under Py3.
The reason being that jids from the CLI, at least the one fed in
integration.runners.jobs.ManageTest.test_loopup_jid is loaded as an
integer, and, while the Py2 code converts JIDs to strings, under Py3, we
assume JID's are already strings.
* Mark tests which require root permissions to run
* Allow declaring that the function IS a class method.
```
Python 3.5.3 (default, Jan 21 2017, 00:29:12)
[GCC 6.3.1 20170109] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> class Foo:
... def bar(self):
... print('bar')
...
>>> import inspect
>>> inspect.ismethod(Foo.bar)
False
>>> inspect.ismethod(Foo().bar)
True
```
On Python 2, `inspect.ismethod` returns `True` for bound and unbound
methods while on Python 3 it only returns `True` for bound methods.
The explicit `is_class_method` is to avoid instantiating the class just
to get the function signature.
* Always decode responses to the Python version native string implementation
* Just compare the objects as matching list.
Asserting same item count doesn't make that much sense.
* Py3 compatibility
* Fix saltnado tests under Py3
* Python 3 compatibility
* Show me the full traceback
* Revert "Convert fileserver data from bytes to strings"
This reverts commit e53972f8c6.
* Revert "Under Py3, we get `bytes` when using the roots backend directly"
This reverts commit 9f73b240c1.
* Convert from bytes to str if not a binary file
* Py3 compatibility fixes.
Convert file contents from bytes to string if not a binary file
The previous way this test was written was over-mocking some of the
state returns as well as tested and asserted against incorrect
behavior as shown in issue #39255. (The test asserted that a return
of '' from the call to _checkblk() was correct, which was hiding a
bug as noted in #39255 and fixed in #39272.)
This prevents git_pillar certificate errors. Additionally, sometimes
/dev/rtc becomes unresponsive which leads the ``hwclock --compare``
command to spin indefinitely, ultimately causing the entire test run to
fail. This changeset uses a SIGALRM handler to abort the hwclock command
if no output is seen within 3 seconds and try a second time. If it times
out the second time as well, then an error will be logged but it will
not be fatal to the test (or hang it indefinitely).
In #39060, some tests were added to check for the hardware clock
getting reset when possible. The test attempted to gate the test
when access to the hardware clock was impossible, but the check
wasn't quite right and caused problems with the resulting tests.
This change makes the `has_settable_hwclock()` function public
in order to make the test gate work correctly. This function
could also be useful at the CLI level.
When running `self.run_function('status._has_settable_hwclock()')`
from the test suite, the return is a string noting that the
function is unavailable. This change allows for the `if not` check
to evaluate the return of the function.
* Add config params for custom refspecs
* Add exceptions for errors encountered modifying git config
* Make the refspecs a configurable parameter
* Make refspecs a per-remote parameter
* Update master config template to include custom refspecs opts
* Add documentation for new config params
* Update GitFS walkthrough with a section on custom refspecs
* Remove dulwich support from salt.utils.gitfs
Dulwich still lacks important features, including (but not limited to)
the following:
- Lack of the necessary support for checking out a ref needed for
git_pillar/winrepo support
- No support in its config objects for multivar git config items, making
it impossible to detect when repos have multiple refspecs set for a
given git remote
Given this information, and the fact that it trails as a distant third
to Pygit2 and GitPython, Salt will cease to support Dulwich as a git
interface moving forward.
* Excise references to dulwich from documentation
* Add mention of custom refspecs to Nitrogen release notes
* Add gitfs_refspecs to mocked opts in gitfs integration tests
Also remove dulwich from unit tests
* Add information about opts argument not being intended for CLI use
Version 2.6.0 changed the wording of one of the exceptions tested,
causing tests to fail when jsonschema 2.6.0 is installed. This commit
updates the tests to change the assert for 2.6.0 and later.
* Fix for #38697
* Lint fixes
* Added missing source_hash_name argument in get_managed function
Additional fix to #33187
Customer was still seeing errors, this should now work.
Tested with 2015.8.13 and 2016.11.2
* [2016.3] Pylint fix (#39202)
* Ignore empty dicts in highstate outputter
Closes#37174
* Sort the return list from the fileserver.envs runner
* Fix the win_ip_test failures (#39230)
The changes made in #38793 changes the "get_all_ointerfaces" call
to be a list of DNS servers. This change adjusts the tests structure
from a string to a list and fixes the test failure.
The changes made in #38793 changes the "get_all_ointerfaces" call
to be a list of DNS servers. This change adjusts the tests structure
from a string to a list and fixes the test failure.
* Apply fix from #38705 to 2016.3 branch
This is a better fix and covers more use cases than the sudo_user one.
* Remove saltenv param from internal state func call
This was probably redundant in the first place, but since state.sls,
state.highstate, etc. accept a saltenv param and the actual state
functions do not, this results in multiple values passed for the saltenv
param.
Remove this argument and let file.get_managed reference __env__
internally.
* Update archive tests to match 2016.11 branch
This keeps trimmed output from failing the test. We are still testing
with a specific module lower down in the test, so this doesn't reduce
our test coverage.
This test fails often due to being trimmed, thanks to
salt.utils.dicttrim trimming values > max_event_size.
This commit changes this test so that it runs sys.doc twice, ensuring
that the return from sys.doc (for now) is not trimmed.
Stabilizes these tests by avoiding errors when cheese, crackers
order changes in the comment and gives errors like:
- 'comment': 'Kernel modules crackers, cheese are already present',
? --------
+ 'comment': 'Kernel modules cheese, crackers are already present',
? ++++++++
* Don't abort pillar.get with merge=True if default is None
This prevents a SaltInvocationError from being raised if the default is
loaded from a import_yaml jinja macro and the file being loaded is empty
(which is an entirely valid use case). In these cases, the loaded
default would be None, which we don't want to cause an exception.
* Add test case for issue 39062
This keeps trimmed output from failing the test. We are still testing
with a specific module lower down in the test, so this doesn't reduce
our test coverage.
This test fails often due to being trimmed, thanks to
salt.utils.dicttrim trimming values > max_event_size.
This commit changes this test so that it runs sys.doc twice, ensuring
that the return from sys.doc (for now) is not trimmed.
Update hardware clock so that date/time changes persist
through reboot.
Add hwclock check to system integration test. Bump tolerance
of _same_times() helper to account for longer run-time of set
operations. Updating hardware rtc's can take more than 2 seconds.
Signed-off-by: Haris Okanovic <haris.okanovic@ni.com>
Reviewed-by: Sergey Kizunov <sergey.kizunov@ni.com>
Reviewed-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
Reviewed-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
If all the devices submitted to pvcreate() are already initialized as
LVM physical volumes, pvcreate() should return True and no futher
actions should be made.
pvdisplay() would be called by pvcreate() twice: firstly to check
whether a device is already initialized for use by LVM and then to
ensure that the pvcreate executable did its job correctly. The test
replaces pvdisplay() with a mock that always returns True and thus
pvcreate() would think that a specified device is already initialized
and exit. In the other words, instead of testing physical volume
initialization the test simulates a case with all the submitted
devices already initialized.
Fix it by replacing pvdisplay with a mock that returns False on the
first call (thus pvcreate thinks that a device is not a PV yet) and True
on the second call (after the pvcreate executable is called).
'lvm version' produces multiline output whereas test_version and
test_fullversion use mocks with single-line output. Use real-life
'lvm version' output in those mocks instead.
* openvswitch: add a basic unit test for openvswitch
* openvswitch: enclose comments_* variables into a map
* openvswitch: only prepare error messages if type parameter is present
* openvswitch: add test case: create a GRE port
* openvswitch: remove trailing whitespace
* openvswitch: add missing "comments" variable
* openvswitch: pep8 compliance
* openvswitch: mock dig.check_ip
* openvswitch: rename "type" argument into "tunnel_type"
* openvswitch: reference bridge_exists before assignment
* openvswitch: reference port_list before assignment
* openvswitch: add upgrade note about "type" option renaming
These unit tests exposed a bunch of python 3 incompatibilities in the
filebuffer util as well as the find util. The filebuffer changes should
be reviewed carefully.
Once this happens, we need to re-enable the test. The move over
should also allow us to upgrade the version of salt-testing that
is applied to the test VMs. Once this is complete, we can apply
the `@flaky` decorator to this test. (salt-testing must be a
version newer than the September release.)
- Added the "CLI Example:" syntax to function that were missing it
- Added docs to functions missing any docs and CLI examples
- Added to functions to allow_failure in sysmod test as needed
- Also adjusted the ordering of the allow_failure structure to make it
easier to see which modules/funcitons were included (alphabetize)
Allows this code path to succeed for a minimal roster file that does not
specify `ssh_options`
$ sudo salt-ssh 'login1*' test.ping
Permission denied for host login1, do you want to deploy the salt-ssh
key? (password required):
[Y/n] Y
Password for root@login1:
login1:
True