mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #45642 from rallytime/bp-45636
Back-port #45636 to 2017.7.3
This commit is contained in:
commit
0a07e0d259
@ -36,11 +36,16 @@ class MacPkgutilModuleTest(ModuleCase):
|
||||
if not salt.utils.which('pkgutil'):
|
||||
self.skipTest('Test requires pkgutil binary')
|
||||
|
||||
os_release = self.run_function('grains.get', ['osrelease'])
|
||||
self.pkg_name = 'com.apple.pkg.BaseSystemResources'
|
||||
if int(os_release.split('.')[1]) >= 13 and salt.utils.is_darwin():
|
||||
self.pkg_name = 'com.apple.pkg.iTunesX'
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Reset to original settings
|
||||
'''
|
||||
self.run_function('pkgutil.forget', ['org.macports.MacPorts'])
|
||||
self.run_function('pkgutil.forget', [TEST_PKG_NAME])
|
||||
self.run_function('file.remove', ['/opt/local'])
|
||||
|
||||
def test_list(self):
|
||||
@ -48,7 +53,7 @@ class MacPkgutilModuleTest(ModuleCase):
|
||||
Test pkgutil.list
|
||||
'''
|
||||
self.assertIsInstance(self.run_function('pkgutil.list'), list)
|
||||
self.assertIn('com.apple.pkg.BaseSystemResources',
|
||||
self.assertIn(self.pkg_name,
|
||||
self.run_function('pkgutil.list'))
|
||||
|
||||
def test_is_installed(self):
|
||||
@ -58,7 +63,7 @@ class MacPkgutilModuleTest(ModuleCase):
|
||||
# Test Package is installed
|
||||
self.assertTrue(
|
||||
self.run_function('pkgutil.is_installed',
|
||||
['com.apple.pkg.BaseSystemResources']))
|
||||
[self.pkg_name]))
|
||||
|
||||
# Test Package is not installed
|
||||
self.assertFalse(
|
||||
|
@ -27,6 +27,14 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
if salt.utils.is_windows():
|
||||
self.run_function('pkg.refresh_db')
|
||||
|
||||
os_release = self.run_function('grains.get', ['osrelease'])
|
||||
self.pkg = 'htop'
|
||||
|
||||
if int(os_release.split('.')[1]) >= 13 and salt.utils.is_darwin():
|
||||
self.pkg = 'wget'
|
||||
elif salt.utils.is_windows:
|
||||
self.pkg = 'putty'
|
||||
|
||||
def test_list(self):
|
||||
'''
|
||||
verify that packages are installed
|
||||
@ -133,30 +141,18 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
'''
|
||||
successfully install and uninstall a package
|
||||
'''
|
||||
os_grain = self.run_function('grains.item', ['os'])['os']
|
||||
os_release = self.run_function('grains.item', ['osrelease'])['osrelease']
|
||||
|
||||
pkg = 'htop'
|
||||
if os_grain == 'Windows':
|
||||
pkg = 'putty'
|
||||
|
||||
version = self.run_function('pkg.version', [pkg])
|
||||
|
||||
if os_grain == 'Ubuntu':
|
||||
if os_release.startswith('12.'):
|
||||
self.skipTest('pkg.install and pkg.remove do not work on ubuntu '
|
||||
'12 when run from the test suite')
|
||||
version = self.run_function('pkg.version', [self.pkg])
|
||||
|
||||
def test_install():
|
||||
install_ret = self.run_function('pkg.install', [pkg])
|
||||
self.assertIn(pkg, install_ret)
|
||||
install_ret = self.run_function('pkg.install', [self.pkg])
|
||||
self.assertIn(self.pkg, install_ret)
|
||||
|
||||
def test_remove():
|
||||
remove_ret = self.run_function('pkg.remove', [pkg])
|
||||
self.assertIn(pkg, remove_ret)
|
||||
remove_ret = self.run_function('pkg.remove', [self.pkg])
|
||||
self.assertIn(self.pkg, remove_ret)
|
||||
|
||||
if version and isinstance(version, dict):
|
||||
version = version[pkg]
|
||||
version = version[self.pkg]
|
||||
|
||||
if version:
|
||||
test_remove()
|
||||
@ -172,15 +168,10 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
'''
|
||||
test holding and unholding a package
|
||||
'''
|
||||
pkg = 'htop'
|
||||
os_family = self.run_function('grains.item', ['os_family'])['os_family']
|
||||
os_major_release = self.run_function('grains.item', ['osmajorrelease'])['osmajorrelease']
|
||||
available = self.run_function('sys.doc', ['pkg.hold'])
|
||||
|
||||
if os_family == 'RedHat':
|
||||
if os_major_release == '5':
|
||||
self.skipTest('`yum versionlock` does not seem to work on RHEL/CentOS 5')
|
||||
|
||||
if available:
|
||||
if os_family == 'RedHat':
|
||||
lock_pkg = 'yum-versionlock' if os_major_release == '5' else 'yum-plugin-versionlock'
|
||||
@ -188,13 +179,13 @@ class PkgModuleTest(ModuleCase, SaltReturnAssertsMixin):
|
||||
if not versionlock:
|
||||
self.run_function('pkg.install', [lock_pkg])
|
||||
|
||||
hold_ret = self.run_function('pkg.hold', [pkg])
|
||||
self.assertIn(pkg, hold_ret)
|
||||
self.assertTrue(hold_ret[pkg]['result'])
|
||||
hold_ret = self.run_function('pkg.hold', [self.pkg])
|
||||
self.assertIn(self.pkg, hold_ret)
|
||||
self.assertTrue(hold_ret[self.pkg]['result'])
|
||||
|
||||
unhold_ret = self.run_function('pkg.unhold', [pkg])
|
||||
self.assertIn(pkg, unhold_ret)
|
||||
self.assertTrue(hold_ret[pkg]['result'])
|
||||
unhold_ret = self.run_function('pkg.unhold', [self.pkg])
|
||||
self.assertIn(self.pkg, unhold_ret)
|
||||
self.assertTrue(hold_ret[self.pkg]['result'])
|
||||
|
||||
if os_family == 'RedHat':
|
||||
if not versionlock:
|
||||
|
@ -20,6 +20,7 @@ class ServiceModuleTest(ModuleCase):
|
||||
self.service_name = 'cron'
|
||||
cmd_name = 'crontab'
|
||||
os_family = self.run_function('grains.get', ['os_family'])
|
||||
os_release = self.run_function('grains.get', ['osrelease'])
|
||||
if os_family == 'RedHat':
|
||||
self.service_name = 'crond'
|
||||
elif os_family == 'Arch':
|
||||
@ -27,6 +28,8 @@ class ServiceModuleTest(ModuleCase):
|
||||
cmd_name = 'systemctl'
|
||||
elif os_family == 'MacOS':
|
||||
self.service_name = 'org.ntp.ntpd'
|
||||
if int(os_release.split('.')[1]) >= 13:
|
||||
self.service_name = 'com.apple.AirPlayXPCHelper'
|
||||
|
||||
if salt.utils.which(cmd_name) is None:
|
||||
self.skipTest('{0} is not installed'.format(cmd_name))
|
||||
|
Loading…
Reference in New Issue
Block a user