test_shell.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 json
  10. import logging
  11. import sys
  12. # Import Salt Libs
  13. import salt.ext.six as six
  14. import salt.utils.json as json
  15. # Import salt tests libs
  16. from tests.support.case import ShellCase
  17. from tests.support.unit import skipIf
  18. log = logging.getLogger(__name__)
  19. class ProxyCallerSimpleTestCase(ShellCase):
  20. """
  21. Test salt-call --proxyid <proxyid> commands
  22. """
  23. @staticmethod
  24. def _load_return(ret):
  25. try:
  26. return json.loads("\n".join(ret))
  27. except ValueError:
  28. log.warning("Failed to JSON decode: '%s'", ret)
  29. six.reraise(*sys.exc_info())
  30. @skipIf(True, "SLOWTEST skip")
  31. def test_can_it_ping(self):
  32. """
  33. Ensure the proxy can ping
  34. """
  35. ret = self._load_return(
  36. self.run_call("--proxyid proxytest --out=json test.ping")
  37. )
  38. self.assertEqual(ret["local"], True)
  39. @skipIf(True, "SLOWTEST skip")
  40. def test_list_pkgs(self):
  41. """
  42. Package test 1, really just tests that the virtual function capability
  43. is working OK.
  44. """
  45. ret = self._load_return(
  46. self.run_call("--proxyid proxytest --out=json pkg.list_pkgs")
  47. )
  48. self.assertIn("coreutils", ret["local"])
  49. self.assertIn("apache", ret["local"])
  50. self.assertIn("redbull", ret["local"])
  51. @skipIf(True, "SLOWTEST skip")
  52. def test_upgrade(self):
  53. ret = self._load_return(
  54. self.run_call("--proxyid proxytest --out=json pkg.upgrade")
  55. )
  56. self.assertEqual(ret["local"]["coreutils"]["new"], "2.0")
  57. self.assertEqual(ret["local"]["redbull"]["new"], "1000.99")
  58. @skipIf(True, "SLOWTEST skip")
  59. def test_service_list(self):
  60. ret = self._load_return(
  61. self.run_call("--proxyid proxytest --out=json service.list")
  62. )
  63. self.assertIn("ntp", ret["local"])
  64. @skipIf(True, "SLOWTEST skip")
  65. def test_service_start(self):
  66. ret = self._load_return(
  67. self.run_call("--proxyid proxytest --out=json service.start samba")
  68. )
  69. ret = self._load_return(
  70. self.run_call("--proxyid proxytest --out=json service.status samba")
  71. )
  72. self.assertTrue(ret)
  73. @skipIf(True, "SLOWTEST skip")
  74. def test_service_get_all(self):
  75. ret = self._load_return(
  76. self.run_call("--proxyid proxytest --out=json service.get_all")
  77. )
  78. self.assertIn("samba", ret["local"])
  79. @skipIf(True, "SLOWTEST skip")
  80. def test_grains_items(self):
  81. ret = self._load_return(
  82. self.run_call("--proxyid proxytest --out=json grains.items")
  83. )
  84. self.assertEqual(ret["local"]["kernel"], "proxy")
  85. self.assertEqual(ret["local"]["kernelrelease"], "proxy")