1
0

test_master.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 ModuleCase
  9. from tests.support.helpers import requires_sshd_server
  10. @requires_sshd_server
  11. class SSHMasterTestCase(ModuleCase):
  12. '''
  13. Test ssh master functionality
  14. '''
  15. def test_can_it_ping(self):
  16. '''
  17. Ensure the proxy can ping
  18. '''
  19. ret = self.run_function('test.ping', minion_tgt='localhost')
  20. self.assertEqual(ret, True)
  21. def test_service(self):
  22. service = 'cron'
  23. os_family = self.run_function('grains.get', ['os_family'], minion_tgt='localhost')
  24. os_release = self.run_function('grains.get', ['osrelease'], minion_tgt='localhost')
  25. if os_family == 'RedHat':
  26. service = 'crond'
  27. elif os_family == 'Arch':
  28. service = 'sshd'
  29. elif os_family == 'MacOS':
  30. service = 'org.ntp.ntpd'
  31. if int(os_release.split('.')[1]) >= 13:
  32. service = 'com.apple.AirPlayXPCHelper'
  33. ret = self.run_function('service.get_all', minion_tgt='localhost')
  34. self.assertIn(service, ret)
  35. self.run_function('service.stop', [service], minion_tgt='localhost')
  36. ret = self.run_function('service.status', [service], minion_tgt='localhost')
  37. self.assertFalse(ret)
  38. self.run_function('service.start', [service], minion_tgt='localhost')
  39. ret = self.run_function('service.status', [service], minion_tgt='localhost')
  40. self.assertTrue(ret)
  41. def test_grains_items(self):
  42. os_family = self.run_function('grains.get', ['os_family'], minion_tgt='localhost')
  43. ret = self.run_function('grains.items', minion_tgt='localhost')
  44. if os_family == 'MacOS':
  45. self.assertEqual(ret['kernel'], 'Darwin')
  46. else:
  47. self.assertEqual(ret['kernel'], 'Linux')
  48. def test_state_apply(self):
  49. ret = self.run_function('state.apply', ['core'], minion_tgt='localhost')
  50. for key, value in ret.items():
  51. self.assertTrue(value['result'])
  52. def test_state_highstate(self):
  53. ret = self.run_function('state.highstate', minion_tgt='localhost')
  54. for key, value in ret.items():
  55. self.assertTrue(value['result'])