Merge pull request #55598 from garethgreenaway/master_mount_fixes

[master] regression fixes to mount module and state module
This commit is contained in:
Daniel Wozniak 2020-01-27 07:51:35 -07:00 committed by GitHub
commit fb36d86ad5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 0 deletions

View file

@ -763,6 +763,9 @@ def set_fstab(
'securityfs',
'devtmpfs',
'cgroup',
'nfs',
'nfs4',
'glusterfs',
'btrfs'])
if fstype in specialFSes:

View file

@ -325,6 +325,8 @@ def mounted(name,
if label_device and label_device not in device_list:
device_list.append(label_device)
if opts:
opts.sort()
mount_invisible_options = [
'_netdev',
'actimeo',

View file

@ -447,6 +447,56 @@ class MountTestCase(TestCase, LoaderModuleMockMixin):
self.assertDictEqual(mount.mod_watch(name, sfun='unmount'), ret)
def test_mounted_multiple_mounts(self):
'''
Test to verify that a device is mounted.
'''
name = '/mnt/nfs1'
device = 'localhost:/mnt/nfsshare'
fstype = 'nfs4'
name2 = '/mnt/nfs2'
device2 = 'localhost:/mnt/nfsshare'
fstype2 = 'nfs4'
ret = {'name': name,
'result': False,
'comment': '',
'changes': {}}
mock = MagicMock(side_effect=['new', 'present', 'new', 'change',
'bad config', 'salt', 'present'])
mock_t = MagicMock(return_value=True)
mock_f = MagicMock(return_value=False)
mock_ret = MagicMock(return_value={'retcode': 1})
mock_mnt = MagicMock(return_value={name: {'device': device, 'opts': [],
'superopts': []}})
mock_read_cache = MagicMock(return_value={})
mock_write_cache = MagicMock(return_value=True)
mock_user = MagicMock(return_value={'uid': 510})
mock_group = MagicMock(return_value={'gid': 100})
mock_str = MagicMock(return_value='salt')
mock_fstab_config = ['localhost:/mnt/nfsshare /mnt/nfs1 nfs defaults 0 0']
# Test no change for uid provided as a name #25293
with patch.dict(mount.__grains__, {'os': 'CentOS'}):
with patch.dict(mount.__opts__, {'test': True}):
with patch.dict(mount.__salt__, {'mount.active': mock_mnt,
'mount.mount': mock_str,
'mount.umount': mock_f,
'mount.read_mount_cache': mock_read_cache,
'mount.write_mount_cache': mock_write_cache,
'user.info': mock_user,
'group.info': mock_group}):
with patch.object(os.path, 'exists', mock_t):
comt = '/mnt/nfs2 would be mounted'
ret.update({'name': name2, 'result': None})
ret.update({'comment': comt, 'changes': {}})
self.assertDictEqual(mount.mounted(name2, device2,
fstype2,
opts=[]),
ret)
def test__convert_to_fast_none(self):
'''
Test the device name conversor