Merge branch '2017.7' into bp-48730

This commit is contained in:
Nicole Thomas 2018-08-03 17:08:07 -04:00 committed by GitHub
commit 57aa204c9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 10 deletions

View file

@ -29,13 +29,13 @@ pipeline {
parallel {
stage('salt linting') {
steps {
sh 'eval "$(pyenv init -)"; tox -e pylint-salt $(find salt/ -name "*.py" -exec git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" setup.py {} +) | tee pylint-report.xml'
sh 'eval "$(pyenv init - --no-rehash)"; tox -e pylint-salt $(find salt/ -name "*.py" -exec git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" setup.py {} +) | tee pylint-report.xml'
archiveArtifacts artifacts: 'pylint-report.xml'
}
}
stage('test linting') {
steps {
sh 'eval "$(pyenv init -)"; tox -e pylint-tests $(find tests/ -name "*.py" -exec git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" {} +) | tee pylint-report-tests.xml'
sh 'eval "$(pyenv init - --no-rehash)"; tox -e pylint-tests $(find tests/ -name "*.py" -exec git diff --name-only "origin/$CHANGE_TARGET" "origin/$BRANCH_NAME" {} +) | tee pylint-report-tests.xml'
archiveArtifacts artifacts: 'pylint-report-tests.xml'
}
}

View file

@ -21,7 +21,7 @@ management.
The default job cache is a temporary cache and jobs will be stored for 24
hours. If the default cache needs to store jobs for a different period the
time can be easily adjusted by changing the `keep_jobs` parameter in the
time can be easily adjusted by changing the ``keep_jobs`` parameter in the
Salt Master configuration file. The value passed in is measured via hours:
@ -47,7 +47,7 @@ checking for and preventing JID collisions.
The default location for the job cache is in the ``/var/cache/salt/master/jobs/``
directory.
Setting the :conf_master:`job_cache`` to ``False`` in addition to setting
Setting the :conf_master:`job_cache` to ``False`` in addition to setting
the :conf_master:`keep_jobs` option to a smaller value, such as ``1``, in the Salt
Master configuration file will reduce the size of the Default Job Cache, and thus
the burden on the Salt Master.

View file

@ -2127,9 +2127,12 @@ def script(source,
os.chmod(path, 320)
os.chown(path, __salt__['file.user_to_uid'](runas), -1)
path = _cmd_quote(path)
if salt.utils.is_windows() and shell.lower() != 'powershell':
cmd_path = _cmd_quote(path, escape=False)
else:
cmd_path = _cmd_quote(path)
ret = _run(path + ' ' + str(args) if args else path,
ret = _run(cmd_path + ' ' + str(args) if args else cmd_path,
cwd=cwd,
stdin=stdin,
output_loglevel=output_loglevel,

View file

@ -166,7 +166,7 @@ def get_sam_name(username):
return '\\'.join([domain, username])
def escape_argument(arg):
def escape_argument(arg, escape=True):
'''
Escape the argument for the cmd.exe shell.
See http://blogs.msdn.com/b/twistylittlepassagesallalike/archive/2011/04/23/everyone-quotes-arguments-the-wrong-way.aspx
@ -177,12 +177,19 @@ def escape_argument(arg):
Args:
arg (str): a single command line argument to escape for the cmd.exe shell
Kwargs:
escape (bool): True will call the escape_for_cmd_exe() function
which escapes the characters '()%!^"<>&|'. False
will not call the function and only quotes the cmd
Returns:
str: an escaped string suitable to be passed as a program argument to the cmd.exe shell
'''
if not arg or re.search(r'(["\s])', arg):
arg = '"' + arg.replace('"', r'\"') + '"'
if not escape:
return arg
return escape_for_cmd_exe(arg)

View file

@ -9,6 +9,7 @@ import textwrap
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
from tests.support.helpers import (
destructiveTest,
skip_if_binaries_missing,
@ -71,7 +72,7 @@ class CMDModuleTest(ModuleCase):
'''
self.assertEqual(self.run_function('cmd.run_stdout',
['echo "cheese"']).rstrip(),
'cheese')
'cheese' if not salt.utils.is_windows() else '"cheese"')
def test_stderr(self):
'''
@ -86,7 +87,7 @@ class CMDModuleTest(ModuleCase):
['echo "cheese" 1>&2',
'shell={0}'.format(shell)], python_shell=True
).rstrip(),
'cheese')
'cheese' if not salt.utils.is_windows() else '"cheese"')
def test_run_all(self):
'''
@ -107,7 +108,7 @@ class CMDModuleTest(ModuleCase):
self.assertTrue(isinstance(ret.get('retcode'), int))
self.assertTrue(isinstance(ret.get('stdout'), six.string_types))
self.assertTrue(isinstance(ret.get('stderr'), six.string_types))
self.assertEqual(ret.get('stderr').rstrip(), 'cheese')
self.assertEqual(ret.get('stderr').rstrip(), 'cheese' if not salt.utils.is_windows() else '"cheese"')
def test_retcode(self):
'''
@ -217,10 +218,13 @@ class CMDModuleTest(ModuleCase):
'''
cmd = '''echo 'SELECT * FROM foo WHERE bar="baz"' '''
expected_result = 'SELECT * FROM foo WHERE bar="baz"'
if salt.utils.is_windows():
expected_result = '\'SELECT * FROM foo WHERE bar="baz"\''
result = self.run_function('cmd.run_stdout', [cmd]).strip()
self.assertEqual(result, expected_result)
@skip_if_not_root
@skipIf(salt.utils.is_windows, 'skip windows, requires password')
def test_quotes_runas(self):
'''
cmd.run with quoted command
@ -234,6 +238,7 @@ class CMDModuleTest(ModuleCase):
runas=runas).strip()
self.assertEqual(result, expected_result)
@skipIf(not salt.utils.which_bin('sleep'), 'sleep cmd not installed')
def test_timeout(self):
'''
cmd.run trigger timeout
@ -244,6 +249,7 @@ class CMDModuleTest(ModuleCase):
python_shell=True)
self.assertTrue('Timed out' in out)
@skipIf(not salt.utils.which_bin('sleep'), 'sleep cmd not installed')
def test_timeout_success(self):
'''
cmd.run sufficient timeout to succeed

View file

@ -8,6 +8,7 @@ integration.modules.test_autoruns
integration.modules.test_beacons
integration.modules.test_config
integration.modules.test_cp
integration.modules.test_cmdmod
integration.modules.test_data
integration.modules.test_disk
integration.modules.test_firewall