1
0

test_simple.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # -*- coding: utf-8 -*-
  2. """
  3. Simple Smoke Tests for Connected Proxy Minion
  4. """
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. from tests.support.case import ModuleCase
  7. from tests.support.helpers import slowTest
  8. class ProxyMinionSimpleTestCase(ModuleCase):
  9. """
  10. Test proxy minion functionality
  11. """
  12. def test_can_it_ping(self):
  13. """
  14. Ensure the proxy can ping
  15. """
  16. ret = self.run_function("test.ping", minion_tgt="proxytest")
  17. self.assertEqual(ret, True)
  18. def test_list_pkgs(self):
  19. """
  20. Package test 1, really just tests that the virtual function capability
  21. is working OK.
  22. """
  23. ret = self.run_function("pkg.list_pkgs", minion_tgt="proxytest")
  24. self.assertIn("coreutils", ret)
  25. self.assertIn("apache", ret)
  26. self.assertIn("redbull", ret)
  27. def test_install_pkgs(self):
  28. """
  29. Package test 2, really just tests that the virtual function capability
  30. is working OK.
  31. """
  32. ret = self.run_function("pkg.install", ["thispkg"], minion_tgt="proxytest")
  33. self.assertEqual(ret["thispkg"], "1.0")
  34. ret = self.run_function("pkg.list_pkgs", minion_tgt="proxytest")
  35. self.assertEqual(ret["apache"], "2.4")
  36. self.assertEqual(ret["redbull"], "999.99")
  37. self.assertEqual(ret["thispkg"], "1.0")
  38. def test_remove_pkgs(self):
  39. ret = self.run_function("pkg.remove", ["apache"], minion_tgt="proxytest")
  40. self.assertNotIn("apache", ret)
  41. def test_upgrade(self):
  42. ret = self.run_function("pkg.upgrade", minion_tgt="proxytest")
  43. self.assertEqual(ret["coreutils"]["new"], "2.0")
  44. self.assertEqual(ret["redbull"]["new"], "1000.99")
  45. def test_service_list(self):
  46. ret = self.run_function("service.list", minion_tgt="proxytest")
  47. self.assertIn("ntp", ret)
  48. def test_service_stop(self):
  49. ret = self.run_function("service.stop", ["ntp"], minion_tgt="proxytest")
  50. ret = self.run_function("service.status", ["ntp"], minion_tgt="proxytest")
  51. self.assertFalse(ret)
  52. def test_service_start(self):
  53. ret = self.run_function("service.start", ["samba"], minion_tgt="proxytest")
  54. ret = self.run_function("service.status", ["samba"], minion_tgt="proxytest")
  55. self.assertTrue(ret)
  56. def test_service_get_all(self):
  57. ret = self.run_function("service.get_all", minion_tgt="proxytest")
  58. self.assertTrue(ret)
  59. self.assertIn("samba", " ".join(ret))
  60. def test_grains_items(self):
  61. ret = self.run_function("grains.items", minion_tgt="proxytest")
  62. self.assertEqual(ret["kernel"], "proxy")
  63. self.assertEqual(ret["kernelrelease"], "proxy")
  64. def test_state_apply(self):
  65. ret = self.run_function("state.apply", ["core"], minion_tgt="proxytest")
  66. for key, value in ret.items():
  67. self.assertTrue(value["result"])
  68. @slowTest
  69. def test_state_highstate(self):
  70. ret = self.run_function("state.highstate", minion_tgt="proxytest")
  71. for key, value in ret.items():
  72. self.assertTrue(value["result"])