1
0

test_jid_logging.py 1006 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import, print_function, unicode_literals
  4. import logging
  5. import salt.ext.six as six
  6. # Import Salt Testing libs
  7. from tests.support.case import ModuleCase
  8. from tests.support.helpers import TstSuiteLoggingHandler, flaky
  9. from tests.support.unit import skipIf
  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, level=logging.DEBUG)
  21. @flaky
  22. def test_jid_in_logs(self):
  23. """
  24. Test JID in log_format
  25. """
  26. with self.handler:
  27. self.run_function("test.ping")
  28. assert (
  29. any("JID" in s for s in self.handler.messages) is True
  30. ), "JID not found in log messages"