|
8 | 8 | import pytest |
9 | 9 | from aiokafka.errors import CommitFailedError, IllegalStateError, KafkaError |
10 | 10 | from aiokafka.structs import OffsetAndMetadata, TopicPartition |
| 11 | +from mode.utils import text |
11 | 12 | from mode.utils.futures import done_future |
12 | 13 | from mode.utils.mocks import ANY, AsyncMock, MagicMock, Mock, call, patch |
13 | 14 | from opentracing.ext import tags |
|
18 | 19 | from faust.sensors.monitor import Monitor |
19 | 20 | from faust.transport.drivers import aiokafka as mod |
20 | 21 | from faust.transport.drivers.aiokafka import ( |
| 22 | + SLOW_PROCESSING_CAUSE_AGENT, |
| 23 | + SLOW_PROCESSING_CAUSE_STREAM, |
| 24 | + SLOW_PROCESSING_EXPLAINED, |
| 25 | + SLOW_PROCESSING_STREAM_IDLE_SINCE_START, |
21 | 26 | TOPIC_LENGTH_MAX, |
22 | 27 | AIOKafkaConsumerThread, |
23 | 28 | Consumer, |
@@ -386,6 +391,29 @@ def test_state(self, *, cthread, now): |
386 | 391 | assert cthread.time_started == now |
387 | 392 |
|
388 | 393 |
|
| 394 | +class Test_Log_Slow_Processing(Test_verify_event_path_base): |
| 395 | + def test_log_slow_processing_stream( |
| 396 | + self, cthread: AIOKafkaConsumerThread, tp: TP, logger |
| 397 | + ): |
| 398 | + cthread._log_slow_processing_stream( |
| 399 | + SLOW_PROCESSING_STREAM_IDLE_SINCE_START, tp, "3 seconds ago" |
| 400 | + ) |
| 401 | + logger.error.assert_called_with( |
| 402 | + SLOW_PROCESSING_STREAM_IDLE_SINCE_START |
| 403 | + + " " |
| 404 | + + SLOW_PROCESSING_EXPLAINED |
| 405 | + % {"setting": "stream_processing_timeout", "current_value": 300.0} |
| 406 | + + " " |
| 407 | + + text.enumeration( |
| 408 | + [SLOW_PROCESSING_CAUSE_STREAM, SLOW_PROCESSING_CAUSE_AGENT], |
| 409 | + start=2, |
| 410 | + sep="\n\n", |
| 411 | + ), |
| 412 | + tp, |
| 413 | + "3 seconds ago", |
| 414 | + ) |
| 415 | + |
| 416 | + |
389 | 417 | @pytest.mark.skip("Needs fixing") |
390 | 418 | class Test_VEP_no_fetch_since_start(Test_verify_event_path_base): |
391 | 419 | def test_just_started(self, *, cthread, now, tp, logger): |
|
0 commit comments