mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #38787 from rallytime/merge-2016.11
[2016.11] Merge forward from 2016.3 to 2016.11
This commit is contained in:
commit
76df6a43f3
@ -90,14 +90,14 @@ the lines below, depending on the relevant Python version:
|
||||
|
||||
To be able to run integration tests which utilizes ZeroMQ transport, you also
|
||||
need to install additional requirements for it. Make sure you have installed
|
||||
the C compiler and development libraries and header files needed for your
|
||||
the C/C++ compiler and development libraries and header files needed for your
|
||||
Python version.
|
||||
|
||||
This is an example for RedHat-based operating systems:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
yum install gcc python-devel
|
||||
yum install gcc gcc-c++ python-devel
|
||||
pip install -r requirements/zeromq.txt
|
||||
|
||||
On Debian, Ubuntu or their derivatives run the following commands:
|
||||
|
@ -44,14 +44,14 @@ depending on your relevant version of Python:
|
||||
|
||||
To be able to run integration tests which utilizes ZeroMQ transport, you also
|
||||
need to install additional requirements for it. Make sure you have installed
|
||||
the C compiler and development libraries and header files needed for your
|
||||
the C/C++ compiler and development libraries and header files needed for your
|
||||
Python version.
|
||||
|
||||
This is an example for RedHat-based operating systems:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
yum install gcc python-devel
|
||||
yum install gcc gcc-c++ python-devel
|
||||
pip install -r requirements/zeromq.txt
|
||||
|
||||
On Debian, Ubuntu or their derivatives run the following commands:
|
||||
|
@ -3439,18 +3439,23 @@ def api_config(path):
|
||||
Read in the Salt Master config file and add additional configs that
|
||||
need to be stubbed out for salt-api
|
||||
'''
|
||||
# Let's grab a copy of salt's master opts
|
||||
opts = client_config(path, defaults=DEFAULT_MASTER_OPTS)
|
||||
# Let's override them with salt-api's required defaults
|
||||
api_opts = DEFAULT_API_OPTS
|
||||
api_opts.update({
|
||||
# Let's grab a copy of salt-api's required defaults
|
||||
opts = DEFAULT_API_OPTS
|
||||
|
||||
# Let's override them with salt's master opts
|
||||
opts.update(client_config(path, defaults=DEFAULT_MASTER_OPTS))
|
||||
|
||||
# Let's set the pidfile and log_file values in opts to api settings
|
||||
opts.update({
|
||||
'pidfile': opts.get('api_pidfile', DEFAULT_API_OPTS['api_pidfile']),
|
||||
'log_file': opts.get('api_logfile', DEFAULT_API_OPTS['api_logfile']),
|
||||
})
|
||||
opts.update(api_opts)
|
||||
|
||||
prepend_root_dir(opts, [
|
||||
'api_pidfile',
|
||||
'api_logfile',
|
||||
'log_file',
|
||||
'pidfile'
|
||||
])
|
||||
return opts
|
||||
|
||||
|
@ -608,7 +608,8 @@ def make_repo(repodir,
|
||||
|
||||
except SaltInvocationError:
|
||||
raise SaltInvocationError(
|
||||
'Public and Private key files associated with Pillar data and \'keyid\' {0} could not be found'
|
||||
'Public and Private key files associated with Pillar data and \'keyid\' '
|
||||
'{0} could not be found'
|
||||
.format(keyid)
|
||||
)
|
||||
|
||||
@ -623,7 +624,8 @@ def make_repo(repodir,
|
||||
|
||||
if local_keyid is None:
|
||||
raise SaltInvocationError(
|
||||
'\'keyid\' was not found in gpg keyring'
|
||||
'The key ID \'{0}\' was not found in GnuPG keyring at \'{1}\''
|
||||
.format(keyid, gnupghome)
|
||||
)
|
||||
|
||||
_check_repo_sign_utils_support()
|
||||
|
@ -430,7 +430,8 @@ def make_repo(repodir,
|
||||
|
||||
except SaltInvocationError:
|
||||
raise SaltInvocationError(
|
||||
'Public and Private key files associated with Pillar data and \'keyid\' {0} could not be found'
|
||||
'Public and Private key files associated with Pillar data and \'keyid\' '
|
||||
'{0} could not be found'
|
||||
.format(keyid)
|
||||
)
|
||||
|
||||
@ -445,14 +446,17 @@ def make_repo(repodir,
|
||||
|
||||
if local_keyid is None:
|
||||
raise SaltInvocationError(
|
||||
'\'keyid\' was not found in gpg keyring'
|
||||
'The key ID \'{0}\' was not found in GnuPG keyring at \'{1}\''
|
||||
.format(keyid, gnupghome)
|
||||
)
|
||||
|
||||
if use_passphrase:
|
||||
phrase = __salt__['pillar.get']('gpg_passphrase')
|
||||
|
||||
if local_uids:
|
||||
define_gpg_name = '--define=\'%_signature gpg\' --define=\'%_gpg_name {0}\''.format(local_uids[0])
|
||||
define_gpg_name = '--define=\'%_signature gpg\' --define=\'%_gpg_name {0}\''.format(
|
||||
local_uids[0]
|
||||
)
|
||||
|
||||
# need to update rpm with public key
|
||||
cmd = 'rpm --import {0}'.format(pkg_pub_key_file)
|
||||
|
119
tests/unit/config/api_test.py
Normal file
119
tests/unit/config/api_test.py
Normal file
@ -0,0 +1,119 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
tests.unit.api_config_test
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt Testing libs
|
||||
from salttesting import skipIf, TestCase
|
||||
from salttesting.helpers import destructiveTest, ensure_in_syspath
|
||||
from salttesting.mock import (
|
||||
MagicMock,
|
||||
NO_MOCK,
|
||||
NO_MOCK_REASON,
|
||||
patch
|
||||
)
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import Salt libs
|
||||
import salt.config
|
||||
|
||||
MOCK_MASTER_DEFAULT_OPTS = {
|
||||
'log_file': '/var/log/salt/master',
|
||||
'pidfile': '/var/run/salt-master.pid',
|
||||
'root_dir': '/'
|
||||
}
|
||||
|
||||
|
||||
@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||
class APIConfigTestCase(TestCase):
|
||||
'''
|
||||
TestCase for the api_config function in salt.config.__init__.py
|
||||
'''
|
||||
|
||||
@patch('salt.config.client_config', MagicMock(return_value=MOCK_MASTER_DEFAULT_OPTS))
|
||||
def test_api_config_log_file_values(self):
|
||||
'''
|
||||
Tests the opts value of the 'log_file' after running through the
|
||||
various default dict updates. 'log_file' should be updated to match
|
||||
the DEFAULT_API_OPTS 'api_logfile' value.
|
||||
'''
|
||||
ret = salt.config.api_config('/some/fake/path')
|
||||
self.assertEqual(ret['log_file'], '/var/log/salt/api')
|
||||
|
||||
@patch('salt.config.client_config', MagicMock(return_value=MOCK_MASTER_DEFAULT_OPTS))
|
||||
def test_api_config_pidfile_values(self):
|
||||
'''
|
||||
Tests the opts value of the 'pidfile' after running through the
|
||||
various default dict updates. 'pidfile' should be updated to match
|
||||
the DEFAULT_API_OPTS 'api_pidfile' value.
|
||||
'''
|
||||
ret = salt.config.api_config('/some/fake/path')
|
||||
self.assertEqual(ret['pidfile'], '/var/run/salt-api.pid')
|
||||
|
||||
@destructiveTest
|
||||
def test_master_config_file_overrides_defaults(self):
|
||||
'''
|
||||
Tests the opts value of the api config values after running through the
|
||||
various default dict updates that should be overridden by settings in
|
||||
the user's master config file.
|
||||
'''
|
||||
# Copy DEFAULT_API_OPTS to restore after the test
|
||||
default_api_opts = salt.config.DEFAULT_API_OPTS.copy()
|
||||
|
||||
foo_dir = '/foo/bar/baz'
|
||||
hello_dir = '/hello/world'
|
||||
mock_master_config = {
|
||||
'api_pidfile': foo_dir,
|
||||
'api_logfile': hello_dir,
|
||||
'rest_timeout': 5
|
||||
}
|
||||
mock_master_config.update(MOCK_MASTER_DEFAULT_OPTS.copy())
|
||||
|
||||
with patch('salt.config.client_config',
|
||||
MagicMock(return_value=mock_master_config)):
|
||||
ret = salt.config.api_config('/some/fake/path')
|
||||
self.assertEqual(ret['rest_timeout'], 5)
|
||||
self.assertEqual(ret['api_pidfile'], foo_dir)
|
||||
self.assertEqual(ret['pidfile'], foo_dir)
|
||||
self.assertEqual(ret['api_logfile'], hello_dir)
|
||||
self.assertEqual(ret['log_file'], hello_dir)
|
||||
|
||||
# Reset DEFAULT_API_OPTS settings as to not interfere with other unit tests
|
||||
salt.config.DEFAULT_API_OPTS = default_api_opts
|
||||
|
||||
@destructiveTest
|
||||
def test_api_config_prepend_root_dirs_return(self):
|
||||
'''
|
||||
Tests the opts value of the api_logfile, log_file, api_pidfile, and pidfile
|
||||
when a custom root directory is used. This ensures that each of these
|
||||
values is present in the list of opts keys that should have the root_dir
|
||||
prepended when the api_config function returns the opts dictionary.
|
||||
'''
|
||||
# Copy DEFAULT_API_OPTS to restore after the test
|
||||
default_api_opts = salt.config.DEFAULT_API_OPTS.copy()
|
||||
|
||||
mock_log = '/mock/root/var/log/salt/api'
|
||||
mock_pid = '/mock/root/var/run/salt-api.pid'
|
||||
|
||||
mock_master_config = MOCK_MASTER_DEFAULT_OPTS.copy()
|
||||
mock_master_config['root_dir'] = '/mock/root/'
|
||||
|
||||
with patch('salt.config.client_config',
|
||||
MagicMock(return_value=mock_master_config)):
|
||||
ret = salt.config.api_config('/some/fake/path')
|
||||
self.assertEqual(ret['api_logfile'], mock_log)
|
||||
self.assertEqual(ret['log_file'], mock_log)
|
||||
self.assertEqual(ret['api_pidfile'], mock_pid)
|
||||
self.assertEqual(ret['pidfile'], mock_pid)
|
||||
|
||||
# Reset DEFAULT_API_OPTS settings as to not interfere with other unit tests
|
||||
salt.config.DEFAULT_API_OPTS = default_api_opts
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(APIConfigTestCase, needs_daemon=False)
|
Loading…
Reference in New Issue
Block a user