You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
774 B

  1. from unittest import TestCase as StdlibTestCase
  2. from unittest.mock import Mock
  3. from synapse.logging.context import ContextResourceUsage, LoggingContext
  4. from synapse.metrics.background_process_metrics import _BackgroundProcess
  5. class TestBackgroundProcessMetrics(StdlibTestCase):
  6. def test_update_metrics_with_negative_time_diff(self) -> None:
  7. """We should ignore negative reported utime and stime differences"""
  8. usage = ContextResourceUsage()
  9. usage.ru_stime = usage.ru_utime = -1.0
  10. mock_logging_context = Mock(spec=LoggingContext)
  11. mock_logging_context.get_resource_usage.return_value = usage
  12. process = _BackgroundProcess("test process", mock_logging_context)
  13. # Should not raise
  14. process.update_metrics()