-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Check stamps and final message #5
Comments
In your case, would the stamp be available on the envelope? foreach ($this->messenger()->queue() as $envelope) {
$envelope->all(); // is the listed stamp here?
} |
Just check it, yes this works fine for stamps my bad i didn't see
But it could be more friendly i think.
And for the serialized message I thought about a property and in your
which get the serialized message which represent the $class message What do you think about it ? |
Absolutely! I'm thinking about how the API for this should work though. I'm trying to think where the
Still trying to understand this one - you want this method to return the serialized string for the message? |
Currently, it's difficult to get the exact envelope/message you want if there are multiple messages sent with the same message class. Perhaps #3 could help but instead of returning |
Yes thats what I want, but serialized by the right serializer, the one I configure in messenger
It's possible to configure a specific serializer per transport like this:
Like explain here https://symfonycasts.com/screencast/messenger/transport-serializer So it's not a complete functionnal test since we can't check the output of these serialisation |
Maybe creating a
I feel we loose the queue name in your lib, but a function like this would be great.
Would be the mirror of this conf:
|
The "queue_name" is an option that not all transports have, isn't it? The |
For the stamp assertions, I was thinking these would only be applicable for "user-defined" stamps (ie |
hmm yeah right, amqb have specific conf, cf. doc:
Complicate to handle everything |
I'm not seeing how this code snipped works? How is the AmpqStamp being added when using this lib's |
Mostly yes, but I think not only. Some library/bundles can apply specific stamps based on annotations in the application (I mainly think about api-platform, but I don't have example). In that case, you want to check tier library/bundles stamps to be sure you configure in the right way |
Forget this - I see now you're adding it (it's user defined). I thought it was something the AmpqTransport added.... |
So to summarize my understanding here, I'm seeing two separate features:
|
What I meant is we can't make assertions on the stamps different "transports" add. |
Yes that would be great, but with your other comment I understand that if we configure specific serializer per transport we can't have them threw your transport. |
Can you not do? # config/packages/test/messenger.yaml
framework:
messenger:
transports:
async:
dsn: test://
serializer: App\Messenger\ExternalJsonMessageSerializer The |
I'm just thinking, but I feel that if we avoid all transport specific conf, it makes tests around it not totally functional. I'm trying to think about how to do. You could override just the dsn to work in memory or something like that. |
The purpose of this library as I see it, is a hybrid of the in-memory/sync transports. It's use is to assert your app is sending the correct message to your async buses with an option to process them (if applicable). I think transport specific stuff is out of this scope. |
I can definitely see the use case for asserting stamps you define are added to your messages but as for wiring up your production transports (even the serializer imo) should be left for unit tests/E2E tests. |
Question, is your |
In that case for me, with your lib we can perform integration tests but not really functional test. |
That's a good way to put it. |
Yes the unserialize is in other app, but this line is not a problem it doesn't make error (probably because I use the symfony serializer system). |
Even with custom serializer it can't makes error, thanks to the interface |
But it could hide a real error if the serializer in your class is not the same as the one configured in the real transport |
So, I'm thinking the stamp assertions are useful and well within the scope of this library. Would that be helpful for you? |
To answer to this question, yes that's what i planned to do. Like in behat when you check the output content like this:
Actually I used to do that for rabbit message with behat (in previous project with swarrot), with my team we created Swarrot Context that allowed us to do things like
But now we I use messenger and phpunit for functional tests, and I try to do the same kind of assertion |
Yes that would still be helpful, and the serializedMessage too because your lib use the same serializer as my project |
Ok, I can work on this feature - it's related to #3.
This is because you're setting your custom serializer on the test transport like here? I'm still a little unclear on how to implement this feature - I'll tackle the stamp assertions first and then attempt this with some additional feedback from you. |
No I configured It globally on messenger like in my first message, so I think your transport got it too. |
|
Forgive me, I'm still trying to understand the serialized string feature. If your serializer is configured globally, What I do understand is a transport that encodes a message for an external consumer with a proprietary format and the current app can't decode. I can see you'd want to test the encoded string to see it's in the correct format. Even here though, it makes more sense to me as a unit test on your custom serializer (or perhaps a real E2E test...) |
The serialization process need to be tested, there is important logic inside. |
@CharloMez, #6 adds the stamp assertions (here's the documentation for this). WDYT? |
Is there a way to check stamps and the final message with this library ?
I explain myself.
I use messenger with rabbitmq, and between different microservices.
To perform that, I use a specific stamp to give the routing_key dynamically when i dispatch the message
And secondly I use symfony serializer to not pair the message with specific class.
and the normalizer:
I would like to perform fonctional testing on it, and for me it's very important to check that my stamp is good and that my final message too (I mean the final json which will really be in my queue).
I saw that you have the serializer in your transport class, is it possible to provide a function to get the serialized message ?
And I don't know how yet, but do you think it is possible to have a function to verify stamps instance and content ?
I don't have time to watch now, but if it is a good idea for you, i can look at it later and make a PR.
thanks !
The text was updated successfully, but these errors were encountered: