test_timeout.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding: utf-8 -*-
  2. """
  3. Tests for various minion timeouts
  4. """
  5. from __future__ import absolute_import
  6. import os
  7. import sys
  8. import pytest
  9. import salt.utils.platform
  10. from tests.support.case import ShellCase
  11. from tests.support.helpers import slowTest
  12. @pytest.mark.windows_whitelisted
  13. class MinionTimeoutTestCase(ShellCase):
  14. """
  15. Test minion timing functions
  16. """
  17. @slowTest
  18. def test_long_running_job(self):
  19. """
  20. Test that we will wait longer than the job timeout for a minion to
  21. return.
  22. """
  23. # Launch the command
  24. sleep_length = 30
  25. if salt.utils.platform.is_windows():
  26. popen_kwargs = {"env": dict(os.environ, PYTHONPATH=";".join(sys.path))}
  27. else:
  28. popen_kwargs = None
  29. ret = self.run_salt(
  30. "minion test.sleep {0}".format(sleep_length),
  31. timeout=90,
  32. catch_stderr=True,
  33. popen_kwargs=popen_kwargs,
  34. )
  35. self.assertTrue(
  36. isinstance(ret[0], list),
  37. "Return is not a list. Minion" " may have returned error: {0}".format(ret),
  38. )
  39. self.assertEqual(len(ret[0]), 2, "Standard out wrong length {}".format(ret))
  40. self.assertTrue(
  41. "True" in ret[0][1],
  42. "Minion did not return True after "
  43. "{0} seconds. ret={1}".format(sleep_length, ret),
  44. )