1
0

test_timeout.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. @pytest.mark.windows_whitelisted
  12. class MinionTimeoutTestCase(ShellCase):
  13. """
  14. Test minion timing functions
  15. """
  16. @pytest.mark.slow_test(seconds=60) # Test takes >30 and <=60 seconds
  17. def test_long_running_job(self):
  18. """
  19. Test that we will wait longer than the job timeout for a minion to
  20. return.
  21. """
  22. # Launch the command
  23. sleep_length = 30
  24. if salt.utils.platform.is_windows():
  25. popen_kwargs = {"env": dict(os.environ, PYTHONPATH=";".join(sys.path))}
  26. else:
  27. popen_kwargs = None
  28. ret = self.run_salt(
  29. "minion test.sleep {0}".format(sleep_length),
  30. timeout=90,
  31. catch_stderr=True,
  32. popen_kwargs=popen_kwargs,
  33. )
  34. self.assertTrue(
  35. isinstance(ret[0], list),
  36. "Return is not a list. Minion" " may have returned error: {0}".format(ret),
  37. )
  38. self.assertEqual(len(ret[0]), 2, "Standard out wrong length {}".format(ret))
  39. self.assertTrue(
  40. "True" in ret[0][1],
  41. "Minion did not return True after "
  42. "{0} seconds. ret={1}".format(sleep_length, ret),
  43. )