test: cover redis listener batch isolation when one message fails DB insertion#263
Conversation
Co-authored-by: alexgarel <144788+alexgarel@users.noreply.github.com>
Co-authored-by: alexgarel <144788+alexgarel@users.noreply.github.com>
query/events.py
Outdated
| await messages_received(transaction, chunk) | ||
| # Each message is a tuple of the message id followed by a dict that is the payload | ||
| last_message_id = response[0][1][-1][0] | ||
| last_message_id = chunk[0][1][-1][0] |
There was a problem hiding this comment.
hum, we should do that only for original response not for the retried items.
Can you fix it @copilot ?
There was a problem hiding this comment.
Done in aa8d05a: last_message_id persistence is now applied only for chunks coming from the original Redis response, not for retried items. No UI changes in this PR.
| def fail_for_one_message(_transaction, streams): | ||
| messages = streams[0][1] | ||
| if any(message[0] == failing_message_id for message in messages): | ||
| raise Exception("insertion failed") |
There was a problem hiding this comment.
@copilot
Very good, but now that I made the items_to_retry a global of events, can we assert at the end that it contains this item ?
There was a problem hiding this comment.
Done in aa8d05a: the test now asserts the failed message is present in events.items_to_retry at the end of processing. No UI changes in this PR.
|
|
||
| assert set_id.called | ||
| stream_message_counts = [len(call.args[1][0][1]) for call in messages_received.call_args_list] | ||
| assert 5 in stream_message_counts |
There was a problem hiding this comment.
I think depending on the time it takes to runs, it might be more than 5 times, isn't it ?
So maybe the best option is to patch events.get_retry_interval to return a very big time (like 3600) in any case. So we are sure there won't be any real retry.
and at the end of the test, we can check the scheduled retry date is in this range.
@copilot
There was a problem hiding this comment.
Done in aa8d05a: the test patches events.get_retry_interval to a large fixed value and checks the scheduled retry timestamp is within the expected range. No UI changes in this PR.
Co-authored-by: alexgarel <144788+alexgarel@users.noreply.github.com>
Co-authored-by: alexgarel <144788+alexgarel@users.noreply.github.com>
Co-authored-by: alexgarel <144788+alexgarel@users.noreply.github.com>
query/events_test.pyrelated to listener retries/splitting💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.