test_simple.py 3.2 KB

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