1
0

test_jid_logging.py 1018 B

1234567891011121314151617181920212223242526272829303132333435
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. # Import Salt Testing libs
  5. from tests.support.case import ModuleCase
  6. from tests.support.unit import skipIf
  7. from tests.support.helpers import TstSuiteLoggingHandler, flaky
  8. import logging
  9. import salt.ext.six as six
  10. @skipIf(six.PY3, 'Runtest Log Hander Disabled for PY3, #41836')
  11. class LoggingJIDsTest(ModuleCase):
  12. '''
  13. Validate that JIDs appear in LOGs
  14. '''
  15. def setUp(self):
  16. '''
  17. Set up
  18. '''
  19. log_format = '[%(levelname)-8s] %(jid)s %(message)s'
  20. self.handler = TstSuiteLoggingHandler(format=log_format,
  21. level=logging.DEBUG)
  22. @flaky
  23. def test_jid_in_logs(self):
  24. '''
  25. Test JID in log_format
  26. '''
  27. with self.handler:
  28. self.run_function('test.ping')
  29. assert any('JID' in s for s in self.handler.messages) is True, 'JID not found in log messages'