mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add regression test for excludes issue
This commit is contained in:
parent
28a7d2b81c
commit
3b449f11fc
8 changed files with 55 additions and 3 deletions
|
@ -0,0 +1,2 @@
|
|||
slsfile1-nop:
|
||||
test.nop
|
|
@ -0,0 +1,2 @@
|
|||
slsfile2-nop:
|
||||
test.nop
|
|
@ -0,0 +1,2 @@
|
|||
include:
|
||||
- issue-47182.stateA.newer
|
|
@ -0,0 +1,6 @@
|
|||
exclude:
|
||||
- sls: issue-47182.stateA
|
||||
|
||||
somestuff:
|
||||
cmd.run:
|
||||
- name: echo This supersedes the stuff previously done in issue-47182.stateA
|
10
tests/integration/files/file/base/issue-47182/stateB.sls
Normal file
10
tests/integration/files/file/base/issue-47182/stateB.sls
Normal file
|
@ -0,0 +1,10 @@
|
|||
include:
|
||||
- issue-47182.slsfile1
|
||||
- issue-47182.slsfile2
|
||||
|
||||
some-state:
|
||||
test.nop:
|
||||
- require:
|
||||
- sls: issue-47182.slsfile1
|
||||
- require_in:
|
||||
- sls: issue-47182.slsfile2
|
4
tests/integration/files/file/base/issue-47182/top.sls
Normal file
4
tests/integration/files/file/base/issue-47182/top.sls
Normal file
|
@ -0,0 +1,4 @@
|
|||
base:
|
||||
'*':
|
||||
- issue-47182.stateA
|
||||
- issue-47182.stateB
|
|
@ -48,6 +48,8 @@ SYS_TMP_DIR = os.path.abspath(os.path.realpath(
|
|||
))
|
||||
TMP = os.path.join(SYS_TMP_DIR, 'salt-tests-tmpdir')
|
||||
FILES = os.path.join(INTEGRATION_TEST_DIR, 'files')
|
||||
BASE_FILES = os.path.join(FILES, 'file', 'base')
|
||||
PROD_FILES = os.path.join(FILES, 'file', 'prod')
|
||||
PYEXEC = 'python{0}.{1}'.format(*sys.version_info)
|
||||
MOCKBIN = os.path.join(INTEGRATION_TEST_DIR, 'mockbin')
|
||||
SCRIPT_DIR = os.path.join(CODE_DIR, 'scripts')
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
from __future__ import absolute_import
|
||||
import copy
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
# Import Salt Testing libs
|
||||
|
@ -14,6 +15,7 @@ import tests.integration as integration
|
|||
from tests.support.unit import TestCase, skipIf
|
||||
from tests.support.mock import NO_MOCK, NO_MOCK_REASON, patch
|
||||
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
|
||||
from tests.support.paths import BASE_FILES
|
||||
|
||||
# Import Salt libs
|
||||
import salt.state
|
||||
|
@ -66,9 +68,9 @@ class StateCompilerTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
class HighStateTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
||||
def setUp(self):
|
||||
root_dir = tempfile.mkdtemp(dir=integration.TMP)
|
||||
state_tree_dir = os.path.join(root_dir, 'state_tree')
|
||||
self.state_tree_dir = os.path.join(root_dir, 'state_tree')
|
||||
cache_dir = os.path.join(root_dir, 'cachedir')
|
||||
for dpath in (root_dir, state_tree_dir, cache_dir):
|
||||
for dpath in (root_dir, self.state_tree_dir, cache_dir):
|
||||
if not os.path.isdir(dpath):
|
||||
os.makedirs(dpath)
|
||||
|
||||
|
@ -77,7 +79,7 @@ class HighStateTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
overrides['state_events'] = False
|
||||
overrides['id'] = 'match'
|
||||
overrides['file_client'] = 'local'
|
||||
overrides['file_roots'] = dict(base=[state_tree_dir])
|
||||
overrides['file_roots'] = dict(base=[self.state_tree_dir])
|
||||
overrides['cachedir'] = cache_dir
|
||||
overrides['test'] = False
|
||||
self.config = self.get_temp_config('minion', **overrides)
|
||||
|
@ -138,6 +140,28 @@ class HighStateTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
|||
self.assertEqual(state_usage_dict['base']['used'], ['state.a', 'state.b'])
|
||||
self.assertEqual(state_usage_dict['base']['unused'], ['state.c'])
|
||||
|
||||
def test_find_sls_ids_with_exclude(self):
|
||||
'''
|
||||
See https://github.com/saltstack/salt/issues/47182
|
||||
'''
|
||||
sls_dir = 'issue-47182'
|
||||
shutil.copytree(
|
||||
os.path.join(BASE_FILES, sls_dir),
|
||||
os.path.join(self.state_tree_dir, sls_dir)
|
||||
)
|
||||
shutil.move(
|
||||
os.path.join(self.state_tree_dir, sls_dir, 'top.sls'),
|
||||
self.state_tree_dir
|
||||
)
|
||||
# Manually compile the high data. We don't have to worry about all of
|
||||
# the normal error checking we do here since we know that all the SLS
|
||||
# files exist and there is no whitelist/blacklist being used.
|
||||
top = self.highstate.get_top()
|
||||
matches = self.highstate.top_matches(top)
|
||||
high, _ = self.highstate.render_highstate(matches)
|
||||
ret = salt.state.find_sls_ids('issue-47182.stateA.newer', high)
|
||||
self.assertEqual(ret, [('somestuff', 'cmd')])
|
||||
|
||||
|
||||
class TopFileMergeTestCase(TestCase, AdaptedConfigurationTestCaseMixin):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue