mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #48898 from rallytime/merge-2018.3
[2018.3] Merge forward from 2017.7 to 2018.3
This commit is contained in:
commit
ffa1fcc682
7 changed files with 73 additions and 43 deletions
|
@ -372,7 +372,8 @@ def create(vm_):
|
|||
for iface_xml in domain_xml.findall('./devices/interface'):
|
||||
iface_xml.remove(iface_xml.find('./mac'))
|
||||
# enable IP learning, this might be a default behaviour...
|
||||
if iface_xml.find("./filterref/parameter[@name='CTRL_IP_LEARNING']") is None:
|
||||
# Don't always enable since it can cause problems through libvirt-4.5
|
||||
if ip_source == 'ip-learning' and iface_xml.find("./filterref/parameter[@name='CTRL_IP_LEARNING']") is None:
|
||||
iface_xml.append(ElementTree.fromstring(IP_LEARNING_XML))
|
||||
|
||||
# If a qemu agent is defined we need to fix the path to its socket
|
||||
|
|
|
@ -15,12 +15,14 @@ import inspect
|
|||
import tempfile
|
||||
import functools
|
||||
import threading
|
||||
import traceback
|
||||
import types
|
||||
from collections import MutableMapping
|
||||
from zipimport import zipimporter
|
||||
|
||||
# Import salt libs
|
||||
import salt.config
|
||||
import salt.defaults.exitcodes
|
||||
import salt.syspaths
|
||||
import salt.utils.context
|
||||
import salt.utils.data
|
||||
|
@ -1480,6 +1482,17 @@ class LazyLoader(salt.utils.lazy.LazyDict):
|
|||
self.missing_modules[name] = error
|
||||
return False
|
||||
except SystemExit as error:
|
||||
try:
|
||||
fn_, _, caller, _ = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
tgt_fn = os.path.join('salt', 'utils', 'process.py')
|
||||
if fn_.endswith(tgt_fn) and '_handle_signals' in caller:
|
||||
# Race conditon, SIGTERM or SIGINT received while loader
|
||||
# was in process of loading a module. Call sys.exit to
|
||||
# ensure that the process is killed.
|
||||
sys.exit(salt.defaults.exitcodes.EX_OK)
|
||||
log.error(
|
||||
'Failed to import %s %s as the module called exit()\n',
|
||||
self.tag, name, exc_info=True
|
||||
|
|
|
@ -647,8 +647,6 @@ class GitModuleTest(ModuleCase):
|
|||
|
||||
shutil.rmtree(new_repo)
|
||||
|
||||
# Test for git.is_worktree is in test_worktree_add_rm
|
||||
|
||||
def test_list_branches(self):
|
||||
'''
|
||||
Test git.list_branches
|
||||
|
@ -975,6 +973,7 @@ class GitModuleTest(ModuleCase):
|
|||
worktree_path = tempfile.mkdtemp(dir=TMP)
|
||||
worktree_basename = os.path.basename(worktree_path)
|
||||
worktree_path2 = tempfile.mkdtemp(dir=TMP)
|
||||
worktree_basename2 = os.path.basename(worktree_path2)
|
||||
|
||||
# Even though this is Windows, git commands return a unix style path
|
||||
if salt.utils.platform.is_windows():
|
||||
|
@ -985,11 +984,13 @@ class GitModuleTest(ModuleCase):
|
|||
ret = self.run_function(
|
||||
'git.worktree_add', [self.repo, worktree_path],
|
||||
)
|
||||
self.assertTrue(worktree_add_prefix + worktree_path in ret)
|
||||
self.assertTrue(worktree_add_prefix in ret)
|
||||
self.assertTrue(worktree_basename in ret)
|
||||
ret = self.run_function(
|
||||
'git.worktree_add', [self.repo, worktree_path2]
|
||||
)
|
||||
self.assertTrue(worktree_add_prefix + worktree_path2 in ret)
|
||||
self.assertTrue(worktree_add_prefix in ret)
|
||||
self.assertTrue(worktree_basename2 in ret)
|
||||
# Check if this new path is a worktree
|
||||
self.assertTrue(self.run_function('git.is_worktree', [worktree_path]))
|
||||
# Check if the main repo is a worktree
|
||||
|
|
|
@ -12,7 +12,7 @@ import os
|
|||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.unit import skipIf
|
||||
from tests.support.helpers import destructiveTest, skip_if_not_root
|
||||
from tests.support.helpers import destructiveTest, flaky, skip_if_not_root
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
|
@ -145,6 +145,7 @@ class ShadowModuleTest(ModuleCase):
|
|||
# User does not exist (set_inactdays return None is user does not exist)
|
||||
self.assertFalse(self.run_function('shadow.set_mindays', [self._no_user, 12]))
|
||||
|
||||
@flaky
|
||||
@destructiveTest
|
||||
def test_lock_password(self):
|
||||
'''
|
||||
|
@ -217,16 +218,16 @@ class ShadowModuleTest(ModuleCase):
|
|||
'''
|
||||
Test set/del password for root
|
||||
'''
|
||||
#saving shadow file
|
||||
# saving shadow file
|
||||
if not os.access("/etc/shadow", os.R_OK | os.W_OK):
|
||||
self.skipTest('Could not save initial state of /etc/shadow')
|
||||
with salt.utils.files.fopen('/etc/shadow', 'r') as sFile:
|
||||
shadow = sFile.read()
|
||||
#set root password
|
||||
# set root password
|
||||
self.assertTrue(self.run_function('shadow.set_password', ['root', self._password]))
|
||||
self.assertEqual(
|
||||
self.run_function('shadow.info', ['root'])['passwd'], self._password)
|
||||
#delete root password
|
||||
# delete root password
|
||||
self.assertTrue(self.run_function('shadow.del_password', ['root']))
|
||||
self.assertEqual(
|
||||
self.run_function('shadow.info', ['root'])['passwd'], '')
|
||||
|
|
|
@ -39,55 +39,67 @@ class MatchTest(ShellCase, ShellCaseCommonTestsMixin):
|
|||
self.assertIn('minion', data)
|
||||
self.assertIn('sub_minion', data)
|
||||
|
||||
def test_compound(self):
|
||||
# compound matcher tests: 11
|
||||
|
||||
def test_compound_min_with_grain(self):
|
||||
'''
|
||||
test salt compound matcher
|
||||
'''
|
||||
data = self.run_salt('-C "min* and G@test_grain:cheese" test.ping')
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertFalse(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is False
|
||||
|
||||
def test_compound_and_not_grain(self):
|
||||
data = self.run_salt('-C "min* and not G@test_grain:foo" test.ping')
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertFalse(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is False
|
||||
|
||||
def test_compound_not_grain(self):
|
||||
data = self.run_salt('-C "min* not G@test_grain:foo" test.ping')
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertFalse(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is False
|
||||
|
||||
def test_compound_pcre_grain_and_grain(self):
|
||||
match = 'P@test_grain:^cheese$ and * and G@test_grain:cheese'
|
||||
data = self.run_salt('-t 1 -C \'{0}\' test.ping'.format(match))
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertFalse(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is False
|
||||
|
||||
def test_compound_list_and_pcre_minion(self):
|
||||
match = 'L@sub_minion and E@.*'
|
||||
data = self.run_salt('-t 1 -C "{0}" test.ping'.format(match))
|
||||
self.assertTrue(minion_in_returns('sub_minion', data))
|
||||
self.assertFalse(minion_in_returns('minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('sub_minion', data) is True
|
||||
assert minion_in_returns('minion', data) is False
|
||||
|
||||
def test_compound_not_sub_minion(self):
|
||||
data = self.run_salt("-C 'not sub_minion' test.ping")
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertFalse(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is False
|
||||
|
||||
def test_compound_all_and_not_grains(self):
|
||||
data = self.run_salt("-C '* and ( not G@test_grain:cheese )' test.ping")
|
||||
self.assertFalse(minion_in_returns('minion', data))
|
||||
self.assertTrue(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is False
|
||||
assert minion_in_returns('sub_minion', data) is True
|
||||
|
||||
def test_compound_grain_regex(self):
|
||||
data = self.run_salt("-C 'G%@planets%merc*' test.ping")
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertFalse(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is False
|
||||
|
||||
def test_coumpound_pcre_grain_regex(self):
|
||||
data = self.run_salt("-C 'P%@planets%^(mercury|saturn)$' test.ping")
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertTrue(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is True
|
||||
|
||||
def test_compound_pillar(self):
|
||||
data = self.run_salt("-C 'I%@companions%three%sarah*' test.ping")
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertTrue(minion_in_returns('sub_minion', data))
|
||||
time.sleep(2)
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is True
|
||||
|
||||
def test_coumpound_pillar_pcre(self):
|
||||
data = self.run_salt("-C 'J%@knights%^(Lancelot|Galahad)$' test.ping")
|
||||
self.assertTrue(minion_in_returns('minion', data))
|
||||
self.assertTrue(minion_in_returns('sub_minion', data))
|
||||
assert minion_in_returns('minion', data) is True
|
||||
assert minion_in_returns('sub_minion', data) is True
|
||||
|
||||
def test_nodegroup(self):
|
||||
'''
|
||||
|
|
|
@ -8,6 +8,7 @@ import errno
|
|||
import os
|
||||
import textwrap
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
|
@ -83,6 +84,7 @@ class CMDRunRedirectTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
super(CMDRunRedirectTest, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
time.sleep(1)
|
||||
for path in (self.state_file, self.test_tmp_path, self.test_file):
|
||||
try:
|
||||
os.remove(path)
|
||||
|
|
|
@ -598,7 +598,7 @@ class TestSaltProgram(six.with_metaclass(TestSaltProgramMeta, TestProgram)):
|
|||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
connect = sock.bind(('localhost', port))
|
||||
except OSError:
|
||||
except (socket.error, OSError):
|
||||
# these ports are already in use, use different ones
|
||||
pub_port = 4606
|
||||
ret_port = 4607
|
||||
|
|
Loading…
Add table
Reference in a new issue