1
0

test_test.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. import pytest
  5. import salt.config
  6. # Import salt libs
  7. import salt.version
  8. # Import Salt Testing libs
  9. from tests.support.case import MultimasterModuleCase
  10. from tests.support.mixins import AdaptedConfigurationTestCaseMixin
  11. class TestModuleTest(MultimasterModuleCase, AdaptedConfigurationTestCaseMixin):
  12. """
  13. Validate the test module
  14. """
  15. @pytest.mark.slow_test(seconds=5) # Test takes >1 and <=5 seconds
  16. def test_ping(self):
  17. """
  18. test.ping
  19. """
  20. self.assertEqual(self.run_function_all_masters("test.ping"), [True] * 2)
  21. @pytest.mark.slow_test(seconds=5) # Test takes >1 and <=5 seconds
  22. def test_echo(self):
  23. """
  24. test.echo
  25. """
  26. self.assertEqual(
  27. self.run_function_all_masters("test.echo", ["text"]), ["text"] * 2
  28. )
  29. @pytest.mark.slow_test(seconds=5) # Test takes >1 and <=5 seconds
  30. def test_version(self):
  31. """
  32. test.version
  33. """
  34. self.assertEqual(
  35. self.run_function_all_masters("test.version"),
  36. [salt.version.__saltstack_version__.string] * 2,
  37. )
  38. @pytest.mark.slow_test(seconds=5) # Test takes >1 and <=5 seconds
  39. def test_conf_test(self):
  40. """
  41. test.conf_test
  42. """
  43. self.assertEqual(self.run_function_all_masters("test.conf_test"), ["baz"] * 2)
  44. @pytest.mark.slow_test(seconds=5) # Test takes >1 and <=5 seconds
  45. def test_get_opts(self):
  46. """
  47. test.get_opts
  48. """
  49. opts = salt.config.minion_config(self.get_config_file_path("mm_minion"))
  50. ret = self.run_function_all_masters("test.get_opts")
  51. self.assertEqual(ret[0]["cachedir"], opts["cachedir"])
  52. self.assertEqual(ret[1]["cachedir"], opts["cachedir"])
  53. @pytest.mark.slow_test(seconds=5) # Test takes >1 and <=5 seconds
  54. def test_cross_test(self):
  55. """
  56. test.cross_test
  57. """
  58. self.assertTrue(self.run_function_all_masters("test.cross_test", ["test.ping"]))
  59. @pytest.mark.slow_test(seconds=1) # Test takes >0.5 and <=1 seconds
  60. def test_fib(self):
  61. """
  62. test.fib
  63. """
  64. ret = self.run_function_all_masters("test.fib", ["20"])
  65. self.assertEqual(ret[0][0], 6765)
  66. self.assertEqual(ret[1][0], 6765)
  67. @pytest.mark.slow_test(seconds=1) # Test takes >0.5 and <=1 seconds
  68. def test_collatz(self):
  69. """
  70. test.collatz
  71. """
  72. ret = self.run_function_all_masters("test.collatz", ["40"])
  73. self.assertEqual(ret[0][0][-1], 2)
  74. self.assertEqual(ret[1][0][-1], 2)
  75. @pytest.mark.slow_test(seconds=1) # Test takes >0.5 and <=1 seconds
  76. def test_outputter(self):
  77. """
  78. test.outputter
  79. """
  80. self.assertEqual(
  81. self.run_function_all_masters("test.outputter", ["text"]), ["text"] * 2
  82. )