testcontainers-dotnet icon indicating copy to clipboard operation
testcontainers-dotnet copied to clipboard

feat: Add Azure EventHubs module

Open WakaToa opened this issue 1 year ago • 2 comments

What does this PR do?

Microsoft released an emulator for EventHubs yesterday, see https://github.com/Azure/azure-service-bus/issues/223#issuecomment-2123141525

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();

WakaToa avatar May 22 '24 12:05 WakaToa

Deploy Preview for testcontainers-dotnet ready!

Name Link
Latest commit b264e42b094d4e68b33a6b5899deb0e917ad7451
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.

netlify[bot] avatar May 22 '24 12:05 netlify[bot]

Also, please add documentation for the module.

eddumelendez avatar Jun 25 '24 21:06 eddumelendez

Hi @WakaToa / @eddumelendez / @kiview ,

I am from Azure Event Hubs Product team and was looking at this PR. I do realize that there were some plausible solutions offered above to get this integration setup.

Could you please let us know if we could extend any help from our side to integrate Event Hubs emulator with testcontainers framework? We'll be happy to provide any product related assistance here.

Saglodha avatar Jan 06 '25 06:01 Saglodha

@HofmeisterAn

I see that @WakaToa is not so responsive so I've made my fork on a top of his changes and implement everything you suggested & aligned to the latest changes. I will create new PR for that (as I dont' know how to merge it) and we can abandon this, I think.

PR: #1342

rafek1241 avatar Jan 18 '25 18:01 rafek1241