Closed DGuhr closed 1 year ago
Hello! The fake we have works at a much lower level than that of a broker. Specifically, it works at the AMQP frame level so we can add unit tests to ensure our client properly implements the protocol and gracefully handles various error conditions. So, while you could in theory build a fake broker with it, it would be a lot of work as you'd need to know how to respond to specific AMQP frames and track a lot of low-level state.
We've discussed adding broker support to this SDK. However, nothing is planned at present.
@jhendrixMSFT thanks for the response! Makes sense, and no worries. I spent the afternoon fighting with activeMQ configuration and I now have a dockerized broker I can use for my tests. I just saw these fakes and, well - "would be nice" I guess :)
fwiw, here's the current impl: https://github.com/RedHatInsights/authz/tree/535fccf603602b06e283a02d98b48293b91552a8/testdata/activemq - this config creates in broker.xml a queue testTopic and a reader and a writer-user.
Here's the initialization (takes ~5s with image present, so a bit slow, but it's an ol' java server, so what should we do): https://github.com/RedHatInsights/authz/blob/535fccf603602b06e283a02d98b48293b91552a8/testenv/LocalActiveMqContainer.go using dockertest (testcontainers-go is also possible for sure)
and here's the first "test" i used to verify it works and I can connect and send messages as a producer using go-amqp as client https://github.com/RedHatInsights/authz/blob/535fccf603602b06e283a02d98b48293b91552a8/testenv/LocalActiveMqContainer_test.go Far from done, but for one day my head is hurting enough. Figuring out that config was hard, even with gpt4 support ;)
The consumer will be implemented in our actual code, then we could spin up that container and have some convenient producerFuncs to send some messages if all goes as wanted. I'll close here, feel free to re-open if you ever think of adding such a fake, I'd be definitely interested :)
Hi folks 👋
I am looking at this library currently to implement an AMQP consumer. I hoped that I could use the "fake" broker you use for some of the tests, then fill the paylaod with my (xml) structure and test the processing of messages (xml parsing, etc). Is there any chance the "fake" package could be available for users of this library?
If not, well, I am kinda new to this, so if you have any hint on how to implement such a test that'd be helpful :) Maybe I am on the wrong track. I also thought about using dockertest or testcontainers-go, but spinning up a real queue (activeMQ in my case) feels a bit heavyweight, I'd assume long test execution times.