From b3b5ecc6ff265609503619d9625ae2ef7bcc5cdd Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Mon, 20 Nov 2017 16:25:03 -0500 Subject: [PATCH 1/2] Add pillar.items test for masterless --- tests/integration/__init__.py | 6 ++++++ tests/integration/shell/test_call.py | 11 +++++++++++ tests/support/case.py | 11 +++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index 17ecb2d172..d92c216010 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -805,6 +805,12 @@ class TestDaemon(object): os.path.join(FILES, 'pillar', 'base'), ] } + minion_opts['pillar_roots'] = { + 'base': [ + RUNTIME_VARS.TMP_PILLAR_TREE, + os.path.join(FILES, 'pillar', 'base'), + ] + } master_opts['file_roots'] = syndic_master_opts['file_roots'] = { 'base': [ os.path.join(FILES, 'file', 'base'), diff --git a/tests/integration/shell/test_call.py b/tests/integration/shell/test_call.py index 99d2d6eebb..e76278574b 100644 --- a/tests/integration/shell/test_call.py +++ b/tests/integration/shell/test_call.py @@ -441,6 +441,17 @@ class CallTest(ShellCase, testprogram.TestProgramCase, ShellCaseCommonTestsMixin log.debug('salt-call output:\n\n%s', '\n'.join(ret)) self.fail('CLI pillar override not found in pillar data') + def test_pillar_items_masterless(self): + ''' + Test to ensure we get expected output + from pillar.items with salt-call + ''' + get_items = self.run_call('pillar.items', local=True) + exp_out = [' - Lancelot', ' - Galahad', ' - Bedevere', + ' monty:', ' python'] + for out in exp_out: + self.assertIn(out, get_items) + def tearDown(self): ''' Teardown method to remove installed packages diff --git a/tests/support/case.py b/tests/support/case.py index a7a5e63c23..99a11e95f7 100644 --- a/tests/support/case.py +++ b/tests/support/case.py @@ -210,8 +210,10 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin): arg_str = '--config-dir {0} {1}'.format(self.get_config_dir(), arg_str) return self.run_script('salt-cp', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) - def run_call(self, arg_str, with_retcode=False, catch_stderr=False): - arg_str = '--config-dir {0} {1}'.format(self.get_config_dir(), arg_str) + def run_call(self, arg_str, local=False, with_retcode=False, catch_stderr=False): + arg_str = '{0} --config-dir {1} {2}'.format('--local' if local else '', + self.get_config_dir(), arg_str) + return self.run_script('salt-call', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) def run_cloud(self, arg_str, catch_stderr=False, timeout=None): @@ -549,11 +551,12 @@ class ShellCase(ShellTestCase, AdaptedConfigurationTestCaseMixin, ScriptPathMixi catch_stderr=catch_stderr, timeout=60) - def run_call(self, arg_str, with_retcode=False, catch_stderr=False): + def run_call(self, arg_str, local=False, with_retcode=False, catch_stderr=False): ''' Execute salt-call. ''' - arg_str = '--config-dir {0} {1}'.format(self.get_config_dir(), arg_str) + arg_str = '{0} --config-dir {1} {2}'.format('--local' if local else '', + self.get_config_dir(), arg_str) return self.run_script('salt-call', arg_str, with_retcode=with_retcode, From 69134e83cafbe9cbb440125f37b735357402684c Mon Sep 17 00:00:00 2001 From: Ch3LL Date: Wed, 22 Nov 2017 15:50:29 -0500 Subject: [PATCH 2/2] Change order of local kwarg in run_call method --- tests/support/case.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/support/case.py b/tests/support/case.py index 99a11e95f7..63857d4f50 100644 --- a/tests/support/case.py +++ b/tests/support/case.py @@ -210,7 +210,7 @@ class ShellTestCase(TestCase, AdaptedConfigurationTestCaseMixin): arg_str = '--config-dir {0} {1}'.format(self.get_config_dir(), arg_str) return self.run_script('salt-cp', arg_str, with_retcode=with_retcode, catch_stderr=catch_stderr) - def run_call(self, arg_str, local=False, with_retcode=False, catch_stderr=False): + def run_call(self, arg_str, with_retcode=False, catch_stderr=False, local=False): arg_str = '{0} --config-dir {1} {2}'.format('--local' if local else '', self.get_config_dir(), arg_str) @@ -551,7 +551,7 @@ class ShellCase(ShellTestCase, AdaptedConfigurationTestCaseMixin, ScriptPathMixi catch_stderr=catch_stderr, timeout=60) - def run_call(self, arg_str, local=False, with_retcode=False, catch_stderr=False): + def run_call(self, arg_str, with_retcode=False, catch_stderr=False, local=False): ''' Execute salt-call. '''