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]: Allow Azure Service Bus to use an existent instance of MsSqlContainer #1323

Open
lgcmotta opened this issue Dec 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@lgcmotta
Copy link

lgcmotta commented Dec 27, 2024

Problem

The current implementation of Testcontainers.ServiceBus automatically sets up MsSqlContainer, but if running integration tests using the Azure Service Bus and SQL Server, we end up having 2 SQL Server containers + 1 Azure Service Bus emulator. This can consume significant resources in the integration tests' environment. When using WebApplicationFactory<T> these numbers can easily scale.

Solution

A possible solution is to create a public overload of ServiceBusBuilder.WithMsSqlContainer that receives a MsSqlContainer, the password and the network alias as optional parameters and use DependsOn if MsSqlContainer and is not null.

Another possible solution would be to expose an API on ServiceBusBuilder to allow consumers to set the MSSQL_SA_PASSWORD and SQL_SERVER environment variables like the ServiceBusBuilder.WithAcceptLicenseAgreement is exposed. This way we can benefit from methods like DependsOn and wait strategies to synchronize the order in which containers should start.

The third option would be to expose the already created SQL Server from Testcontainers.ServiceBus and let consumers use it to test against it, but allowing them to override the SQL Server image if desired.

Benefit

If testing against SQL Server and Azure service bus, we can have one container less on the test environment, saving resources and speeding up test execution. Consumers may use different SQL Server images, meaning one image less to pull before test execution in pipelines.

Alternatives

Alternatively, it's possible to implement an Azure Service Bus emulator on the test environment, using ContainerBuilder and IContainer and manually bind the Azure Service Bus emulator container with an existing SQL Server container.

Would you like to help contributing this enhancement?

Yes

@lgcmotta lgcmotta added the enhancement New feature or request label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant