test_deploy.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: utf-8 -*-
  2. """
  3. salt-ssh testing
  4. """
  5. from __future__ import absolute_import, print_function, unicode_literals
  6. import os
  7. import shutil
  8. from tests.support.case import SSHCase
  9. from tests.support.helpers import slowTest
  10. from tests.support.runtests import RUNTIME_VARS
  11. class SSHTest(SSHCase):
  12. """
  13. Test general salt-ssh functionality
  14. """
  15. @slowTest
  16. def test_ping(self):
  17. """
  18. Test a simple ping
  19. """
  20. ret = self.run_function("test.ping")
  21. self.assertTrue(ret, "Ping did not return true")
  22. @slowTest
  23. def test_thin_dir(self):
  24. """
  25. test to make sure thin_dir is created
  26. and salt-call file is included
  27. """
  28. thin_dir = self.run_function("config.get", ["thin_dir"], wipe=False)
  29. os.path.isdir(thin_dir)
  30. os.path.exists(os.path.join(thin_dir, "salt-call"))
  31. os.path.exists(os.path.join(thin_dir, "running_data"))
  32. def test_set_path(self):
  33. """
  34. test setting the path env variable
  35. """
  36. path = "/pathdoesnotexist/"
  37. roster = os.path.join(RUNTIME_VARS.TMP, "roster-set-path")
  38. self.custom_roster(
  39. roster, data={"set_path": "$PATH:/usr/local/bin/:{0}".format(path)}
  40. )
  41. ret = self.run_function("environ.get", ["PATH"], roster_file=roster)
  42. assert path in ret
  43. def tearDown(self):
  44. """
  45. make sure to clean up any old ssh directories
  46. """
  47. salt_dir = self.run_function("config.get", ["thin_dir"], wipe=False)
  48. if os.path.exists(salt_dir):
  49. shutil.rmtree(salt_dir)