Commit Graph

425 Commits

Author SHA1 Message Date
Erik Johnson
1cbe89feee
Implement tell() for filehandle iteration 2018-06-18 16:23:35 -05:00
Erik Johnson
38df912fa6
Operate on a copy of the read_data
This keeps us from mangling it if it contains lists, which we would be
popping items off of. We don't want to pop items from the list that was
passed in.
2018-06-18 14:45:40 -05:00
Erik Johnson
67c036dc2d
Add MockCall to tests.support.mock to track calls 2018-06-18 10:34:33 -05:00
Erik Johnson
fd9d700157
Add additional docs to MockOpen class 2018-06-18 00:28:06 -05:00
Erik Johnson
fc0aa9934f
Track call_count in MockOpen 2018-06-18 00:21:26 -05:00
Erik Johnson
51b3faa7b4
Add support for passing multiple strings for a given match in read_data 2018-06-18 00:21:26 -05:00
Erik Johnson
f5823252bb
Track call args/kwargs in MockFH
This allows for them to be verified in tests
2018-06-18 00:21:25 -05:00
Erik Johnson
335591ca90
Mock the seek function in MockFH 2018-06-18 00:21:25 -05:00
Erik Johnson
2be19cfa89
Report correct location when reading using explicit size and EOF reached 2018-06-18 00:21:25 -05:00
Erik Johnson
5ec95ba5ca
On second thought, actually implement tell() 2018-06-18 00:21:25 -05:00
Erik Johnson
19022eb9e5
Add tell mock to MockFH 2018-06-18 00:21:25 -05:00
Erik Johnson
4e67955572
Replace the rest of mock_open with a class 2018-06-18 00:21:25 -05:00
Erik Johnson
836fde9a30
Allow Python 2 to accept an exception as read_data 2018-06-18 00:21:25 -05:00
Erik Johnson
543385fd02
Add writelines_calls property 2018-06-18 00:21:25 -05:00
Erik Johnson
42fa842456
Make read funcs mocks so their calls can be tracked
Also add a property func as a shorthand to return all the write calls
for a given filehandle.
2018-06-18 00:21:25 -05:00
Erik Johnson
b9200dbc3e
add a dict containing the handles to the mock_open return object
This allows tests to access the MockFH objects opened during the
execution of the unit test.
2018-06-18 00:16:03 -05:00
Erik Johnson
852ba4b982
Add mocked close() function to MockFH 2018-06-18 00:16:02 -05:00
Erik Johnson
1861e9b944
mock_open: rewrite multi-file support
The initial approach tied all opened files to the same mocked
filehandle. This new approach moves all the read functions into a class,
and then uses a separate instance of that class for each opened file.
2018-06-18 00:16:02 -05:00
Erik Johnson
5e6b539770
Use function for empty string
Missed this when making changes for multi-file support
2018-06-18 00:16:02 -05:00
Erik Johnson
5d09b178d7
Separate mocked file contents per filename, not glob
This allows for multiple opens of a file matching the same glob.
Otherwise, subsequent opens would already be at EOF.
2018-06-18 00:16:02 -05:00
Erik Johnson
875102f538
Modify mock_open to support multiple file paths 2018-06-18 00:16:02 -05:00
Erik Johnson
8ba6cadac7
More mock_open bugfixes
This makes readline() a regular function and not an iterator. It also
makes the different side_effect functions all operate on the same
generator representing the file contents, and adds support for reading
an explicit amount of bytes from the file. The side effect functions can
now be run one after another and the mocked filehandle will work
properly.
2018-06-18 00:16:02 -05:00
rallytime
f23207002d
Merge branch '2018.3' into 'develop'
Conflicts:
  - salt/states/file.py
  - tests/unit/beacons/test_btmp_beacon.py
  - tests/unit/beacons/test_wtmp_beacon.py
  - tests/unit/grains/test_core.py
2018-06-15 17:00:59 -04:00
rallytime
398cc78224
Merge branch '2017.7' into '2018.3'
Conflicts:
  - .kitchen.yml
  - doc/topics/releases/2017.7.6.rst
  - salt/modules/timezone.py
  - tests/support/case.py
  - tests/unit/modules/test_timezone.py
2018-06-15 16:51:45 -04:00
Ch3LL
48b5d2e9d3
Add timeout argument to run_salt for ShellCase 2018-06-14 16:19:33 -04:00
Erik Johnson
e6a4744f85
Use errno instead of hard-coding error 2 2018-06-13 01:11:55 -05:00
Erik Johnson
ff63f36932
Fixes / enhancements for mock_open
This makes the following changes:

1. Now works properly when read_data is a bytestring
2. Now works properly when mocked filehandle is iterated (e.g. `for line in fh:`)
3. Adds ability to make mocked filehandle raise an IOError when the path
   being opened doesn't match a pattern (or one of a list of patterns).
2018-06-13 01:05:44 -05:00
plastikos
a6a5441510
Merge branch 'develop' into issue-13889 2018-06-08 11:23:11 -06:00
plastikos
540bcde985
Merge branch 'develop' into issue-13889 2018-06-08 01:50:02 -06:00
rallytime
d991430715
Merge branch '2018.3' into 'develop'
No conflicts.
2018-06-07 13:03:54 -04:00
rallytime
7dc1e770c4
Merge branch '2018.3' into 'develop'
Conflicts:
  - doc/topics/installation/freebsd.rst
  - salt/cloud/clouds/oneandone.py
  - salt/grains/core.py
  - salt/modules/napalm_ntp.py
  - salt/modules/win_update.py
  - salt/modules/win_wua.py
  - salt/modules/zabbix.py
  - salt/renderers/pass.py
  - salt/states/vault.py
  - tests/unit/states/test_win_update.py
2018-06-06 13:35:36 -04:00
Erik Johnson
41e5a75027
Add catch_timeout to run_script
One of the tests depends on forcing a timeout, but since we no longer
include the timeout message in the stdout/stderr return, we needed a way
to return whether or not the script timed out.
2018-06-06 09:04:09 -05:00
Erik Johnson
a1ce0631fd
Use @property instead of @staticmethod for config_dir
We're not passing arguments and we're just getting back a string
contstant, so there's no need to make this a staticmethod.
2018-06-05 14:10:33 -05:00
Erik Johnson
551ada8e4d
Capture and log output of processes that timed out and were killed
Before, tests.support.case.ShellTestCase.run_script would just go
¯\_(ツ)_/¯ and return that it killed the process. But you can still run
`.communicate()` on a process that was terminated, so this commit does
that and uses it to log the output from the killed process.
2018-06-05 13:33:39 -05:00
Nicole Thomas
a46e42ab11
Merge pull request #47927 from rallytime/merge-2018.3
[2018.3] Merge forward from 2017.7 to 2018.3
2018-06-04 14:55:11 -04:00
Erik Johnson
af02d5ba7b
Add result logging to run_script, make returns DRY 2018-06-04 00:17:41 -05:00
rallytime
be8d34ec21
Merge branch '2018.3' into 'develop'
No conflicts.
2018-06-01 15:19:09 -04:00
rallytime
3273bbdab7
Merge branch '2017.7' into '2018.3'
Conflicts:
  - doc/ref/configuration/master.rst
  - doc/ref/modules/all/index.rst
  - doc/topics/grains/index.rst
  - doc/topics/releases/2016.3.4.rst
  - doc/topics/spm/spm_formula.rst
  - doc/topics/tutorials/cron.rst
  - doc/topics/tutorials/index.rst
  - doc/topics/tutorials/stormpath.rst
  - salt/engines/slack.py
  - salt/log/handlers/fluent_mod.py
  - salt/modules/cyg.py
  - salt/modules/junos.py
  - salt/modules/namecheap_dns.py
  - salt/modules/namecheap_domains.py
  - salt/modules/namecheap_ns.py
  - salt/modules/namecheap_ssl.py
  - salt/modules/namecheap_users.py
  - salt/modules/reg.py
  - salt/modules/tomcat.py
  - salt/modules/vault.py
  - salt/modules/win_file.py
  - salt/modules/zpool.py
  - salt/output/highstate.py
  - salt/renderers/pass.py
  - salt/runners/cache.py
  - salt/states/boto_apigateway.py
  - salt/states/boto_iam.py
  - salt/states/boto_route53.py
  - salt/states/msteams.py
  - salt/states/reg.py
  - salt/states/win_iis.py
  - tests/integration/modules/test_cmdmod.py
  - tests/integration/states/test_user.py
  - tests/support/helpers.py
  - tests/unit/cloud/clouds/test_openstack.py
  - tests/unit/fileserver/test_gitfs.py
  - tests/unit/modules/test_junos.py
  - tests/unit/pillar/test_git.py
  - tests/unit/states/test_win_path.py
  - tests/unit/test_pillar.py
  - tests/unit/utils/test_format_call.py
  - tests/unit/utils/test_utils.py
  - tests/unit/utils/test_warnings.py
2018-06-01 14:54:12 -04:00
Nicole Thomas
a2b588299b
Merge pull request #47860 from terminalmage/state-writing-docs
Clean up doc build warnings, add best practices for writing states
2018-06-01 10:42:54 -04:00
Daniel Wallace
735e92093e
Merge pull request #47917 from dwoz/winsuite
Fix windows tests suite breakage
2018-06-01 06:42:14 -05:00
Daniel A Wozniak
118601ebd6
Fix windows tests suite breakage 2018-05-31 23:17:18 -07:00
Erik Johnson
93ee5ee2b0
Fix all Sphinx warnings
Well, all but one, which we expect to see
2018-05-31 15:28:25 -05:00
Nicole Thomas
ae73cb3947
Merge pull request #47899 from terminalmage/salt-jenkins-1000
salt-jenkins issue 1000
2018-05-31 14:24:48 -04:00
Erik Johnson
25afc932f7
WIP salt-jenkins issue 1000
This adds logging of the output and retcode when the output file fails
to be created. As I have thus far been unable to reproduce this locally,
this is the best shot at seeing what is causing the issue, since
ShellCase's run_script is rather opaque about what happens in the script
itself. We do know from the salt-runtests.log that the `salt-call -g` is
successfully returning, what we don't know is what happened after that
data was returned, and this should provide that insight.
2018-05-30 11:40:51 -05:00
rallytime
120ee16b70
Replace old utils paths with new utils paths 2018-05-29 11:19:34 -04:00
rallytime
dc32b67c03
Merge branch '2017.7' into '2018.3'
Conflicts:
  - salt/modules/win_snmp.py
  - tests/integration/modules/test_saltutil.py
  - tests/integration/states/test_pkg.py
  - tests/support/helpers.py
  - tests/support/runtests.py
  - tests/unit/fileserver/test_gitfs.py
  - tests/whitelist.txt
2018-05-29 11:14:39 -04:00
Daniel A. Wozniak
c2f8aef7c5
Fix for py3 ec2 cloud tests 2018-05-27 14:09:50 -07:00
Daniel A. Wozniak
e5948902af
Use salt utils method for this_user 2018-05-24 00:40:20 -07:00
Daniel A. Wozniak
a056a293f1
Centeralize test username lookup 2018-05-23 16:16:35 -07:00
Daniel A Wozniak
6a6ab69722
Get the current username on windows 2018-05-23 16:16:32 -07:00
rallytime
4abfd26e86
Merge branch '2017.7' into '2018.3'
Conflicts:
  - requirements/dev_python27.txt
  - requirements/dev_python34.txt
  - salt/fileclient.py
  - salt/output/__init__.py
  - salt/serializers/configparser.py
  - salt/states/pkg.py
  - salt/states/zpool.py
  - salt/transport/tcp.py
  - tests/integration/cloud/providers/test_ec2.py
  - tests/integration/modules/test_mac_user.py
  - tests/integration/modules/test_pip.py
  - tests/integration/modules/test_pkg.py
  - tests/integration/modules/test_service.py
  - tests/integration/states/test_pip_state.py
  - tests/integration/states/test_user.py
  - tests/unit/modules/test_cmdmod.py
2018-05-23 12:33:00 -04:00
plastikos
9dd9430378
Merge branch 'develop' into issue-13889 2018-05-17 23:10:44 -06:00
Erik Johnson
3b449f11fc
Add regression test for excludes issue 2018-05-16 12:26:46 -05:00
rallytime
969296ecbe
Merge branch '2018.3' into 'develop'
No conflicts.
2018-05-15 12:38:01 -04:00
plastikos
19e53fe943
Merge branch 'develop' into issue-13889 2018-05-15 10:35:59 -06:00
rallytime
cf58ae22bf
Merge branch '2018.3' into 'develop'
Conflicts:
  - salt/states/pip_state.py
  - tests/unit/utils/test_stringutils.py
2018-05-09 11:40:54 -04:00
rallytime
25f03ae425
Merge branch '2017.7' into '2018.3'
Conflicts:
  - tests/integration/modules/test_status.py
  - tests/integration/states/test_pip_state.py
  - tests/support/case.py
  - tests/whitelist.txt
2018-05-09 11:24:02 -04:00
rallytime
2ad60c7e81
Lint: remove duplicate function in helpers.py 2018-05-07 15:45:30 -04:00
rallytime
786076ac03
Merge branch '2017.7' into '2018.3'
Conflicts:
  - pkg/windows/modules/get-settings.psm1
  - salt/modules/cmdmod.py
  - salt/modules/pip.py
  - salt/modules/win_lgpo.py
  - salt/states/pip_state.py
  - tests/integration/states/test_pip.py
  - tests/support/helpers.py
  - tests/unit/modules/test_pip.py
  - tests/whitelist.txt
2018-05-07 13:17:01 -04:00
Daniel A Wozniak
c6697b9f16
Move kill process tree and re-use it 2018-05-06 09:44:55 -07:00
Daniel Wozniak
6a4d0380b1
Merge pull request #47493 from dwoz/win_run_timeout
Add support for windows timeout to run_salt
2018-05-05 22:34:30 -07:00
Daniel A Wozniak
fec1233dc4
Add support for windows timeout to run_salt
The run_salt function needs to support timeout on windows for the full
test suite to run.
2018-05-05 15:10:14 -07:00
Thayne Harbaugh
485e151507 Support Jinja imports with relative paths. Issue #13889
Jinja imports will be interpreted as originating from the top of each
of the directories in the searchpath when the template name does not
begin with './' or '../'.  When a template name begins with './' or
'../' then the import will be relative to the importing file.

Prior practices required the following construct:

.. code-block:: yaml

  {% from tpldir ~ '/foo' import bar %}

This patch supports a more "natural" construct:

.. code-block:: yaml

  {% from './foo' import bar %}

Comparatively when importing from a parent directory - prior practice:

.. code-block:: yaml

  {% from tpldir ~ '/../foo' import bar %}

Construct supported by this patch:

.. code-block:: yaml

  {% from '../foo' import bar %}
2018-05-04 17:14:01 -06:00
rallytime
bd184a257f
Merge branch '2018.3' into 'develop'
Conflicts:
  - tests/unit/grains/test_core.py
2018-05-02 15:28:21 -04:00
twangboy
14ee5537b9
Add @with_tempdir helper
Fix two state tests
Remove redundent tests
2018-05-02 12:17:36 -06:00
Shane Lee
f031710af2
Merge branch '2017.7' into fix_47024 2018-05-01 16:26:04 -06:00
twangboy
7c46d9d0d4
Fix integration.modules.test_pip
Pass password as kwarg for runas on Windows
Fix issues with pip 10 in unit.states.test_pip
2018-05-01 15:33:29 -06:00
rallytime
13e8124031
Merge branch '2017.7' into '2018.3'
Due to the many merge conflicts created from #47106 against the 2017.7 branch
and #46002 against the 2018.3 branch, the changes from #47106 have been largely
removed from this merge forward and the HEAD of 2018.3 was taken.

A separate fix for Tornado 5.0 support will need to be made directly against the
2018.3 branch.

Conflicts:
  - doc/topics/development/conventions/formulas.rst
  - salt/master.py
  - salt/minion.py
  - salt/netapi/rest_tornado/saltnado.py
  - salt/states/zfs.py
  - salt/transport/ipc.py
  - salt/transport/tcp.py
  - salt/transport/zeromq.py
  - salt/utils/async.py
  - tests/support/helpers.py
  - tests/support/parser/cover.py
  - tests/unit/grains/test_core.py
  - tests/unit/modules/test_ssh.py
  - tests/unit/test_minion.py
  - tests/unit/utils/test_safe_walk.py
2018-04-27 13:38:35 -04:00
Nicole Thomas
aacd5cefe3
Merge pull request #47304 from cachedout/test_cli_timeout_arg
Pass timeout to salt CLI for tests
2018-04-27 09:11:57 -04:00
Daniel A. Wozniak
94a70e847a
Ignore gitfs tests when symlinks not enabled 2018-04-26 23:51:28 -07:00
Mike Place
85025af83c
Pass timeout to salt CLI for tests
This should hopefully fix up the race condition in the long-running
jobs test.
2018-04-25 11:04:59 -05:00
rallytime
0eab957281
Merge branch '2018.3' into 'develop'
Conflicts:
  - salt/netapi/rest_tornado/saltnado.py
  - tests/integration/states/test_file.py
  - tests/integration/states/test_git.py
  - tests/unit/modules/test_tls.py
2018-04-20 15:40:49 -04:00
Daniel A. Wozniak
ad9c7f63f0
Fix coverate on py3 windows builds
Setting a value for will cause coverage to look for a config file called
named '1' and in-turn raises an Exception. Based on the docs, if the
environment variable exists coverage is enabled. Just defined the
environment variable instead of giving it a value.
2018-04-20 12:30:43 -07:00
Daniel A. Wozniak
25803c9176
Move process target to top level module namespace 2018-04-19 18:38:28 -07:00
Nicole Thomas
1947ffdf56
Merge pull request #47122 from rallytime/merge-2018.3
[2018.3] Merge forward from 2017.7 to 2018.3
2018-04-19 16:44:17 -04:00
Nicole Thomas
3d812f64b2
Merge pull request #47040 from terminalmage/new-decorators
Add ability to run a shell command to depends decorator
2018-04-19 15:30:25 -04:00
Erik Johnson
879c557264
Use decorators for temp files/dirs in test suite
This adds a new decorator which creates a temporary directory and cleans
it after the test completes. It also modifies an existing decorator for
creating temporary files so that it accepts arguments, which will be
passed through to salt.utils.files.mkstemp().
2018-04-18 19:46:29 -05:00
rallytime
94c2a12be6
Merge branch '2017.7' into '2018.3'
Conflicts:
  - tests/integration/modules/test_state.py
  - tests/unit/templates/test_jinja.py
  - tests/unit/test_minion.py
2018-04-17 10:54:42 -04:00
Mike Place
b8990f5258
Pass the timeout variable to the CLI when calling salt in tests 2018-04-13 16:37:01 -06:00
Erik Johnson
db11317400
Add ability to run a shell command to depends decorator
This adds the ability to suppress loading of a function based on the
retcode of a command.
2018-04-12 18:02:21 -05:00
rallytime
fe10957ce0
Merge branch '2018.3' into 'develop'
Conflicts:
  - salt/cloud/clouds/azurearm.py
2018-04-12 11:00:14 -04:00
Gareth J. Greenaway
2ccf2c5fe0
Fixing test_path_which to check that the filter is available rather than results. 2018-04-11 08:19:07 -07:00
Nicole Thomas
ffaee26540
Merge pull request #46990 from rallytime/merge-2018.3
[2018.3] Merge forward from 2017.7 to 2018.3
2018-04-10 13:07:32 -04:00
Nicole Thomas
a34b92ae82
Merge pull request #46339 from DSRCorporation/bugs/ssh_state_test_failures
SSH State test failures
2018-04-10 13:06:50 -04:00
rallytime
2f1cf3e511
Merge branch '2017.7' into '2018.3'
Conflicts:
  - .kitchen.yml
2018-04-10 10:11:35 -04:00
Gareth J. Greenaway
0adfee9b11
Updating a couple tests. Fixing check_whitelist_blacklist to work with PY3 when non-iterables are passed. Adding warning about lst_avg results being wrong and future updates in Neon. 2018-04-09 19:38:18 -07:00
Gareth J. Greenaway
f3f42146ca
Removing expected from strftime and hashsum tests since the results are always different and we are only concerned about the filter being available. 2018-04-06 13:19:11 -07:00
Gareth J. Greenaway
860234c045
Fixing lint. 2018-04-06 13:19:11 -07:00
Gareth J. Greenaway
0599759e5b
cleaning up some test doc strings. 2018-04-06 13:19:10 -07:00
Gareth J. Greenaway
dceda5eb88
Moving all jinja filter tests into support/jinja_filters.py. Updaitng integration/ssh/test_jinja_filters.py to use those tests. Adding integration/modules/test_state_jinja_filters.py to also use the common jinja filter tests. 2018-04-06 13:19:10 -07:00
rallytime
5b50eaf6b0
Merge branch '2018.3' into 'develop'
Conflicts:
  - doc/ref/proxy/all/salt.proxy.cimc.rst
  - doc/ref/proxy/all/salt.proxy.panos.rst
  - doc/topics/releases/2018.3.0.rst
  - salt/modules/cmdmod.py
  - salt/modules/state.py
  - salt/utils/schedule.py
  - tests/integration/modules/test_state.py
2018-04-05 13:25:46 -04:00
Mike Place
bd98c49dc7
Merge branch '2018.3' into bugs/ssh_state_test_failures 2018-04-05 09:58:54 -05:00
Daniel Wallace
2edd5eaf9e
fix path 2018-04-04 13:37:39 -05:00
rallytime
893196d3e6
Merge branch '2017.7' into '2018.3'
Conflicts:
  - doc/conf.py
  - salt/loader.py
  - salt/modules/dockermod.py
  - salt/modules/sensehat.py
  - salt/utils/parsers.py
  - tests/integration/cloud/providers/test_ec2.py
  - tests/integration/modules/test_cp.py
  - tests/integration/modules/test_groupadd.py
  - tests/integration/spm/test_man_spm.py
  - tests/integration/states/test_npm.py
  - tests/unit/states/test_environ.py
2018-04-03 14:33:11 -04:00
Dmitry Kuzmenko
6fdc458a7f
Increase timeout for run_run in ShellCase 2018-03-29 22:46:23 +03:00
Dmitry Kuzmenko
92a6c43c73
More logging and assertion fixes. Extended ssh ops timeout. 2018-03-29 22:46:22 +03:00
Daniel A. Wozniak
5c22a0f88d
Use aboslute imports 2018-03-28 22:32:30 -07:00
Daniel A. Wozniak
78c9cb9584
Fix TestResult constructor calls 2018-03-28 21:09:59 -07:00
Daniel A. Wozniak
5ac89ad307
Use winrm_verify_ssl option causing tests to pass 2018-03-28 20:21:40 -07:00
Daniel A. Wozniak
ba5f11476c
Adding windows minion tests for salt cloud 2018-03-28 15:16:54 -07:00
Daniel A. Wozniak
4cb0c3f228
Failfast will be '-F' instead of '-f'
Avoid potential confusion with '-f' for '--force'
2018-03-21 20:31:25 -07:00
Daniel A. Wozniak
641f1f2293
Add fail-fast option to test runner 2018-03-20 22:53:01 -07:00
Erik Johnson
f9f187e915
Improve reliability/idempotence of file.blockreplace state
This makes the following changes:

- The `append_newline` argument to the `file.blockreplace`
  remote-execution function has been modified so that if its value is
  `None`, it only appends a newline when the content block does not end
  in one.
- A couple of fixes were made to newline handling. The existing code
  normalized the newlines in the content block, replacing them with
  os.linesep. However, when the file contains newlines that don't match
  the OS (i.e. POSIX newlines in a file on a Windows box, or Windows
  newlines on a Linux/Mac/BSD/etc. box), then we would still end up with
  mixed newlines. The line separator is now detected when we read in the
  original file, and the detected line separator is used when writing
  the content block. Additionally, the same newline mismatch was
  possible when appending/prepending the content block. This has been
  fixed by using a common function for appending, prepending, and
  replacing the content block.
- Support for the `append_newline` argument has been added to the
  `file.blockreplace` state. The default value for the state is `None`.
  A `versionchanged` has been added to the remote execution function to
  let users know that the Fluorine release will change the default value
  of that variable.
- 20 new integration tests have been written to test the
  `file.blockreplace` state.
2018-03-07 22:29:39 -06:00
Erik Johnson
4798187035
Improve reliability/idempotence of file.blockreplace state (2018.3 branch)
This makes the following changes:

- The `append_newline` argument to the `file.blockreplace`
  remote-execution function has been modified so that if its value is
  `None`, it only appends a newline when the content block does not end
  in one.
- A couple of fixes were made to newline handling. The existing code
  normalized the newlines in the content block, replacing them with
  os.linesep. However, when the file contains newlines that don't match
  the OS (i.e. POSIX newlines in a file on a Windows box, or Windows
  newlines on a Linux/Mac/BSD/etc. box), then we would still end up with
  mixed newlines. The line separator is now detected when we read in the
  original file, and the detected line separator is used when writing
  the content block. Additionally, the same newline mismatch was
  possible when appending/prepending the content block. This has been
  fixed by using a common function for appending, prepending, and
  replacing the content block.
- Support for the `append_newline` argument has been added to the
  `file.blockreplace` state. The default value for the state is `None`.
  A `versionchanged` has been added to the remote execution function to
  let users know that the Fluorine release will change the default value
  of that variable.
- 20 new integration tests have been written to test the
  `file.blockreplace` state.
2018-03-07 22:29:09 -06:00
Erik Johnson
1668a489c4
Update refrences to Oxygen codename to 2018.3.0 2018-02-21 21:47:41 -06:00
Erik Johnson
9d004f6512 Use mock 2.0.0 instead of unittest.mock on Python 3 (#2)
This preserves the custom mock_open we backported from unittest.mock,
but otherwise ditches unittest.mock as it does not have
MagicMock.assert_called in Python releases before 3.6.

This allows us to maintain a uniform mock version across all platforms
and Python releases.
2018-02-13 20:16:03 +01:00
Erik Johnson
293bdf2517
Merge pull request #45726 from rallytime/merge-oxygen
[oxygen] Merge forward from 2017.7 to oxygen
2018-01-28 13:05:00 -06:00
Nicole Thomas
2969d86237
Merge pull request #45735 from terminalmage/shellcase-debug-logging
Add debug logging to ShellCase functions
2018-01-28 08:27:20 -05:00
Erik Johnson
1cabf31a1f
Add debug logging to ShellCase functions
Some of these have been failing in ways which are not reproducible
locally. This adds debug logging so that we can check the
salt-runtests.log for the return data, to aid in troubleshooting.

NOTE: This also contains a fix for a bug in the CLI output handler that
I think may have a chance of fixing some of these odd failures.
2018-01-27 20:55:34 -06:00
Erik Johnson
f60183b95c
Use bytestrings for struct.pack/unpack
https://github.com/saltstack/salt/pull/45687 and
https://github.com/saltstack/salt/pull/45725 fixed problems with older
Python 2 versions interacting with the struct module, since
unicode_literals turned the format strings to unicode and older Python 2
releases can't accept a unicode format string. Since Python 2 and 3 both
support using bytestrings for the format strings, this commit makes sure
we are using bytestrings everywhere else we are using struct.pack/unpack.
2018-01-27 17:34:16 -06:00
rallytime
0ad101d560
Merge branch '2017.7' into 'oxygen'
Conflicts:
  - doc/man/salt.7
  - salt/modules/git.py
  - salt/modules/pacman.py
  - salt/states/git.py
  - tests/integration/modules/test_mac_user.py
  - tests/support/parser/__init__.py
2018-01-26 17:27:03 -05:00
Erik Johnson
d6d7da5c90
Replace all usage of six.b
It can't be trusted to produce bytes, it returns unicode when a unicode
string is passed.
2018-01-24 09:17:28 -06:00
Erik Johnson
6aa865cf54
Fix unnecessary/incorrect usage of six.binary_type 2018-01-22 11:17:06 -06:00
Nicole Thomas
12c0f99e8c
Merge pull request #45293 from terminalmage/py3-acl-auth-netapi
[PY3] Add unicode_literals to acl, auth, and netapi modules
2018-01-09 16:32:59 -05:00
Daniel Wallace
a8341fea01
clean up for windows tests for kitchen-salt 2018-01-06 17:14:46 -07:00
Daniel Wallace
e2824a7253
fix py3 tests 2018-01-05 13:36:08 -07:00
Erik Johnson
49dd5b32e9
[PY3] Add unicode_literals to acl, auth, and netapi modules 2018-01-05 10:31:11 -06:00
Erik Johnson
1dc6e79638
[PY3] Add unicode_literals to ext_pillar modules 2018-01-04 08:46:40 -06:00
Erik Johnson
002aa88a97
Replace yaml usage with a helper to ensure unicode is handled properly
Without allow_unicode=True, unicode characters are processed through the
str representer and on Python 2 are dumped as a Unicode code point (i.e.
a literal \u0414). This commit makes allow_unicode=True the default in
our salt.utils.yamlloader.safe_dump() helper. It also adds a new
salt.utils.yamlloader.dump() helper which wraps yaml.dump() and also
makes allow_unicode=True the default.

To make importing and using our custom yaml loader/dumper easier, a
convenience module called salt.utils.yaml has been added, which does a
wildcard import from both salt.utils.yamldumper and
salt.utils.yamlloader.

Refs to yaml.load/dump and yaml.safe_load/safe_dump have been updated to
salt.utils.yaml, to ensure that unicode is handled properly.
2018-01-03 14:14:21 -06:00
Erik Johnson
7b13a7df8b
Replace json module usage with a helper to ensure unicode content is handled properly
This adds wrappers for json.dump{,s} which disable `ensure_ascii` by
default.
2017-12-27 09:30:58 -06:00
rallytime
9ded5e1cbb
Merge branch '2017.7' into 'oxygen'
Conflicts:
  - salt/config/__init__.py
  - salt/grains/core.py
  - salt/modules/win_lgpo.py
  - salt/returners/mysql.py
  - salt/states/libcloud_dns.py
  - tests/integration/runners/test_runner_returns.py
  - tests/unit/grains/test_core.py
2017-12-21 15:58:08 -05:00
Daniel Wallace
d0586013eb
fix pylint 2017-12-21 10:40:54 -07:00
Daniel Wallace
59e2e56d13
chmod the xml files before trying to copy 2017-12-21 08:17:10 -07:00
Daniel Wallace
a5c1410e23
catch IOError when copying xml files back 2017-12-20 18:26:18 -07:00
Michael Calmer
744e698689
adapt tests to reflect reality
When CherryPy run with python3 it reads "bytes" from the wire.
In case of python2 BytesIO == StringIO, so nothing should change.

This change will do the same to make unit tests reflect reality.
2017-12-20 06:59:56 -05:00
Erik Johnson
7d6b679ac4
Fix fake importer for Python 3
Python 3 does not appear to pass all values to the `__import__` builtin
when they do not differ from the defaults. Therefore, the fake import
fails because of missing positional args.

This fix simply uses the defaults from Python 2 and 3's `__import__`
builtin.
2017-12-19 12:09:36 -06:00
Erik Johnson
15296e59a5
Add debug logging to SSHCase 2017-12-19 12:09:35 -06:00
Erik Johnson
8cdb9ea54f
[PY3] Add print_function import to files with unicode_literals already added
This makes the 2.x usage invalid syntax and forces the use of print as a
function. This adds the import to the files which I've updated in the
last couple of days but forgot to add it.
2017-12-15 12:14:18 -06:00
Nicole Thomas
ae8dd2e202
Merge pull request #44982 from terminalmage/docker-unicode
[PY3] Add unicode_literals to docker state/execution modules
2017-12-14 11:03:15 -05:00
Erik Johnson
5e1f75aab0
[PY3] Add unicode_literals to docker state/execution modules 2017-12-13 22:49:23 -06:00
Daniel Wallace
a7df9c3da3
fix py3 tests 2017-12-12 12:47:31 -07:00
rallytime
db5866d097
Update old utils paths to new utils paths 2017-12-11 18:43:33 -05:00
rallytime
08c71f13e4
Merge branch '2017.7' into 'oxygen'
Conflicts:
  - doc/ref/configuration/minion.rst
  - doc/topics/thorium/index.rst
  - salt/beacons/__init__.py
  - salt/client/mixins.py
  - salt/client/ssh/wrapper/state.py
  - salt/daemons/masterapi.py
  - salt/grains/extra.py
  - salt/minion.py
  - salt/modules/cron.py
  - salt/modules/file.py
  - salt/modules/mac_user.py
  - salt/modules/napalm_network.py
  - salt/modules/state.py
  - salt/modules/win_file.py
  - salt/modules/win_pkg.py
  - salt/proxy/dummy.py
  - salt/state.py
  - salt/states/file.py
  - salt/states/lxc.py
  - salt/utils/__init__.py
  - salt/utils/schedule.py
  - tests/integration/modules/test_file.py
  - tests/integration/modules/test_groupadd.py
  - tests/integration/ssh/test_state.py
  - tests/integration/states/test_file.py
  - tests/unit/daemons/test_masterapi.py
  - tests/unit/grains/test_core.py
  - tests/unit/modules/test_disk.py
  - tests/unit/modules/test_napalm_network.py
  - tests/unit/modules/test_state.py
  - tests/unit/test_minion.py
  - tests/unit/utils/test_process.py
2017-12-11 18:24:41 -05:00
Erik Johnson
272044c688
Roll back use of explicit unicode literals 2017-12-10 17:41:45 -06:00
Nicole Thomas
53eee476ac
Merge pull request #44638 from terminalmage/new-docker-hotness
Many improvements to docker network and container states
2017-12-07 15:50:55 -05:00
twangboy
f8110713f8
Use binary instead of unicode for loglevel 2017-12-06 21:31:43 -07:00
Erik Johnson
64aa4fbbec
Many improvements to docker network and container states
Much Improved Support for Docker Networking
===========================================

The `docker_network.present` state has undergone a full rewrite, which
includes the following improvements:

Full API Support for Network Management
---------------------------------------

The improvements made to input handling in the
`docker_container.running` state for 2017.7.0 have now been expanded to
docker_network.present`.  This brings with it full support for all
tunable configuration arguments.

Custom Subnets
--------------

Custom subnets can now be configured. Both IPv4 and mixed IPv4/IPv6
networks are supported.

Network Configuration in :py:func:`docker_container.running` States
-------------------------------------------------------------------

It is now possible to configure static IPv4/IPv6 addresses, as well as
links and labels.

Improved Handling of Images from Custom Registries
==================================================

Rather than attempting to parse the tag from the passed image name, Salt
will now resolve that tag down to an image ID and use that ID instead.

Due to this change, there are some backward-incompatible changes to
image management. See below for a full list of these changes.

Backward-incompatible Changes to Docker Image Management
--------------------------------------------------------

Passing image names to the following functions must now be done using separate
`repository` and `tag` arguments:

- `docker.build`
- `docker.commit`
- `docker.import`
- `docker.load`
- `docker.tag`
- `docker.sls_build`

Additionally, the `tag` argument must now be explicitly passed to the
`docker_image.present` state, unless the image is being pulled from a
docker registry.
2017-12-06 12:12:25 -06:00
Ch3LL
61ac5cf157
Add spm -y and -f arg integration tests 2017-12-04 16:06:14 -05:00
Anthony Shaw
3611e08a27
import absolute paths 2017-11-29 10:00:41 +11:00
Anthony Shaw
a029f70cff
merge inbound, resolve conflict and remove unfinished state test module 2017-11-29 08:21:53 +11:00
Anthony Shaw
7b3ea6f5b9
mute false negative on linter 2017-11-25 19:03:23 +11:00
Anthony Shaw
0a34c12147
tests for napalm grains module, still issue to resolve on is_proxy 2017-11-25 05:47:27 +11:00
Anthony Shaw
38eb0dd000
more test fixtures 2017-11-24 17:14:14 +01:00
Anthony Shaw
c7106d646c
complete tests for napalm_probes 2017-11-24 16:48:06 +01:00
Anthony Shaw
136816c109
fix missing commas in docstrings 2017-11-24 16:36:38 +01:00
Anthony Shaw
452a8965a3
complete coverage for NTP module 2017-11-24 16:34:16 +01:00
Ch3LL
69134e83ca
Change order of local kwarg in run_call method 2017-11-22 15:50:29 -05:00
Ch3LL
b3b5ecc6ff
Add pillar.items test for masterless 2017-11-22 15:40:57 -05:00
rallytime
052b13c98e
Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/cli/daemons.py
  - salt/client/ssh/__init__.py
  - salt/modules/win_pkg.py
  - salt/netapi/rest_cherrypy/app.py
  - salt/proxy/fx2.py
  - salt/utils/__init__.py
  - salt/utils/jinja.py
  - salt/utils/napalm.py
  - salt/utils/path.py
  - salt/utils/verify.py
  - tests/integration/modules/test_saltutil.py
  - tests/integration/states/test_service.py
  - tests/unit/utils/test_verify.py
2017-11-22 12:36:03 -05:00
Anthony Shaw
dfdb43780d
coverage for ntp testing 2017-11-22 11:36:22 +01:00
Anthony Shaw
5ce67c8a7b
setup all tests for napalm_acl module 2017-11-22 09:01:26 +00:00
Anthony Shaw
cd8d87c61f
create a common module for napalm tests, setup napalm_bgp tests 2017-11-22 08:37:56 +00:00
twangboy
47114fdb30
Pass root_dirs to the win_verify_env function
Remove while loop that was hanging when `salt` wasn't in the path
Add salt.util.path.safe_path function to check for unsafe paths
Pass root_dir to all calls to `verify_env`
2017-11-13 13:05:23 -07:00
rallytime
4e2280157a
Merge branch '2017.7' into 'develop'
Conflicts:
  - .kitchen.yml
  - tests/unit/test_doc.py
  - tests/unit/utils/test_cloud.py
2017-11-13 12:27:59 -05:00
Ch3LL
308596ac8d
Add salt-ssh raw integration tests 2017-11-10 14:47:38 -05:00
Ch3LL
8089a885c2
add wipe function to other run_ssh method 2017-11-10 10:48:31 -05:00
Ch3LL
faef0886a7
Add state tests and state request system to salt-ssh 2017-11-10 10:48:30 -05:00
rallytime
2c052e34b3
Merge branch '2017.7' into 'develop'
Conflicts:
  - .gitignore
  - salt/modules/win_lgpo.py
  - salt/utils/__init__.py
  - tests/integration/spm/test_build.py
  - tests/unit/test_pydsl.py
2017-11-05 20:28:51 -07:00
Mike Place
1412a42f0e
Merge pull request #44070 from gtmanfred/kitchen
begin adding kitchen-salt into the test suite
2017-11-02 15:55:33 -06:00
Nicole Thomas
b2b0c770a4
Merge pull request #44279 from rallytime/merge-2017.7
[2017.7] Merge forward from 2016.11 to 2017.7
2017-10-27 12:17:18 -04:00
Erik Johnson
bd5b9dd0aa Merge pull request #44291 from Ch3LL/pillar_test
add saltutil.refresh_pillar test
2017-10-27 10:19:42 -05:00
Ch3LL
34e2955445
add saltutil.refresh_pillar test 2017-10-25 15:56:49 -04:00
rallytime
8237f45a46
Add print_function to __future__ import list 2017-10-25 14:54:03 -04:00
Ch3LL
03b5c4bc6d
add spm integration tests for remove and build 2017-10-25 12:09:51 -04:00
rallytime
1c3cb5c6a4
Merge branch '2016.11' into '2017.7'
Conflicts:
  - .gitignore
  - tests/unit/states/test_file.py
2017-10-25 10:04:08 -04:00
rallytime
8a1c575ae5
Update salt.utils.fopen calls to new salt.utils.files.fopen path 2017-10-25 09:59:04 -04:00
rallytime
28343f0120
Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/modules/git.py
2017-10-25 09:54:37 -04:00
Daniel Wallace
56a3ad8f68
fix pylint comments 2017-10-24 12:18:27 -06:00
Daniel Wallace
4add666db1
add comment to Gemfile and move copyartifacts
moved copyartifacts.py to tests/support

Also added a comment to the Gemfile that this is only used to run the testsuite with kitchen-salt
2017-10-24 12:01:57 -06:00
Ch3LL
4729ccd32b
Add multiple spm integration tests 2017-10-23 17:13:32 -04:00
rallytime
2617cf851f
Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/modules/aptpkg.py
  - salt/utils/win_functions.py
  - tests/unit/states/test_mount.py
2017-10-20 10:44:29 -04:00
Nicole Thomas
f0175623ed Merge branch 'develop' into ssh_known_hosts_improvements 2017-10-19 13:44:29 -04:00
Ch3LL
cd79e9444e
remove unneded kwarg 2017-10-18 17:21:52 -04:00
Ch3LL
1541376c4f
Add spm build test 2017-10-18 17:15:42 -04:00
Daniel Wallace
7410ffd92a
add first kitchen test 2017-10-17 14:59:10 -06:00
rallytime
c0f16dae74
Merge branch '2017.7' into 'develop'
Conflicts:
  - doc/topics/tutorials/index.rst
  - salt/crypt.py
  - salt/modules/cmdmod.py
  - salt/modules/grains.py
  - salt/pillar/git_pillar.py
  - salt/roster/clustershell.py
  - tests/unit/states/test_augeas.py
  - tests/unit/utils/test_utils.py
2017-10-16 15:26:19 -04:00
Erik Johnson
877abb89d0
Complete the salt.utils refactor
This moves the remaining 30 functions from salt.utils to new locations.
2017-10-15 09:43:31 -05:00
Erik Johnson
2d4d8fa9c8
Convert "Can be removed" lines into TODO lines 2017-10-13 09:29:03 -05:00
Ch3LL
d2e91c33bd
Add spm shell tests 2017-10-12 15:31:48 -04:00
Erik Johnson
8b16300495
Fix some regressions in recent legacy git_pillar deprecation
These didn't get caught in PR 42823 because of how we invoke the
git_pillar code. Firstly, the "pillar" argument needed to stay. This is
because even though we're not using it, _external_pillar_data() is still
passing it now that git_pillar is not specially invoked there.
Secondly, since the input comes in as a list, and _external_pillar_data
uses single-asterisk expansion, the repos are passed separately when
they should be passed as a single list. To fix these issues, I've done
the following:

1. Re-introduced the "pillar" argument in git_pillar's ext_pillar
   function.
2. Changed the "pillar" variable to avoid confusion with the (unused)
   "pillar" argument being passed in.
3. Instead of git_pillar accepting the repos as a list, the ext_pillar
   function now uses single-asterisk expansion to make it conform with
   how _external_pillar_data() invokes it.
2017-09-26 16:12:55 -05:00
Alexei Pope Lane
ad80801d0f Improvements to SSH known_hosts module and state. 2017-09-19 13:28:48 +10:00
rallytime
5901b10c14 Remove deprecated Legacy Git Pillar code 2017-08-23 16:49:58 -04:00
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
rallytime
ccf790a83f Update all references for moved functions to use "files" util
- fopen
- flopen
- fpopen
- safe_rm
- is_empty
- is_fcntl_available
2017-07-18 10:31:01 -06:00
rallytime
8d960d463a Merge branch '2017.7' into 'develop'
Conflicts:
  - salt/grains/core.py
2017-07-06 17:42:30 -06:00
Erik Johnson
d942752e95 Fix usage of assert_called_once in Python 3 < 3.6
This is a more complete fix which builds upon 41c65b0 and covers all
refs to assert_called_once in the suite.
2017-07-03 09:30:12 -05:00
rallytime
4a7073ac79 Add generate_random_name function to tests helpers
This function is used identically in every cloud provider test file. Let's add
it to a more central place and make it more DRY. Might be useful in other testing
places as well.
2017-06-29 15:43:03 -06:00
Dmitry Kuzmenko
e01e566779 Minor: show full dict diffs if test fails. 2017-06-27 16:22:09 +03:00
Daniel Wallace
05f2c66604 handle bytes strings in mock_open 2017-06-15 22:43:40 -06:00
Daniel Wallace
4f7c6d1161 use our own mock_open
test.support.mock.mock_open specifies a side effect so that if you constantly
read a mocked open call, it will only iterate through it once, and then after
it will appear as if the end of the file has been reached.

This is needed for salt.modules.cp.push to be tested correctly.
2017-06-15 17:50:35 -06:00
Mike Place
b12611d122 Merge pull request #41617 from cro/n_proxy_tests
Port salt-proxy tests to the testsuite changes in Nitrogen.
2017-06-15 12:07:29 -05:00
Gareth J. Greenaway
53a216378c Fixing the last text failure. 2017-06-09 09:16:09 -06:00
Gareth J. Greenaway
4d3399c6c4 Couple more typos, assert not asset. 2017-06-09 09:16:09 -06:00
Gareth J. Greenaway
14a903ef61 Fixing typo in assertSaltTrueReturn, assertSaltFalseReturn and assertSaltNoneReturn. 2017-06-09 09:16:09 -06:00
Gareth J. Greenaway
a531d01b26 Updating the assert tests for develop based on changes from 41569. 2017-06-09 09:16:09 -06:00
Erik Johnson
846200f11e Include terminate_process_list in import 2017-06-08 00:24:53 -05:00
C. R. Oldham
4540f82aaa Port salt-proxy tests to the testsuite changes in Nitrogen. 2017-06-06 13:49:16 -06:00
Daniel Wallace
f309bae8b4 Make sure runtests_engine is ASCII text
If this is has any unicode characters in it, it won't load on systems that do
not default to a unicode locale.

find . -type f | while read line; do ret=$(file $line); if [[ $ret == *UTF-8* && $line == *.py ]]; then echo $line; fi; done

The above will list all files that have unicode characters in it and won't load
with locale set to C or POSIX
2017-06-05 17:30:28 -06:00
rallytime
8dfa8d1d19 Pass the fingerprint_hash_type through for gitfs sshd tests 2017-05-11 12:29:51 -06:00
Nicole Thomas
2bf02fad81 Merge pull request #41050 from terminalmage/git_pillar-tests
Fix git_pillar integration tests on Arch
2017-05-03 16:53:31 -06:00