test_master.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # -*- coding: utf-8 -*-
  2. """
  3. Simple Smoke Tests for Connected SSH minions
  4. """
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. from tests.support.case import SSHCase
  7. from tests.support.helpers import requires_system_grains, skip_if_not_root, slowTest
  8. class SSHMasterTestCase(SSHCase):
  9. """
  10. Test ssh master functionality
  11. """
  12. @slowTest
  13. def test_can_it_ping(self):
  14. """
  15. Ensure the proxy can ping
  16. """
  17. ret = self.run_function("test.ping")
  18. self.assertEqual(ret, True)
  19. @requires_system_grains
  20. @skip_if_not_root
  21. @slowTest
  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. self.run_function("service.enable", [service])
  35. ret = self.run_function("service.get_all")
  36. self.assertIn(service, ret)
  37. self.run_function("service.stop", [service])
  38. ret = self.run_function("service.status", [service])
  39. self.assertFalse(ret)
  40. self.run_function("service.start", [service])
  41. ret = self.run_function("service.status", [service])
  42. self.assertTrue(ret)
  43. @requires_system_grains
  44. @slowTest
  45. def test_grains_items(self, grains):
  46. os_family = grains["os_family"]
  47. ret = self.run_function("grains.items")
  48. if os_family == "MacOS":
  49. self.assertEqual(ret["kernel"], "Darwin")
  50. else:
  51. self.assertEqual(ret["kernel"], "Linux")
  52. @slowTest
  53. def test_state_apply(self):
  54. ret = self.run_function("state.apply", ["core"])
  55. for key, value in ret.items():
  56. self.assertTrue(value["result"])
  57. @slowTest
  58. def test_state_highstate(self):
  59. ret = self.run_function("state.highstate")
  60. for key, value in ret.items():
  61. self.assertTrue(value["result"])