mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Simplify the Syndic configuration testing.
* Inherit the master configuration file on the syndic one. * Recreate the Syndic on the test. Don't pass it as a module global.
This commit is contained in:
parent
54ea179467
commit
e467b1e00b
@ -95,7 +95,6 @@ def run_tests(TestCase, needs_daemon=True):
|
||||
parser.finalize(0)
|
||||
|
||||
|
||||
SYNDIC = None
|
||||
class TestDaemon(object):
|
||||
'''
|
||||
Set up the master and minion daemons, and run related cases
|
||||
@ -113,8 +112,14 @@ class TestDaemon(object):
|
||||
self.master_opts = salt.config.master_config(
|
||||
os.path.join(INTEGRATION_TEST_DIR, 'files', 'conf', 'master')
|
||||
)
|
||||
minion_config_path = os.path.join(INTEGRATION_TEST_DIR, 'files', 'conf', 'minion')
|
||||
minion_config_path = os.path.join(
|
||||
INTEGRATION_TEST_DIR, 'files', 'conf', 'minion'
|
||||
)
|
||||
self.minion_opts = salt.config.minion_config(minion_config_path)
|
||||
self.syndic_opts = salt.config.syndic_config(
|
||||
os.path.join(INTEGRATION_TEST_DIR, 'files', 'conf', 'syndic'),
|
||||
minion_config_path
|
||||
)
|
||||
|
||||
#if sys.version_info < (2, 7):
|
||||
# self.minion_opts['multiprocessing'] = False
|
||||
@ -129,7 +134,6 @@ class TestDaemon(object):
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Set up config options that require internal data
|
||||
self.master_opts['pillar_roots'] = {
|
||||
'base': [os.path.join(FILES, 'pillar', 'base')]
|
||||
@ -152,23 +156,6 @@ class TestDaemon(object):
|
||||
]
|
||||
# clean up the old files
|
||||
self._clean()
|
||||
if not os.path.isdir(TMP):
|
||||
os.makedirs(TMP)
|
||||
|
||||
# make a temporary configuration merging master and syndic bits
|
||||
config_content = (
|
||||
open(os.path.join(
|
||||
INTEGRATION_TEST_DIR, 'files', 'conf', 'master')).read()
|
||||
+
|
||||
open(os.path.join(
|
||||
INTEGRATION_TEST_DIR, 'files', 'conf', 'syndic')).read()
|
||||
)
|
||||
syndic_conf_path = os.path.join( TMP, 'syndic.conf')
|
||||
fic = open(syndic_conf_path, 'w')
|
||||
fic.write(config_content)
|
||||
fic.close()
|
||||
self.syndic_opts = salt.config.syndic_config(
|
||||
syndic_conf_path, minion_config_path)
|
||||
|
||||
# Point the config values to the correct temporary paths
|
||||
for name in ('hosts', 'aliases'):
|
||||
@ -253,11 +240,6 @@ class TestDaemon(object):
|
||||
self.pre_setup_minions()
|
||||
self.setup_minions()
|
||||
|
||||
# make global module vars to be accessible from
|
||||
# testcases
|
||||
import integration
|
||||
integration.SYNDIC = syndic
|
||||
|
||||
if self.parser.options.sysinfo:
|
||||
from salt import version
|
||||
print_header('~~~~~~~ Versions Report ', inline=True)
|
||||
|
@ -4,6 +4,8 @@ from salttesting.helpers import ensure_in_syspath
|
||||
ensure_in_syspath('../../')
|
||||
|
||||
# Import salt libs
|
||||
import salt.config
|
||||
import salt.minion
|
||||
import integration
|
||||
|
||||
|
||||
@ -12,7 +14,16 @@ class TestSyndic(integration.SyndicCase):
|
||||
Validate the syndic interface by testing the test module
|
||||
'''
|
||||
def test_config(self):
|
||||
syndic = integration.SYNDIC
|
||||
syndic_conf_path = os.path.join(
|
||||
integration.INTEGRATION_TEST_DIR, 'files', 'conf', 'syndic'
|
||||
)
|
||||
minion_config_path = os.path.join(
|
||||
integration.INTEGRATION_TEST_DIR, 'files', 'conf', 'minion'
|
||||
)
|
||||
syndic_opts = salt.config.syndic_config(
|
||||
syndic_conf_path, minion_config_path
|
||||
)
|
||||
syndic = salt.minion.Syndic(syndic_opts)
|
||||
# id & pki dir are shared & so configured on the minion side
|
||||
self.assertEquals(syndic.opts['id'], 'minion')
|
||||
self.assertEquals(syndic.opts['pki_dir'], '/tmp/salttest/pki')
|
||||
@ -27,10 +38,8 @@ class TestSyndic(integration.SyndicCase):
|
||||
self.assertEquals(syndic.opts['pidfile'], '/tmp/salttest/osyndic.pid')
|
||||
# Show that the options of localclient that repub to local master
|
||||
# are not merged with syndic ones
|
||||
self.assertEquals(
|
||||
syndic.opts['_master_conf_file'],
|
||||
os.path.join(integration.INTEGRATION_TEST_DIR, 'files', 'conf', 'minion'))
|
||||
self.assertEquals(syndic.opts['_minion_conf_file'], '/tmp/salt-tests-tmpdir/syndic.conf')
|
||||
self.assertEquals(syndic.opts['_master_conf_file'], minion_config_path)
|
||||
self.assertEquals(syndic.opts['_minion_conf_file'], syndic_conf_path)
|
||||
|
||||
def test_ping(self):
|
||||
'''
|
||||
|
@ -1,3 +1,4 @@
|
||||
include: master
|
||||
# syndic basic config
|
||||
# same config as master ./except the syndic bits
|
||||
# in the TestCase we add at the top of the configfile the content of ./master
|
||||
|
Loading…
Reference in New Issue
Block a user