test_test.py 2.3 KB

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