test_simple.py 4.0 KB

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