Merge Forward #52593

This commit is contained in:
twangboy 2019-07-02 18:28:03 -06:00
parent 491bfa8c4d
commit 43dd7b325e
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB
4 changed files with 47 additions and 36 deletions

View file

@ -776,8 +776,9 @@ class SaltDistribution(distutils.dist.Distribution):
* salt-call
* salt-cp
* salt-minion
* salt-syndic
* salt-unity
* salt-proxy
* spm
When packaged for salt-ssh, the following scripts should be installed:
* salt-call
@ -785,7 +786,8 @@ class SaltDistribution(distutils.dist.Distribution):
* salt-ssh
* salt-cloud
Under windows, the following scripts should be omitted from the salt-ssh package:
Under windows, the following scripts should be omitted from the salt-ssh
package:
* salt-cloud
* salt-run
@ -980,10 +982,10 @@ class SaltDistribution(distutils.dist.Distribution):
if IS_WINDOWS_PLATFORM:
data_files[0][1].extend(['doc/man/salt-cp.1',
'doc/man/salt-key.1',
'doc/man/salt-master.1',
'doc/man/salt-minion.1',
'doc/man/salt-proxy.1',
'doc/man/salt-unity.1'])
'doc/man/salt-syndic.1',
'doc/man/salt-unity.1',
'doc/man/spm.1'])
return data_files
# *nix, so, we need all man pages
@ -1032,13 +1034,12 @@ class SaltDistribution(distutils.dist.Distribution):
return scripts
if IS_WINDOWS_PLATFORM:
scripts.extend(['scripts/salt',
'scripts/salt-cp',
scripts.extend(['scripts/salt-cp',
'scripts/salt-key',
'scripts/salt-master',
'scripts/salt-minion',
'scripts/salt-proxy',
'scripts/salt-unity'])
'scripts/salt-syndic',
'scripts/salt-unity',
'scripts/spm'])
return scripts
# *nix, so, we need all scripts
@ -1049,10 +1050,10 @@ class SaltDistribution(distutils.dist.Distribution):
'scripts/salt-key',
'scripts/salt-master',
'scripts/salt-minion',
'scripts/salt-proxy',
'scripts/salt-ssh',
'scripts/salt-syndic',
'scripts/salt-unity',
'scripts/salt-proxy',
'scripts/spm'])
return scripts
@ -1069,11 +1070,10 @@ class SaltDistribution(distutils.dist.Distribution):
return {'console_scripts': scripts}
if IS_WINDOWS_PLATFORM:
scripts.extend(['salt = salt.scripts:salt_main',
'salt-cp = salt.scripts:salt_cp',
scripts.extend(['salt-cp = salt.scripts:salt_cp',
'salt-key = salt.scripts:salt_key',
'salt-master = salt.scripts:salt_master',
'salt-minion = salt.scripts:salt_minion',
'salt-syndic = salt.scripts:salt_syndic',
'salt-unity = salt.scripts:salt_unity',
'spm = salt.scripts:salt_spm'])
return {'console_scripts': scripts}

View file

@ -21,7 +21,6 @@ import salt.utils.platform
log = logging.getLogger(__name__)
@skipIf(salt.utils.platform.is_windows(), 'Skip on Windows OS')
class ProxyTest(testprogram.TestProgramCase):
'''
Various integration tests for the salt-proxy executable.
@ -30,8 +29,6 @@ class ProxyTest(testprogram.TestProgramCase):
def test_exit_status_no_proxyid(self):
'''
Ensure correct exit status when --proxyid argument is missing.
Skip on Windows because daemonization not supported
'''
proxy = testprogram.TestDaemonSaltProxy(
@ -40,12 +37,14 @@ class ProxyTest(testprogram.TestProgramCase):
)
# Call setup here to ensure config and script exist
proxy.setup()
# Needed due to verbatim_args=True
args = ['--config-dir', proxy.abs_path(proxy.config_dir)]
if not salt.utils.platform.is_windows():
args.append('-d')
stdout, stderr, status = proxy.run(
args=[
'--config-dir', proxy.abs_path(proxy.config_dir), # Needed due to verbatim_args=True
'-d',
],
verbatim_args=True, # prevents --proxyid from being added automatically
args=args,
# verbatim_args prevents --proxyid from being added automatically
verbatim_args=True,
catch_stderr=True,
with_retcode=True,
# The proxy minion had a bug where it would loop forever
@ -65,11 +64,13 @@ class ProxyTest(testprogram.TestProgramCase):
# cause timeout exceptions and respective traceback
proxy.shutdown()
# Hangs on Windows. You can add a timeout to the proxy.run command, but then
# it just times out.
@skipIf(salt.utils.platform.is_windows(), 'Test hangs on Windows')
def test_exit_status_unknown_user(self):
'''
Ensure correct exit status when the proxy is configured to run as an unknown user.
Skip on Windows because daemonization not supported
Ensure correct exit status when the proxy is configured to run as an
unknown user.
'''
proxy = testprogram.TestDaemonSaltProxy(
@ -80,7 +81,7 @@ class ProxyTest(testprogram.TestProgramCase):
# Call setup here to ensure config and script exist
proxy.setup()
stdout, stderr, status = proxy.run(
args=['-d'],
arg=['-d'] if not salt.utils.platform.is_windows() else [],
catch_stderr=True,
with_retcode=True,
)
@ -100,9 +101,8 @@ class ProxyTest(testprogram.TestProgramCase):
# pylint: disable=invalid-name
def test_exit_status_unknown_argument(self):
'''
Ensure correct exit status when an unknown argument is passed to salt-proxy.
Skip on Windows because daemonization not supported
Ensure correct exit status when an unknown argument is passed to
salt-proxy.
'''
proxy = testprogram.TestDaemonSaltProxy(
@ -111,8 +111,11 @@ class ProxyTest(testprogram.TestProgramCase):
)
# Call setup here to ensure config and script exist
proxy.setup()
args = ['--unknown-argument']
if not salt.utils.platform.is_windows():
args.append('-b')
stdout, stderr, status = proxy.run(
args=['-d', '--unknown-argument'],
args=args,
catch_stderr=True,
with_retcode=True,
)
@ -128,13 +131,15 @@ class ProxyTest(testprogram.TestProgramCase):
# cause timeout exceptions and respective traceback
proxy.shutdown()
# Hangs on Windows. You can add a timeout to the proxy.run command, but then
# it just times out.
@skipIf(salt.utils.platform.is_windows(), 'Test hangs on Windows')
def test_exit_status_correct_usage(self):
'''
Ensure correct exit status when salt-proxy starts correctly.
Skip on Windows because daemonization not supported
'''
proxy = testprogram.TestDaemonSaltProxy(
name='proxy-correct_usage',
parent_dir=self._test_dir,
@ -142,7 +147,7 @@ class ProxyTest(testprogram.TestProgramCase):
# Call setup here to ensure config and script exist
proxy.setup()
stdout, stderr, status = proxy.run(
args=['-d'],
args=['-d'] if not salt.utils.platform.is_windows() else [],
catch_stderr=True,
with_retcode=True,
)

View file

@ -399,6 +399,11 @@ class TestProgram(six.with_metaclass(TestProgramMeta, object)):
cmd_env = dict(os.environ)
cmd_env.update(env_delta)
if salt.utils.platform.is_windows() and six.PY2:
for k, v in cmd_env.items():
if isinstance(k, six.text_type) or isinstance(v, six.text_type):
cmd_env[k.encode('ascii')] = v.encode('ascii')
popen_kwargs = {
'shell': self.shell,
'stdout': subprocess.PIPE,
@ -822,7 +827,8 @@ class TestDaemon(TestProgram):
continue
except psutils.AccessDenied:
# We might get access denied if not running as root
continue
if not salt.utils.platform.is_windows():
raise
if any((cmdline == proc_cmdline[n:n + cmd_len])
for n in range(len(proc_cmdline) - cmd_len + 1)):
ret.append(proc)

View file

@ -143,7 +143,7 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'roster'),
arg_str
)
return self.run_script('salt-ssh', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr, raw=True)
return self.run_script('salt-ssh', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr, raw=True, timeout=timeout)
def run_run(self,
arg_str,
@ -901,12 +901,12 @@ class SyndicCase(TestCase, SaltClientTestCaseMixin):
'''
_salt_client_config_file_name_ = 'syndic_master'
def run_function(self, function, arg=()):
def run_function(self, function, arg=(), timeout=90):
'''
Run a single salt function and condition the return down to match the
behavior of the raw function call
'''
orig = self.client.cmd('minion', function, arg, timeout=25)
orig = self.client.cmd('minion', function, arg, timeout=timeout)
if 'minion' not in orig:
self.skipTest(
'WARNING(SHOULD NOT HAPPEN #1935): Failed to get a reply '