test_master.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Simple Smoke Tests for Connected SSH minions
  4. '''
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing libs
  8. from tests.support.case import SSHCase
  9. from tests.support.helpers import skip_if_not_root, requires_system_grains
  10. class SSHMasterTestCase(SSHCase):
  11. '''
  12. Test ssh master functionality
  13. '''
  14. def test_can_it_ping(self):
  15. '''
  16. Ensure the proxy can ping
  17. '''
  18. ret = self.run_function('test.ping')
  19. self.assertEqual(ret, True)
  20. @requires_system_grains
  21. @skip_if_not_root
  22. def test_service(self, grains):
  23. service = 'cron'
  24. os_family = grains['os_family']
  25. os_release = grains['osrelease']
  26. if os_family == 'RedHat':
  27. service = 'crond'
  28. elif os_family == 'Arch':
  29. service = 'sshd'
  30. elif os_family == 'MacOS':
  31. service = 'org.ntp.ntpd'
  32. if int(os_release.split('.')[1]) >= 13:
  33. service = 'com.apple.AirPlayXPCHelper'
  34. ret = self.run_function('service.get_all')
  35. self.assertIn(service, ret)
  36. self.run_function('service.stop', [service])
  37. ret = self.run_function('service.status', [service])
  38. self.assertFalse(ret)
  39. self.run_function('service.start', [service])
  40. ret = self.run_function('service.status', [service])
  41. self.assertTrue(ret)
  42. @requires_system_grains
  43. def test_grains_items(self, grains):
  44. os_family = grains['os_family']
  45. ret = self.run_function('grains.items')
  46. if os_family == 'MacOS':
  47. self.assertEqual(ret['kernel'], 'Darwin')
  48. else:
  49. self.assertEqual(ret['kernel'], 'Linux')
  50. def test_state_apply(self):
  51. ret = self.run_function('state.apply', ['core'])
  52. for key, value in ret.items():
  53. self.assertTrue(value['result'])
  54. def test_state_highstate(self):
  55. ret = self.run_function('state.highstate')
  56. for key, value in ret.items():
  57. self.assertTrue(value['result'])