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

[Enhancement]: Azure Service Bus emulator #1302

Closed
KSemenenko opened this issue Nov 19, 2024 · 15 comments · Fixed by #1309
Closed

[Enhancement]: Azure Service Bus emulator #1302

KSemenenko opened this issue Nov 19, 2024 · 15 comments · Fixed by #1309
Labels
enhancement New feature or request module An official Testcontainers module

Comments

@KSemenenko
Copy link
Contributor

KSemenenko commented Nov 19, 2024

Problem

It’s nice to have Azure Service Bus emulator

Solution

https://learn.microsoft.com/en-us/azure/service-bus-messaging/test-locally-with-service-bus-emulator?tabs=docker-linux-container

And

https://mcr.microsoft.com/en-us/artifact/mar/azure-messaging/servicebus-emulator/about

Benefit

Azure Service Bus emulator - useful for tests

Alternatives

No

Would you like to help contributing this enhancement?

Yes

@KSemenenko KSemenenko added the enhancement New feature or request label Nov 19, 2024
@HofmeisterAn
Copy link
Collaborator

If I am correct, the Azure Service Bus Emulator is not as straightforward as other modules because it requires a database container as well. Fortunately, we already have a module with similar requirements. I believe we can follow the implementation of our WebDriver module, which also sets up a network, network alias and connects multiple containers together.

@HofmeisterAn
Copy link
Collaborator

I started to work on the module implementation.

@HofmeisterAn
Copy link
Collaborator

I'm almost done and ready to create the PR, but unfortunately, I'm running into an issue with the tests. It's something we've encountered before with other Azure client libraries. When I try to send a message to the emulator, it fails and responds with an error message that isn't related to the container instance, but rather to Azure itself (it looks like it sends the request to the wrong endpoint):

The messaging entity 'sb://sbemulatorns.servicebus.onebox.windows-int.net/hello-queue' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions. TrackingId:256027e76d1e4df6a348e1aa9d674be9_G0, SystemTracker:gateway1, Timestamp:2024-11-23T09:21:53 (MessagingEntityNotFound). For troubleshooting information, see https://aka.ms/azsdk/net/servicebus/exceptions/troubleshoot.

await sender.SendMessageAsync(message)
.ConfigureAwait(true);

The connection string looks like:

Endpoint=sb://127.0.0.1:53590/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true

Does someone know to configure the client?

@HofmeisterAn
Copy link
Collaborator

It looks like this is not necessarily a client issue. If I add an additional delay, the test runs fine. I assume the console log message indicates readiness too early?

@KSemenenko
Copy link
Contributor Author

Maybe it need time to create a queue?

@KSemenenko
Copy link
Contributor Author

As I see emailtaor use config.json with wheee it define queue.
And this string queueName = "queue.1 will work wideout delays?

@HofmeisterAn
Copy link
Collaborator

I copied the example from MS and changed the queue name 👍, but didn't change anything.

@tj-spyro
Copy link

The MS example docker compose config explicitly uses port 5672 on the host and then no port specified in the connection string. Perhaps the client SDK only works on that port?

@HofmeisterAn
Copy link
Collaborator

I tried the default port (without a randomly assigned host port) and a connection string without the port as well. Same behavior. Interestingly, it works with the extra delay...

@HofmeisterAn
Copy link
Collaborator

I've created an upstream issue, right now, I have no idea how to reliably indicate readiness ☝️.

@HofmeisterAn HofmeisterAn added the module An official Testcontainers module label Nov 27, 2024
@HofmeisterAn
Copy link
Collaborator

I created a PR that includes a workaround, which adds an additional two-second wait before indicating readiness. It would be great if someone could review the PR and do some tests to check if the module works as expected 🙏.

@zaritskyi1
Copy link

Thank you for creating the PR! I tested the changes on my setup (Docker with Windows 10), and the module works fine for me overall. However, I noticed that the Reuse feature isn't working in my case. I suspect it might be related to the inner MSSQL container.

Let me know if you’d like me to share more details or try something specific to help debug this issue.
Thanks again for your work on this!

@HofmeisterAn
Copy link
Collaborator

Thank you for the tests.

I noticed that the Reuse feature isn't working in my case. I suspect it might be related to the inner MSSQL container.

Ah, that makes sense. We do not forward this configuration to the MSSQL container builder. We have the same issue in the WebDriver module. Thank you for bringing this to my attention. I need to think about how we can modify the API to allow forwarding such configurations to the nested builder.

@riezebosch
Copy link

riezebosch commented Dec 6, 2024

Just a bit late to the party, I implemented this myself in this integration test and was about to ask if a contribution was appreciated. Let me know if I can be of any help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request module An official Testcontainers module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants