You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Problem
The current implementation of
Testcontainers.ServiceBus
automatically sets upMsSqlContainer
, 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 usingWebApplicationFactory<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 useDependsOn
ifMsSqlContainer
and is not null.Another possible solution would be to expose an API on
ServiceBusBuilder
to allow consumers to set theMSSQL_SA_PASSWORD
andSQL_SERVER
environment variables like theServiceBusBuilder.WithAcceptLicenseAgreement
is exposed. This way we can benefit from methods likeDependsOn
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
andIContainer
and manually bind the Azure Service Bus emulator container with an existing SQL Server container.Would you like to help contributing this enhancement?
Yes
The text was updated successfully, but these errors were encountered: