Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2019.2] Merge forward from 2019.2.1 to 2019.2 #52695

Merged
merged 42 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6ca8f4b
Try/except undefineFlags() as this operation is not supported on bhyve
jeroen92 Aug 12, 2018
e09be84
Update test_schema to mirror the new ValidationErrors in 3.0.0
Ch3LL Apr 17, 2019
6db2beb
Replace "pchanges" with "changes" to fix onchanges/prereq requisites
terminalmage Sep 28, 2018
0ba0ddf
Add test mode changes to file.touch state
terminalmage Sep 29, 2018
982e693
Add exception logging in flaky decorator
terminalmage Sep 29, 2018
ceb3f4d
Add repack_state_returns to TestCase
terminalmage Sep 29, 2018
ed214c4
Make it possible to use prereq with test and saltmod state mods
terminalmage Sep 29, 2018
4bc5fd0
Add integration tests for test mode onchanges/prereq
terminalmage Sep 29, 2018
885d6ff
Update file.touch unit tests to reflect addition of changes in test mode
terminalmage Sep 30, 2018
0f296bb
Update kernelpkg test to reflect pchanges removal
terminalmage Oct 1, 2018
fb3b75d
Fix tests for pchanges backport into 2018.3
Ch3LL Apr 8, 2019
f3c7f27
remove pchanges for windows file modules
Ch3LL Apr 11, 2019
93bdd08
Update dict correctly in file state
Ch3LL Apr 11, 2019
81b865f
use same newfile message on linux for windows file state
Ch3LL Apr 11, 2019
e03aed5
Merge pull request #52591 from Ch3LL/fix_jsonschema_2019.2
dwoz Apr 18, 2019
27c79d2
Update integration.modules.test_network.NetworkTest.test_network_ping…
s0undt3ch Apr 17, 2019
8ee15a9
Merge pull request #52548 from cbosdo/virt-purge-fix
dwoz Apr 18, 2019
5a0464b
Bring 51661 into 2019.2.1
twangboy Apr 18, 2019
d952674
Merge branch '2019.2.1' into gitfs_2019.2.1
twangboy Apr 18, 2019
c6b4986
Merge pull request #52615 from twangboy/gitfs_2019.2.1
dwoz Apr 18, 2019
77943e5
Merge pull request #52614 from Ch3LL/cp-test_network-2019.2.1
dwoz Apr 18, 2019
105784a
Remove unused method from pytest engine
dwoz Apr 18, 2019
4859e6c
Merge pull request #52619 from dwoz/pytest_engine_2019.2.1
dwoz Apr 18, 2019
423f6f9
Fix vent assertion race condition
dwoz Apr 19, 2019
c001022
Fix linter
dwoz Apr 19, 2019
0a4d2d9
Merge pull request #52629 from dwoz/ping_wait_2019.2.1
Ch3LL Apr 19, 2019
538d5cf
Remove pchanges from win_dacl
Ch3LL Apr 19, 2019
ecd6802
Merge branch '2019.2.1' into cp-52415
Ch3LL Apr 19, 2019
c3971a5
Fix salt.modules.publish and salt.states.x509 tests
dwoz Apr 20, 2019
9b6f9f9
Clean up cruft
dwoz Apr 20, 2019
af4f204
Merge pull request #52645 from dwoz/test_fixes
s0undt3ch Apr 20, 2019
f7d823c
Merge pull request #52601 from Ch3LL/cp-52415
dwoz Apr 21, 2019
0ea007d
Parse chattr version and fix test case
dwoz Apr 21, 2019
cf88c27
Fix linter issues
dwoz Apr 21, 2019
7f7bb90
Merge branch '2019.2.1' into cron_test_fix
garethgreenaway Apr 21, 2019
169c2d5
Chattr version py3 fix
dwoz Apr 22, 2019
859d088
Merge remote-tracking branch 'origin/cron_test_fix' into cron_test_fix
dwoz Apr 22, 2019
e69fcc5
Fix typo
dwoz Apr 22, 2019
d1a61a6
Merge pull request #52655 from dwoz/cron_test_fix
dwoz Apr 22, 2019
915c780
Fix issues with the win_file tests
twangboy Apr 22, 2019
174f558
Merge pull request #52659 from twangboy/fix_test_win_file
dwoz Apr 22, 2019
5eba30c
Merge branch '2019.2.1' into 2019.2
Ch3LL Apr 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion salt/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import shutil
import stat
import string
import subprocess
import sys
import tempfile
import time
Expand Down Expand Up @@ -61,6 +62,7 @@
import salt.utils.url
import salt.utils.user
import salt.utils.data
import salt.utils.versions
from salt.exceptions import CommandExecutionError, MinionError, SaltInvocationError, get_error_message as _get_error_message
from salt.utils.files import HASHES, HASHES_REVMAP

Expand Down Expand Up @@ -159,6 +161,35 @@ def _splitlines_preserving_trailing_newline(str):
return lines


def _get_chattr_man():
'''
Get the contents of the chattr man page
'''
return subprocess.check_output(['man', 'chattr'])


def _parse_chattr_man(man):
'''
Parse the contents of a chattr man page to find the E2fsprogs version
'''
match = re.search(
r'E2fsprogs version [0-9\.]+',
salt.utils.stringutils.to_str(man),
)
if match:
version = match.group().strip('E2fsprogs version ')
else:
version = None
return version


def _chattr_version():
'''
Return the version of chattr installed
'''
return _parse_chattr_man(_get_chattr_man())


def gid_to_group(gid):
'''
Convert the group id to the group name on this system
Expand Down Expand Up @@ -577,7 +608,14 @@ def lsattr(path):
for line in result.splitlines():
if not line.startswith('lsattr: '):
vals = line.split(None, 1)
results[vals[1]] = re.findall(r"[aAcCdDeijPsStTu]", vals[0])
needed_version = salt.utils.versions.LooseVersion('1.41.12')
chattr_version = salt.utils.versions.LooseVersion(_chattr_version())
# The version of chattr on Centos 6 does not support extended
# attributes.
if chattr_version > needed_version:
results[vals[1]] = re.findall(r"[aAcCdDeijPsStTu]", vals[0])
else:
results[vals[1]] = re.findall(r"[acdijstuADST]", vals[0])

return results

Expand Down
5 changes: 4 additions & 1 deletion salt/modules/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3291,7 +3291,10 @@ def purge(vm_, dirs=False, removables=None, **kwargs):
shutil.rmtree(dir_)
if getattr(libvirt, 'VIR_DOMAIN_UNDEFINE_NVRAM', False):
# This one is only in 1.2.8+
dom.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM)
try:
dom.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM)
except Exception:
dom.undefine()
else:
dom.undefine()
conn.close()
Expand Down
5 changes: 4 additions & 1 deletion salt/modules/x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,10 +1391,13 @@ def create_certificate(
for ignore in list(_STATE_INTERNAL_KEYWORDS) + \
['listen_in', 'preqrequired', '__prerequired__']:
kwargs.pop(ignore, None)
# TODO: Make timeout configurable in Neon
certs = __salt__['publish.publish'](
tgt=ca_server,
fun='x509.sign_remote_certificate',
arg=salt.utils.data.decode_dict(kwargs, to_str=True))
arg=salt.utils.data.decode_dict(kwargs, to_str=True),
timeout=30
)

if not any(certs):
raise salt.exceptions.SaltInvocationError(
Expand Down
2 changes: 1 addition & 1 deletion salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3016,7 +3016,7 @@ def checkout(self):
if repo.branch == '__env__' and hasattr(repo, 'all_saltenvs'):
env = self.opts.get('pillarenv') \
or self.opts.get('saltenv') \
or self.opts.get('git_pillar_base')
or 'base'
elif repo.env:
env = repo.env
else:
Expand Down
3 changes: 3 additions & 0 deletions tests/filename_map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ salt/modules/dockermod.py:
- integration.states.test_docker_container
- integration.states.test_docker_network

salt/modules/file.py:
- integration.states.test_cron

salt/modules/influxdb08mod.py:
- unit.states.test_influxdb08_database
- unit.states.test_influxdb08_user
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/files/conf/master
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tcp_master_workers: 64515

peer:
'.*':
- 'test.*'
- '(x509|test).*'

ext_pillar:
- ext_pillar_opts:
Expand Down
3 changes: 0 additions & 3 deletions tests/integration/files/conf/master.d/peers.conf

This file was deleted.

19 changes: 1 addition & 18 deletions tests/integration/files/engines/runtests_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ def start(self):

@gen.coroutine
def _start(self):
if self.opts['__role'] == 'minion':
yield self.listen_to_minion_connected_event()
else:
self.io_loop.spawn_callback(self.fire_master_started_event)

self.io_loop.spawn_callback(self.fire_master_started_event)
port = int(self.opts['runtests_conn_check_port'])
log.info('Starting Pytest Engine(role=%s) on port %s', self.opts['__role'], port)
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Expand Down Expand Up @@ -92,19 +88,6 @@ def handle_connection(self, connection, address):
# This is not macOS !?
pass

@gen.coroutine
def listen_to_minion_connected_event(self):
log.info('Listening for minion connected event...')
minion_start_event_match = 'salt/minion/{0}/start'.format(self.opts['id'])
event_bus = salt.utils.event.get_master_event(self.opts, self.opts['sock_dir'], listen=True)
event_bus.subscribe(minion_start_event_match)
while True:
event = event_bus.get_event(full=True, no_block=True)
if event is not None and event['tag'] == minion_start_event_match:
log.info('Got minion connected event: %s', event)
break
yield gen.sleep(0.25)

@gen.coroutine
def fire_master_started_event(self):
log.info('Firing salt-master started event...')
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/modules/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import salt.utils.path
import salt.utils.platform

URL = 'repo.saltstack.com'
URL = 'google-public-dns-a.google.com'


class NetworkTest(ModuleCase):
Expand Down
181 changes: 181 additions & 0 deletions tests/integration/pillar/test_git_pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,33 @@ def test_all_saltenvs(self):
'nested_dict': {'dev': True}}}
)

def test_all_saltenvs_base(self):
'''
Test all_saltenvs parameter with base pillarenv.
'''
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: gitpython
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(
ret,
{'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}}}
)


@destructiveTest
@skipIf(NO_MOCK, NO_MOCK_REASON)
Expand Down Expand Up @@ -1742,6 +1769,103 @@ def test_all_saltenvs(self, grains):
''')
self.assertEqual(ret, expected)

@requires_system_grains
def test_all_saltenvs_base(self, grains):
'''
Test all_saltenvs parameter.
'''
expected = {'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}
}
}

# Test with passphraseless key and global credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
git_pillar_pubkey: {pubkey_nopass}
git_pillar_privkey: {privkey_nopass}
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(ret, expected)

# Test with passphraseless key and per-repo credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- __env__ {url}:
- mountpoint: nowhere
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
''')
self.assertEqual(ret, expected)

if grains['os_family'] == 'Debian':
# passphrase-protected currently does not work here
return

# Test with passphrase-protected key and global credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
git_pillar_pubkey: {pubkey_withpass}
git_pillar_privkey: {privkey_withpass}
git_pillar_passphrase: {passphrase}
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(ret, expected)

# Test with passphrase-protected key and per-repo credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- passphrase: {passphrase}
- __env__ {url}:
- mountpoint: nowhere
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- passphrase: {passphrase}
''')
self.assertEqual(ret, expected)


@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(_windows_or_mac(), 'minion is windows or mac')
Expand Down Expand Up @@ -2119,6 +2243,33 @@ def test_all_saltenvs(self):
'nested_dict': {'dev': True}}}
)

def test_all_saltenvs_base(self):
'''
Test all_saltenvs parameter with base pillarenv.
'''
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(
ret,
{'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}}}
)


@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(_windows_or_mac(), 'minion is windows or mac')
Expand Down Expand Up @@ -2719,3 +2870,33 @@ def test_all_saltenvs(self):
'nested_list': ['dev'],
'nested_dict': {'dev': True}}}
)

def test_all_saltenvs_base(self):
'''
Test all_saltenvs parameter with base pillarenv.
'''
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
git_pillar_user: {user}
git_pillar_password: {password}
git_pillar_insecure_auth: True
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(
ret,
{'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}}}
)
2 changes: 1 addition & 1 deletion tests/integration/reactor/test_reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ def test_ping_reaction(self):

e.fire_event({'a': 'b'}, '/test_event')

self.assertMinionEventReceived({'a': 'b'})
self.assertMinionEventReceived({'a': 'b'}, timeout=30)
3 changes: 3 additions & 0 deletions tests/integration/states/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def setUp(self):
def tearDown(self):
os.remove(os.path.join(TMP_PILLAR_TREE, 'signing_policies.sls'))
os.remove(os.path.join(TMP_PILLAR_TREE, 'top.sls'))
certs_path = os.path.join(TMP, 'pki')
if os.path.exists(certs_path):
salt.utils.files.rm_rf(certs_path)
self.run_function('saltutil.refresh_pillar')

def run_function(self, *args, **kwargs):
Expand Down
Loading