test_simple.py 3.1 KB

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