Commit Graph

94 Commits

Author SHA1 Message Date
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
Erik Johnson
f77393b80d Skip git_pillar integration tests on cent6
Cent6 has too old of a version of git to handle the make_repo func that
spawns the git repos used in these tests.
2017-05-03 16:36:36 -05:00
Erik Johnson
a94d081004 Add check for git-http-backend
This allows for more graceful test failures when the libexec dir is
different from what the test class determines it should be.
2017-05-03 15:16:16 -05:00
Erik Johnson
33515f6a14 Fix git_pillar integration tests on Arch
The location of the git-http-backend is within /usr/lib instead of
/usr/libexec.

This also uncomments a line that was commented out for troubleshooting
purposes.
2017-05-03 14:49:14 -05:00
twangboy
c7d164423e Increase timeout of run_function 2017-05-02 16:01:06 -06:00
Erik Johnson
39157b40ed Fix some git_pillar integration test failures
For some reason these were not failing when I opened #40777, but now
that the PR is merged are failing for PR builds (as well as locally in
my test env). This fixes those failures.
2017-05-01 17:13:42 -05:00
Mike Place
f766c97e26 Merge pull request #40777 from terminalmage/issue39349
Add git_pillar integration tests
2017-05-01 13:51:19 -06:00
Erik Johnson
402be207b2 Skip Pygit2 tests until EPEL fixes pygit2/libgit2 version mismatch
We can revert this commit once they get the updated pygit2 pushed to
EPEL stable.
2017-04-28 13:25:02 -05:00
Pedro Algarvio
7b503e562b
Use setUpClass instead of __init__ 2017-04-28 13:33:37 +01:00
Pedro Algarvio
0ae04c01ef
Delete all attributes even strings, boolean, integers 2017-04-28 13:33:37 +01:00
Pedro Algarvio
88627d312f
Write the generated configuration into a config file 2017-04-28 13:33:36 +01:00
Pedro Algarvio
80b80e5416
Fix cherrypy memory leakage
* Clean its event/signal bus since our tests don't rely on those.
* No test class level dictionaries
2017-04-28 13:33:35 +01:00
Pedro Algarvio
41df7eca96
Use setUpClass instead of __init__ 2017-04-28 13:33:31 +01:00
Erik Johnson
9f27f362ca Add HTTP git_pillar integration tests for pygit2
Also work around ssh auth issues in Ubuntu
2017-04-27 18:20:18 -05:00
Erik Johnson
9e6361c6c8 Add GitPython HTTP git_pillar tests 2017-04-27 00:48:24 -05:00
Erik Johnson
3881b6e0f3 Prepare git_pillar test code for adding HTTP tests
This further abstracts some of the setup and teardown code so it can be
used for git-over-http tests.

It also moves the code that was originally added to the archive
state integration tests to create a local http server into
salt.support.helpers so that it can be more easily and portably used.
2017-04-24 11:00:39 -05:00
Pedro Algarvio
eb588c772a
Add missing futures import 2017-04-05 23:16:52 +01:00
Pedro Algarvio
cd1f7ba629
Let's use the system temp dir as it was to see if it fixes the test failure 2017-04-05 00:34:39 +01:00
Pedro Algarvio
c3417213d7
Make sure the socket's used are closed 2017-04-04 19:28:06 +01:00
Pedro Algarvio
61003bca0a
Take care of resource leakage on tests 2017-04-04 18:58:20 +01:00
Pedro Algarvio
42e35e13cc
Use mock to patch 2017-04-04 18:58:20 +01:00
Pedro Algarvio
008f0016e2
Make sure we close the spooled temporary file 2017-04-04 18:58:19 +01:00
Pedro Algarvio
104a2fb30c
Keep the same exception raised before the move 2017-04-04 18:04:39 +01:00
Pedro Algarvio
6a638620ba
Move base test case modules to tests.support.case 2017-04-04 18:04:39 +01:00
Pedro Algarvio
9af2ca8823
No need to load all modules docs.
This should reduce memory usage as well as speeding up the decorator
2017-04-04 18:04:38 +01:00
Pedro Algarvio
b94992f544
Some more RUNTIME_CONFIGS and RUNTIME_VARS fixes 2017-04-04 18:04:38 +01:00
Pedro Algarvio
8031ac0209
Move mixins to tests.support.mixins.
The adapted config mixin get config methods are not static methods
2017-04-04 17:29:34 +01:00
Pedro Algarvio
8056479853
This argument is not required when used as a ctx manager 2017-04-01 14:26:11 +01:00
Pedro Algarvio
174625618a
Add mixin to assert XML equality 2017-04-01 14:22:58 +01:00
Pedro Algarvio
9a11538b54
Stop using deprecated TestCase methods 2017-04-01 14:22:57 +01:00
Pedro Algarvio
9cf1b37b54
Take care of some more deprecated TestCase methods 2017-04-01 14:22:57 +01:00
Pedro Algarvio
f82fa73fd7
Pylint disable 2017-04-01 14:22:55 +01:00