Merge pull request #45371 from rallytime/bp-45158

Back-port #45158 to 2017.7
This commit is contained in:
Nicole Thomas 2018-01-11 12:51:37 -05:00 committed by GitHub
commit 22c3efda06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 47 deletions

View File

@ -4,7 +4,6 @@ exclude:
include:
- include-test
{{ salt['runtests_helpers.get_salt_temp_dir_for_path']('exclude-test') }}:
file:
- managed
{{ pillar['exclude-test'] }}:
file.managed:
- source: salt://testfile

View File

@ -1,7 +1,6 @@
include:
- to-include-test
{{ salt['runtests_helpers.get_salt_temp_dir_for_path']('include-test') }}:
file:
- managed
{{ pillar['include-test'] }}:
file.managed:
- source: salt://testfile

View File

@ -8,7 +8,7 @@ test-state:
salt.state:
- tgt: '*'
- sls:
- include-test
- orch.target-test
cmd.run:
salt.function:

View File

@ -8,7 +8,7 @@ test-state:
salt.state:
- tgt: '*'
- sls:
- include-test
- orch.target-test
cmd.run:
salt.function:

View File

@ -0,0 +1,2 @@
always_true:
test.succeed_without_changes

View File

@ -1,4 +1,3 @@
{{ salt['runtests_helpers.get_salt_temp_dir_for_path']('to-include-test') }}:
file:
- managed
{{ pillar['to-include-test'] }}:
file.managed:
- source: salt://testfile

View File

@ -4,6 +4,7 @@
from __future__ import absolute_import
import os
import shutil
import tempfile
import textwrap
import threading
import time
@ -325,44 +326,28 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
os.unlink(testfile)
def test_include(self):
fnames = (
os.path.join(TMP, 'include-test'),
os.path.join(TMP, 'to-include-test')
)
exclude_test_file = os.path.join(
TMP, 'exclude-test'
)
try:
ret = self.run_function('state.sls', mods='include-test')
self.assertSaltTrueReturn(ret)
for fname in fnames:
self.assertTrue(os.path.isfile(fname))
self.assertFalse(os.path.isfile(exclude_test_file))
finally:
for fname in list(fnames) + [exclude_test_file]:
if os.path.isfile(fname):
os.remove(fname)
tempdir = tempfile.mkdtemp(dir=TMP)
self.addCleanup(shutil.rmtree, tempdir, ignore_errors=True)
pillar = {}
for path in ('include-test', 'to-include-test', 'exclude-test'):
pillar[path] = os.path.join(tempdir, path)
ret = self.run_function('state.sls', mods='include-test', pillar=pillar)
self.assertSaltTrueReturn(ret)
self.assertTrue(os.path.isfile(pillar['include-test']))
self.assertTrue(os.path.isfile(pillar['to-include-test']))
self.assertFalse(os.path.isfile(pillar['exclude-test']))
def test_exclude(self):
fnames = (
os.path.join(TMP, 'include-test'),
os.path.join(TMP, 'exclude-test')
)
to_include_test_file = os.path.join(
TMP, 'to-include-test'
)
try:
ret = self.run_function('state.sls', mods='exclude-test')
self.assertSaltTrueReturn(ret)
for fname in fnames:
self.assertTrue(os.path.isfile(fname))
self.assertFalse(os.path.isfile(to_include_test_file))
finally:
for fname in list(fnames) + [to_include_test_file]:
if os.path.isfile(fname):
os.remove(fname)
tempdir = tempfile.mkdtemp(dir=TMP)
self.addCleanup(shutil.rmtree, tempdir, ignore_errors=True)
pillar = {}
for path in ('include-test', 'exclude-test', 'to-include-test'):
pillar[path] = os.path.join(tempdir, path)
ret = self.run_function('state.sls', mods='exclude-test', pillar=pillar)
self.assertSaltTrueReturn(ret)
self.assertTrue(os.path.isfile(pillar['include-test']))
self.assertTrue(os.path.isfile(pillar['exclude-test']))
self.assertFalse(os.path.isfile(pillar['to-include-test']))
@skipIf(salt.utils.which_bin(KNOWN_BINARY_NAMES) is None, 'virtualenv not installed')
def test_issue_2068_template_str(self):