test_simple.py 3.2 KB

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