Skip to content
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

assert multiple message on kafka message using "within" doesn't work #336

Open
vbrune14 opened this issue Sep 18, 2024 · 1 comment
Open

Comments

@vbrune14
Copy link

if you want to assert that X (x>1) messages are received in a kafka topic within XXXXXms, you will in most cases receive a false

Indeed, the "within" parameter will do a check every 100ms, so every 100ms it will poll messages, if one message is received, this "alone" message will be compared with a list (=> false) and immediately forget, then others polls will be done, each time comparing "alone" message with list and forget the "alone" message
The only case of success is if all message arrived in the same poll....

fix will consist in keeping in memory all the previous polled message, and compare the full list with the expected list

/!\ don't forget compliance with assertion on unique message , comparaison with "alone" message is ok

@alexandrepa
Copy link
Collaborator

Hello, we have to be very cautious about adding this type of behavior. Within guard at the moment are generic and it will not easy to add this behavior.
In the way of testing an app it can also add a lot of test instability to wait for this kind of assertion.

Maybe for your specific case, it can be better to add a steps assertion before X (x>1) messages are received in a kafka topic to be sure that all your kafka messages have been sent. (You can wait for specifics logs for example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants