test_timeout.py 1.3 KB

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