test_deploy.py 1.7 KB

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