test_test.py 2.4 KB

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