test_modjk.py 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # -*- coding: utf-8 -*-
  2. '''
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. '''
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing Libs
  8. from tests.support.unit import TestCase
  9. # Import Salt Libs
  10. import salt.states.modjk as modjk
  11. from salt.ext import six
  12. if six.PY2:
  13. LIST_NOT_STR = "workers should be a list not a <type 'unicode'>"
  14. else:
  15. LIST_NOT_STR = "workers should be a list not a <class 'str'>"
  16. class ModjkTestCase(TestCase):
  17. '''
  18. Test cases for salt.states.modjk
  19. '''
  20. # 'worker_stopped' function tests: 1
  21. def test_worker_stopped(self):
  22. '''
  23. Test to stop all the workers in the modjk load balancer
  24. '''
  25. name = 'loadbalancer'
  26. ret = {'name': name,
  27. 'result': False,
  28. 'comment': '',
  29. 'changes': {}}
  30. ret.update({'comment': LIST_NOT_STR})
  31. self.assertDictEqual(modjk.worker_stopped(name, 'app1'), ret)
  32. # 'worker_activated' function tests: 1
  33. def test_worker_activated(self):
  34. '''
  35. Test to activate all the workers in the modjk load balancer
  36. '''
  37. name = 'loadbalancer'
  38. ret = {'name': name,
  39. 'result': False,
  40. 'comment': '',
  41. 'changes': {}}
  42. ret.update({'comment': LIST_NOT_STR})
  43. self.assertDictEqual(modjk.worker_activated(name, 'app1'), ret)
  44. # 'worker_disabled' function tests: 1
  45. def test_worker_disabled(self):
  46. '''
  47. Test to disable all the workers in the modjk load balancer
  48. '''
  49. name = 'loadbalancer'
  50. ret = {'name': name,
  51. 'result': False,
  52. 'comment': '',
  53. 'changes': {}}
  54. ret.update({'comment': LIST_NOT_STR})
  55. self.assertDictEqual(modjk.worker_disabled(name, 'app1'), ret)
  56. # 'worker_recover' function tests: 1
  57. def test_worker_recover(self):
  58. '''
  59. Test to recover all the workers in the modjk load balancer
  60. '''
  61. name = 'loadbalancer'
  62. ret = {'name': name,
  63. 'result': False,
  64. 'comment': '',
  65. 'changes': {}}
  66. ret.update({'comment': LIST_NOT_STR})
  67. self.assertDictEqual(modjk.worker_recover(name, 'app1'), ret)