-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is the perf test for the DLQ design in #202. We want to run this in prod to observe the overhead of storing a copy of every raw message in the stream processor.
- Loading branch information
Showing
3 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from datetime import datetime | ||
from typing import Generator | ||
from unittest.mock import ANY | ||
|
||
from arroyo.backends.kafka import KafkaPayload | ||
from arroyo.backends.local.backend import LocalBroker | ||
from arroyo.backends.local.storages.memory import MemoryMessageStorage | ||
from arroyo.dlq import BufferedMessages, DlqLimit, DlqPolicy, KafkaDlqProducer | ||
from arroyo.types import BrokerValue, Partition, Topic | ||
|
||
topic = Topic("test") | ||
dlq_topic = Topic("test-dlq") | ||
partition = Partition(topic, 0) | ||
|
||
|
||
def generate_values() -> Generator[BrokerValue[KafkaPayload], None, None]: | ||
i = 0 | ||
while True: | ||
yield BrokerValue( | ||
KafkaPayload(None, str(i).encode("utf-8"), []), | ||
Partition(topic, 0), | ||
i, | ||
datetime.now(), | ||
) | ||
i += 1 | ||
|
||
|
||
def test_buffered_messages() -> None: | ||
broker: LocalBroker[KafkaPayload] = LocalBroker(MemoryMessageStorage()) | ||
|
||
dlq_policy = DlqPolicy( | ||
KafkaDlqProducer(broker.get_producer(), dlq_topic), DlqLimit() | ||
) | ||
|
||
buffer: BufferedMessages[KafkaPayload] = BufferedMessages(dlq_policy) | ||
|
||
generator = generate_values() | ||
|
||
for _ in range(10): | ||
buffer.append(next(generator)) | ||
|
||
assert buffer.pop(partition, 1) == BrokerValue( | ||
KafkaPayload(None, b"1", []), partition, 1, ANY | ||
) | ||
|
||
|
||
def test_no_buffered_messages() -> None: | ||
buffer: BufferedMessages[KafkaPayload] = BufferedMessages(None) | ||
|
||
generator = generate_values() | ||
for _ in range(10): | ||
buffer.append(next(generator)) | ||
assert buffer.pop(partition, 9) is None |