1
0

test_jid_logging.py 988 B

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