-
-
Notifications
You must be signed in to change notification settings - Fork 341
feat(ServiceBus): Add support to use existing MSSQL container instances #1335
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bf3a42f
feat: add exposed API to attach MsSqlContainer to Azure Service Bus e…
lgcmotta 3c3c2b9
feat: invoke CreateAsync for each network attached to ServiceBusConta…
lgcmotta 632aba5
test: create test with custom instance of MsSqlContainer to attach to…
lgcmotta 761cea3
docs: enhance summary documentation for WithMsSqlContainer
lgcmotta 2f74cd3
refactor: remove network and mssql start from asb emulator test
lgcmotta fee3432
refactor: enumerate networks to array before invoking create async
lgcmotta fee7110
fix: exclude implicit imported IContainer types when checking for IDa…
lgcmotta 209b2a6
Merge branch 'develop' into develop
lgcmotta 89c3040
test: move service bus container test to abstract class and resolve c…
lgcmotta 8a5f3a0
refactor: reuse public WithMsSqlContainer when invoking private WithM…
lgcmotta 562ffd3
refactor: change summary docs to consistently use MSSQL instead of SQL
lgcmotta 1d4547f
fix: remove commented code
lgcmotta d78b741
refactor: make ServiceBusContainerTest constructor protected
lgcmotta 9611f83
refactor: place service bus test with default MSSQL before the custom
lgcmotta 952839b
fix: commit 8a5f3a0 causes MSSQL container to be duplicated when usin…
lgcmotta 4aa61f2
refactor: move ASB emulator tests to inside ServiceBusContainerTest c…
lgcmotta c54334c
chore: reverting `Single` invoke when creating container's network
lgcmotta a4ef713
feat: move defaults (network and MSSQL) setup from Init to Build
lgcmotta 791f694
chore: merge upstream/develop into develop
lgcmotta a8b822b
refactor: Rearrange default MSSQL configuration
HofmeisterAn 01c1611
chore: Remove using
HofmeisterAn e3ce1df
Merge remote-tracking branch 'origin/develop' into fork/lgcmotta/develop
HofmeisterAn 79e36e1
Merge branch 'develop' into develop
lgcmotta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/Testcontainers.ServiceBus.Tests/ServiceBusContainerWithCustomMsSqlTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| namespace Testcontainers.ServiceBus; | ||
|
|
||
| public class ServiceBusContainerWithCustomMsSqlTest : IAsyncLifetime | ||
lgcmotta marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| private static readonly INetwork Network = new NetworkBuilder().Build(); | ||
|
|
||
| private readonly ServiceBusContainer _serviceBusContainer = new ServiceBusBuilder() | ||
| .WithNetwork(Network) | ||
| .WithAcceptLicenseAgreement(true) | ||
| .WithMsSqlContainer(new MsSqlBuilder() | ||
| .WithImage("mcr.microsoft.com/azure-sql-edge:latest") | ||
| .WithNetwork(Network) | ||
| .WithNetworkAliases("sql-server") | ||
| .Build(), "sql-server") | ||
| .Build(); | ||
|
|
||
| public Task InitializeAsync() | ||
| { | ||
| return _serviceBusContainer.StartAsync(); | ||
| } | ||
|
|
||
| public Task DisposeAsync() | ||
| { | ||
| return _serviceBusContainer.DisposeAsync().AsTask(); | ||
| } | ||
|
|
||
| [Fact] | ||
| [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] | ||
| public async Task ReceiveMessageReturnsSentMessage() | ||
| { | ||
| // Given | ||
| const string helloServiceBus = "Hello, Service Bus!"; | ||
|
|
||
| // By default, the emulator uses the following configuration: | ||
| // https://learn.microsoft.com/en-us/azure/service-bus-messaging/test-locally-with-service-bus-emulator?tabs=automated-script#interact-with-the-emulator. | ||
|
|
||
| // Upload a custom configuration before the container starts using the | ||
| // `WithResourceMapping(string, string)` API or one of its overloads: | ||
| // `WithResourceMapping("Config.json", "/ServiceBus_Emulator/ConfigFiles/")`. | ||
| const string queueName = "queue.1"; | ||
|
|
||
| var message = new ServiceBusMessage(helloServiceBus); | ||
|
|
||
| await using var client = new ServiceBusClient(_serviceBusContainer.GetConnectionString()); | ||
|
|
||
| var sender = client.CreateSender(queueName); | ||
|
|
||
| var receiver = client.CreateReceiver(queueName); | ||
|
|
||
| // When | ||
| await sender.SendMessageAsync(message) | ||
| .ConfigureAwait(true); | ||
|
|
||
| var receivedMessage = await receiver.ReceiveMessageAsync() | ||
| .ConfigureAwait(true); | ||
|
|
||
| // Then | ||
| Assert.Equal(helloServiceBus, receivedMessage.Body.ToString()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| global using System; | ||
| global using System.Threading.Tasks; | ||
| global using Azure.Messaging.ServiceBus; | ||
| global using DotNet.Testcontainers.Builders; | ||
| global using DotNet.Testcontainers.Commons; | ||
| global using DotNet.Testcontainers.Networks; | ||
| global using Testcontainers.MsSql; | ||
| global using Xunit; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.