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

feat(ServiceBus): Add support to use existing MSSQL container instances #1335

Merged
merged 23 commits into from
Feb 3, 2025

Conversation

lgcmotta
Copy link
Contributor

@lgcmotta lgcmotta commented Jan 11, 2025

What does this PR do?

This PR exposes an overload of WithMsSqlContainer, enabling users to attach an existing MsSqlContainer instance to the Azure Service Bus emulator. Previously, ServiceBusContainer automatically spun up its own SQL Server container, leading to unnecessary duplication when users were already testing with Azure Service Bus and SQL Server (see #1323).

Why is it important?

This enhancement addresses the resource usage issues described in #1323. By allowing a single MsSqlContainer to be shared, the overhead of launching a separate SQL Server container to use the Azure Service Bus emulator is eliminated. This can be especially beneficial in CI/CD scenarios or other environments where minimizing resource consumption and reducing test execution time is a priority.

Related issues

How to test this PR

  • A new test has been added that demonstrates attaching a custom MsSqlContainer to ServiceBusContainer.
  • Ensure both containers (ServiceBusContainer and MsSqlContainer) are on the same network.
  • Use a non-default SQL Server image, for example: mcr.microsoft.com/azure-sql-edge:latest.
  • Verify that only the containers you intend to run are launched (Azure SQL Edge for SQL Server, and the Azure Service Bus emulator), and that mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04 (the default in MsSqlBuilder) is not spun up.

Follow-ups

None at this time. Inline summary documentation is included in the new overload.

Copy link

netlify bot commented Jan 11, 2025

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 79e36e1
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/67a0c39aaad5b80008f7eb9b
😎 Deploy Preview https://deploy-preview-1335--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I've slightly rearranged the Build() method and added INetwork as an argument to WithMsSqlContainer(...). I believe it feels more natural for developers to pass the network along with the container instance, as this way they don't have to remember to add the Service Bus Container to the same network. It's more likely to be configured correctly this way, I think. Let me know what you think. I'm happy to merge the PR if you're okay with the changes. Thanks ✌️.

@HofmeisterAn HofmeisterAn added enhancement New feature or request module An official Testcontainers module labels Jan 31, 2025
@HofmeisterAn HofmeisterAn changed the title feat(servicebus): Add support to use a custom MsSqlContainer instance with Service Bus emulator feat(ServiceBus): Add support to use existing MSSQL container instances Jan 31, 2025
@lgcmotta
Copy link
Contributor Author

lgcmotta commented Feb 3, 2025

Thanks for the PR. I've slightly rearranged the Build() method and added INetwork as an argument to WithMsSqlContainer(...). I believe it feels more natural for developers to pass the network along with the container instance, as this way they don't have to remember to add the Service Bus Container to the same network. It's more likely to be configured correctly this way, I think. Let me know what you think. I'm happy to merge the PR if you're okay with the changes. Thanks ✌️.

Hey @HofmeisterAn, I agree with you, it makes sense to pass the INetwork with the MsSqlContainer. You can merge these changes!! Thank you for the feedback and contribution to the PR!

@HofmeisterAn HofmeisterAn merged commit ae50c59 into testcontainers:develop Feb 3, 2025
58 checks passed
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 this pull request may close these issues.

[Enhancement]: Allow Azure Service Bus to use an existent instance of MsSqlContainer
3 participants