-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #1412 with TestKafkaBroker
behaviour where Consumer Groups weren't being respected
#1413
Conversation
Currently facing an issue where the RPC test assumes you can get a response back from a publisher? Not sure why this assumption was made. @pytest.mark.asyncio()
async def test_rpc(self, queue: str, rpc_broker: BrokerUsecase):
@rpc_broker.subscriber(queue)
async def m(m): # pragma: no cover
return "1"
async with rpc_broker:
await rpc_broker.start()
r = await rpc_broker.publish("hello", queue, rpc_timeout=3, rpc=True)
> assert r == "1"
E AssertionError imo I think publishers by definition can't return anything other than a ReceiveAck / similar response from the message queue – also not sure if I misunderstand the use case for RPC in this context. |
RPC in TestClient allows you to validate your handler result without special publisher creation. I think, we should save this behavior. In you case, if user has the only last result - it should be OK for most cases: (the following pseudocode represents assuming bahavior) result = None
for sub in subscribers:
result = call_subscriber(...)
return result |
faststream/kafka/testing.py
Outdated
raise_timeout=raise_timeout, | ||
) | ||
for consumer_group in set( | ||
{sub.group_id for sub in self.broker._subscribers.values()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like O(n**2) in this case. Can we find any decision without iteration throw all subscribers twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please fix the comments and upload main changes to make it mergeable?
5469bae
to
a03f4ea
Compare
9cb00e7
to
0d760ce
Compare
…st-broker-fix # Conflicts: # faststream/kafka/testing.py
Should be good to go, applied ruff formatting + linting. |
I'll check it and solve conflicts with main soon. Thank you for the work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sifex looks really great, but now I can't understand, why it respects consumer group😆
Anyway, can you, please add test for this behavior for publish_batch
method? Then we can merge it
…-test-broker-fix # Conflicts: # tests/brokers/confluent/test_test_client.py
Description
This fixes bug #1412 where distribution of messages on a topic does not get distributed to each consumer group when running the
TestKafkaBroker
.Fixes #1412
Example:
This example should have 2 messages received to 2 subscribers.
Where as if we have the same group_id, we only expect to receive it once.
Other fixes
DOCKER_COMPOSE_PROJECT
project name generation where the users' username field contains a.
character (which docker believes to be invalid naming)..github/PULL_REQUEST_TEMPLATE.md
Type of change
Checklist
scripts/lint.sh
shows no errors)scripts/test-cov.sh
(No. Currently Segfaults on Local M1 MBP, will rely on GHA)scripts/static-anaylysis.sh