From 70517a1f407585a35bfdc715aa345ed2ec7bb5f0 Mon Sep 17 00:00:00 2001 From: Xavier Vello Date: Thu, 7 Mar 2024 14:03:07 +0100 Subject: [PATCH] add test for REPLAY_OVERFLOW_SESSIONS_ENABLED=False --- posthog/api/test/test_capture.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/posthog/api/test/test_capture.py b/posthog/api/test/test_capture.py index 27a4d91422d03..52f46e0b5addf 100644 --- a/posthog/api/test/test_capture.py +++ b/posthog/api/test/test_capture.py @@ -1637,6 +1637,26 @@ def test_recording_ingestion_can_overflow_from_redis_instructions(self, kafka_pr topic_counter = Counter([call[1]["topic"] for call in kafka_produce.call_args_list]) assert topic_counter == Counter({KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS: 1}) + @patch("posthog.kafka_client.client._KafkaProducer.produce") + def test_recording_ingestion_ignores_overflow_from_redis_if_disabled(self, kafka_produce) -> None: + with self.settings( + SESSION_RECORDING_KAFKA_MAX_REQUEST_SIZE_BYTES=20480, REPLAY_OVERFLOW_SESSIONS_ENABLED=False + ): + redis = get_client() + redis.zadd( + "@posthog/capture-overflow/replay", + { + "overflowing": timezone.now().timestamp() + 1000, + }, + ) + + # Session is currently overflowing but REPLAY_OVERFLOW_SESSIONS_ENABLED is false + self._send_august_2023_version_session_recording_event( + event_data=large_data_array, session_id="overflowing" + ) + topic_counter = Counter([call[1]["topic"] for call in kafka_produce.call_args_list]) + assert topic_counter == Counter({KAFKA_SESSION_RECORDING_SNAPSHOT_ITEM_EVENTS: 1}) + @patch("posthog.kafka_client.client._KafkaProducer.produce") def test_recording_ingestion_can_write_headers_with_the_message(self, kafka_produce: MagicMock) -> None: with self.settings(