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: Add Azure EventHubs module #1183

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

WakaToa
Copy link
Contributor

@WakaToa WakaToa commented May 22, 2024

What does this PR do?

Microsoft released an emulator for EventHubs yesterday, see Azure/azure-service-bus#223 (comment)

This PR included a module for the emulator.

Info

You need to provide an Azurite (emulator) instance/endpoint to start the EventHub emulator. This can be done using the EventHubsConfiguration.

You need to specify the following configuration file when starting the emulator.

{
  "UserConfig": {
    "NamespaceConfig": [
      {
        "Type": "EventHub",
        "Name": "emulatorNs1",
        "Entities": [
          {
            "Name": "eh1",
            "PartitionCount": "2",
            "ConsumerGroups": [
              {
                "Name": "cg1"
              }
            ]
          }
        ]
      }
    ], 
    "LoggingConfig": {
      "Type": "File"
    }
  }
}

It will be dynamically mapped and i have built a floating builder so that the user can set the configuration as easily as possible.
The namespace "emulatorNs1" is mandatory and it is the only one currently supported by the emulator.

var configurationBuilder = ConfigurationBuilder
    .Create()
    .WithEventHub(EventHubName, "2", new[] { EventHubConsumerGroupName });

var builder = new EventHubsBuilder()
    .WithNetwork(_network)
    .WithConfigurationBuilder(configurationBuilder)
    .WithAzuriteBlobEndpoint(AzuriteNetworkAlias)
    .WithAzuriteTableEndpoint(AzuriteNetworkAlias);

_eventHubsContainer = builder.Build();

await _eventHubsContainer.StartAsync();

Copy link

netlify bot commented May 22, 2024

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit b264e42
🔍 Latest deploy log https://app.netlify.com/sites/testcontainers-dotnet/deploys/664de1efb02bc800082444d3
😎 Deploy Preview https://deploy-preview-1183--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.

@HofmeisterAn HofmeisterAn added enhancement New feature or request module An official Testcontainers module labels May 27, 2024
Comment on lines +5 to +23
private readonly AzuriteContainer _azuriteContainer;

private EventHubsContainer _eventHubsContainer;

private readonly INetwork _network = new NetworkBuilder().WithName(NetworkName).Build();

private const string NetworkName = "eh-network";
private const string AzuriteNetworkAlias = "azurite";

private const string EventHubName = "testeventhub";
private const string EventHubConsumerGroupName = "testconsumergroup";

private EventHubsContainerTest()
{
_azuriteContainer = new AzuriteBuilder()
.WithNetwork(_network)
.WithNetworkAliases(AzuriteNetworkAlias)
.Build();
}
Copy link
Member

Choose a reason for hiding this comment

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

This is an idea still but due to EventHubs emulator will not work without Azurite then we can provide two ways to run EventHub Container implementation.

  1. Embed Azurite, so, users don't worry about it.
  2. Allow external Azurite in case users need a specific configuration

/cc @kiview WDYT?

Choose a reason for hiding this comment

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

Does a pattern exist already ?

@eddumelendez
Copy link
Member

Also, please add documentation for the module.

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.

4 participants