1
0

test_shell.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Test salt-call --proxyid commands
  4. tests.integration.proxy.test_shell
  5. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. '''
  7. # Import python libs
  8. from __future__ import absolute_import, print_function, unicode_literals
  9. # Import Salt Libs
  10. import salt.utils.json as json
  11. # Import salt tests libs
  12. from tests.support.case import ShellCase
  13. class ProxyCallerSimpleTestCase(ShellCase):
  14. '''
  15. Test salt-call --proxyid <proxyid> commands
  16. '''
  17. @staticmethod
  18. def _load_return(ret):
  19. return json.loads('\n'.join(ret))
  20. def test_can_it_ping(self):
  21. '''
  22. Ensure the proxy can ping
  23. '''
  24. ret = self._load_return(self.run_call('--proxyid proxytest --out=json test.ping'))
  25. self.assertEqual(ret['local'], True)
  26. def test_list_pkgs(self):
  27. '''
  28. Package test 1, really just tests that the virtual function capability
  29. is working OK.
  30. '''
  31. ret = self._load_return(self.run_call('--proxyid proxytest --out=json pkg.list_pkgs'))
  32. self.assertIn('coreutils', ret['local'])
  33. self.assertIn('apache', ret['local'])
  34. self.assertIn('redbull', ret['local'])
  35. def test_upgrade(self):
  36. ret = self._load_return(self.run_call('--proxyid proxytest --out=json pkg.upgrade'))
  37. self.assertEqual(ret['local']['coreutils']['new'], '2.0')
  38. self.assertEqual(ret['local']['redbull']['new'], '1000.99')
  39. def test_service_list(self):
  40. ret = self._load_return(self.run_call('--proxyid proxytest --out=json service.list'))
  41. self.assertIn('ntp', ret['local'])
  42. def test_service_start(self):
  43. ret = self._load_return(self.run_call('--proxyid proxytest --out=json service.start samba'))
  44. ret = self._load_return(self.run_call('--proxyid proxytest --out=json service.status samba'))
  45. self.assertTrue(ret)
  46. def test_service_get_all(self):
  47. ret = self._load_return(self.run_call('--proxyid proxytest --out=json service.get_all'))
  48. self.assertIn('samba', ret['local'])
  49. def test_grains_items(self):
  50. ret = self._load_return(self.run_call('--proxyid proxytest --out=json grains.items'))
  51. self.assertEqual(ret['local']['kernel'], 'proxy')
  52. self.assertEqual(ret['local']['kernelrelease'], 'proxy')