mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-09 17:24:57 -04:00
Avoid incrementing bg process utime/stime counters by negative durations (#14323)
This commit is contained in:
parent
7911e2835d
commit
2bb2c32e8e
6 changed files with 35 additions and 5 deletions
19
tests/metrics/test_background_process_metrics.py
Normal file
19
tests/metrics/test_background_process_metrics.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from unittest import TestCase as StdlibTestCase
|
||||
from unittest.mock import Mock
|
||||
|
||||
from synapse.logging.context import ContextResourceUsage, LoggingContext
|
||||
from synapse.metrics.background_process_metrics import _BackgroundProcess
|
||||
|
||||
|
||||
class TestBackgroundProcessMetrics(StdlibTestCase):
|
||||
def test_update_metrics_with_negative_time_diff(self) -> None:
|
||||
"""We should ignore negative reported utime and stime differences"""
|
||||
usage = ContextResourceUsage()
|
||||
usage.ru_stime = usage.ru_utime = -1.0
|
||||
|
||||
mock_logging_context = Mock(spec=LoggingContext)
|
||||
mock_logging_context.get_resource_usage.return_value = usage
|
||||
|
||||
process = _BackgroundProcess("test process", mock_logging_context)
|
||||
# Should not raise
|
||||
process.update_metrics()
|
Loading…
Add table
Add a link
Reference in a new issue